@shopware-ag/dive 1.16.24 → 1.16.26-beta.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.
Files changed (44) hide show
  1. package/build/dive.cjs +1652 -203
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.d.cts +50 -8
  4. package/build/dive.d.ts +50 -8
  5. package/build/dive.js +1619 -159
  6. package/build/dive.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/ar/AR.ts +164 -0
  9. package/src/ar/arquicklook/ARQuickLook.ts +42 -0
  10. package/src/ar/webxr/WebXR.ts +176 -0
  11. package/src/ar/webxr/controller/WebXRController.ts +334 -0
  12. package/src/ar/webxr/crosshair/WebXRCrosshair.ts +35 -0
  13. package/src/ar/webxr/origin/WebXROrigin.ts +191 -0
  14. package/src/ar/webxr/overlay/Overlay.ts +50 -0
  15. package/src/ar/webxr/raycaster/WebXRRaycaster.ts +131 -0
  16. package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +102 -0
  17. package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +49 -0
  18. package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +356 -0
  19. package/src/axiscamera/AxisCamera.ts +4 -4
  20. package/src/axiscamera/__test__/AxisCamera.test.ts +4 -0
  21. package/src/com/Communication.ts +17 -0
  22. package/src/com/__test__/Communication.test.ts +1 -1
  23. package/src/com/actions/index.ts +2 -0
  24. package/src/dive.ts +51 -9
  25. package/src/events/EventExecutor.ts +35 -0
  26. package/src/helper/findSceneRecursive/findSceneRecursive.ts +2 -2
  27. package/src/info/Info.ts +37 -1
  28. package/src/info/__test__/Info.test.ts +45 -5
  29. package/src/mediacreator/MediaCreator.ts +4 -4
  30. package/src/mediacreator/__test__/MediaCreator.test.ts +7 -2
  31. package/src/renderer/Renderer.ts +21 -11
  32. package/src/renderer/__test__/Renderer.test.ts +19 -1
  33. package/src/scene/Scene.ts +35 -12
  34. package/src/scene/__test__/Scene.test.ts +39 -5
  35. package/src/scene/root/Root.ts +1 -0
  36. package/src/scene/xrroot/XRRoot.ts +56 -0
  37. package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +80 -0
  38. package/src/toolbox/BaseTool.ts +9 -3
  39. package/src/toolbox/Toolbox.ts +1 -1
  40. package/src/toolbox/__test__/Toolbox.test.ts +1 -1
  41. package/src/toolbox/select/SelectTool.ts +1 -1
  42. package/src/toolbox/select/__test__/SelectTool.test.ts +1 -1
  43. package/src/toolbox/transform/TransformTool.ts +4 -4
  44. package/src/toolbox/transform/__test__/TransformTool.test.ts +2 -4
package/build/dive.cjs CHANGED
@@ -325,19 +325,19 @@ var init_BaseTool = __esm({
325
325
  });
326
326
 
327
327
  // src/toolbox/transform/TransformTool.ts
328
- var import_Addons, DIVETransformTool;
328
+ var import_TransformControls, DIVETransformTool;
329
329
  var init_TransformTool = __esm({
330
330
  "src/toolbox/transform/TransformTool.ts"() {
331
331
  "use strict";
332
332
  init_BaseTool();
333
- import_Addons = require("three/examples/jsm/Addons");
333
+ import_TransformControls = require("three/examples/jsm/controls/TransformControls");
334
334
  init_implementsInterface();
335
335
  DIVETransformTool = class extends DIVEBaseTool {
336
336
  constructor(scene, controller) {
337
337
  super(scene, controller);
338
338
  this.isTransformTool = true;
339
339
  this.name = "DIVETransformTool";
340
- this._gizmo = new import_Addons.TransformControls(
340
+ this._gizmo = new import_TransformControls.TransformControls(
341
341
  this._controller.object,
342
342
  this._controller.domElement
343
343
  );
@@ -371,7 +371,7 @@ var init_TransformTool = __esm({
371
371
  if (!this._gizmo.object.onMoveEnd) return;
372
372
  this._gizmo.object.onMoveEnd();
373
373
  });
374
- scene.add(this._gizmo);
374
+ this._scene.add(this._gizmo);
375
375
  }
376
376
  Activate() {
377
377
  }
@@ -636,6 +636,1398 @@ var init_IO = __esm({
636
636
  }
637
637
  });
638
638
 
639
+ // src/info/Info.ts
640
+ var WebXRUnsupportedReason, DIVEInfo;
641
+ var init_Info = __esm({
642
+ "src/info/Info.ts"() {
643
+ "use strict";
644
+ WebXRUnsupportedReason = /* @__PURE__ */ ((WebXRUnsupportedReason2) => {
645
+ WebXRUnsupportedReason2[WebXRUnsupportedReason2["UNKNWON_ERROR"] = 0] = "UNKNWON_ERROR";
646
+ WebXRUnsupportedReason2[WebXRUnsupportedReason2["NO_HTTPS"] = 1] = "NO_HTTPS";
647
+ WebXRUnsupportedReason2[WebXRUnsupportedReason2["IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE"] = 2] = "IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE";
648
+ WebXRUnsupportedReason2[WebXRUnsupportedReason2["AR_SESSION_NOT_ALLOWED"] = 3] = "AR_SESSION_NOT_ALLOWED";
649
+ return WebXRUnsupportedReason2;
650
+ })(WebXRUnsupportedReason || {});
651
+ DIVEInfo = class {
652
+ /**
653
+ *
654
+ * @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
655
+ */
656
+ static GetSystem() {
657
+ const platform = navigator.platform;
658
+ if (/Android/.test(navigator.userAgent)) {
659
+ return "Android";
660
+ } else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
661
+ return "iOS";
662
+ } else if (platform.startsWith("Win")) {
663
+ return "Windows";
664
+ } else if (platform.startsWith("Mac")) {
665
+ return "MacOS";
666
+ } else if (platform.startsWith("Linux")) {
667
+ return "Linux";
668
+ } else {
669
+ return "Unknown";
670
+ }
671
+ }
672
+ /**
673
+ * @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
674
+ */
675
+ static GetSupportsWebXR() {
676
+ return __async(this, null, function* () {
677
+ if (this._supportsWebXR !== null) {
678
+ return this._supportsWebXR;
679
+ }
680
+ if (!navigator.xr) {
681
+ this._supportsWebXR = false;
682
+ if (window.isSecureContext === false) {
683
+ this._webXRUnsupportedReason = 1 /* NO_HTTPS */;
684
+ } else {
685
+ this._webXRUnsupportedReason = 0 /* UNKNWON_ERROR */;
686
+ }
687
+ return this._supportsWebXR;
688
+ }
689
+ try {
690
+ const supported = yield navigator.xr.isSessionSupported("immersive-ar");
691
+ if (!supported) {
692
+ this._webXRUnsupportedReason = 2 /* IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE */;
693
+ }
694
+ this._supportsWebXR = supported;
695
+ } catch (error) {
696
+ this._supportsWebXR = false;
697
+ this._webXRUnsupportedReason = 3 /* AR_SESSION_NOT_ALLOWED */;
698
+ }
699
+ return this._supportsWebXR;
700
+ });
701
+ }
702
+ /**
703
+ * @returns The reason why WebXR is not supported on the user's device. Returns null if WebXR is supported nor not has been checked yet.
704
+ */
705
+ static GetWebXRUnsupportedReason() {
706
+ if (this._supportsWebXR === null) {
707
+ console.log("WebXR support has not been checked yet.");
708
+ return null;
709
+ }
710
+ return this._webXRUnsupportedReason;
711
+ }
712
+ /**
713
+ * @returns A boolean indicating whether the user's device supports AR Quick Look.
714
+ */
715
+ static GetSupportsARQuickLook() {
716
+ const a = document.createElement("a");
717
+ if (a.relList.supports("ar")) {
718
+ return true;
719
+ }
720
+ const userAgent = navigator.userAgent;
721
+ const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
722
+ if (!isIOS) {
723
+ return false;
724
+ }
725
+ const match = userAgent.match(/OS (\d+)_/);
726
+ if (!match || match.length < 2) {
727
+ return false;
728
+ }
729
+ const iOSVersion = parseInt(match[1], 10);
730
+ const minQuickLookVersion = 12;
731
+ if (iOSVersion < minQuickLookVersion) {
732
+ return false;
733
+ }
734
+ const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
735
+ if (isSupportedBrowser) {
736
+ return true;
737
+ }
738
+ return false;
739
+ }
740
+ /**
741
+ * @returns A boolean indicating whether the user's device is a mobile device.
742
+ */
743
+ static get isMobile() {
744
+ return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
745
+ }
746
+ /**
747
+ * @returns A boolean indicating whether the user's device is a desktop device.
748
+ */
749
+ static get isDesktop() {
750
+ return !this.isMobile;
751
+ }
752
+ /**
753
+ * @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
754
+ */
755
+ static GetIsARCapable() {
756
+ return __async(this, null, function* () {
757
+ if (this.GetSupportsARQuickLook()) {
758
+ return true;
759
+ }
760
+ return yield this.GetSupportsWebXR();
761
+ });
762
+ }
763
+ };
764
+ DIVEInfo._supportsWebXR = null;
765
+ DIVEInfo._webXRUnsupportedReason = null;
766
+ }
767
+ });
768
+
769
+ // src/ar/arquicklook/ARQuickLook.ts
770
+ var import_three5, import_USDZExporter, DIVEARQuickLook;
771
+ var init_ARQuickLook = __esm({
772
+ "src/ar/arquicklook/ARQuickLook.ts"() {
773
+ "use strict";
774
+ import_three5 = require("three");
775
+ import_USDZExporter = require("three/examples/jsm/exporters/USDZExporter");
776
+ DIVEARQuickLook = class {
777
+ static Launch(scene) {
778
+ const quickLookScene = new import_three5.Object3D();
779
+ quickLookScene.add(...this.extractModels(scene));
780
+ return this.launchARFromNode(quickLookScene);
781
+ }
782
+ static extractModels(scene) {
783
+ return scene.Root.children;
784
+ }
785
+ static launchARFromNode(node) {
786
+ return this._usdzExporter.parse(node, { quickLookCompatible: true }).then((usdz) => {
787
+ const blob = new Blob([usdz], { type: "model/vnd.usdz+zip" });
788
+ const url = URL.createObjectURL(blob);
789
+ const a = document.createElement("a");
790
+ a.innerHTML = "<picture></picture>";
791
+ a.rel = "ar";
792
+ a.href = url;
793
+ a.download = "scene.usdz";
794
+ a.click();
795
+ });
796
+ }
797
+ };
798
+ DIVEARQuickLook._usdzExporter = new import_USDZExporter.USDZExporter();
799
+ }
800
+ });
801
+
802
+ // src/ar/webxr/overlay/Overlay.ts
803
+ var Overlay;
804
+ var init_Overlay = __esm({
805
+ "src/ar/webxr/overlay/Overlay.ts"() {
806
+ "use strict";
807
+ Overlay = class {
808
+ get Element() {
809
+ return this._element;
810
+ }
811
+ get CloseButton() {
812
+ return this._closeButton;
813
+ }
814
+ constructor() {
815
+ this._element = document.createElement("div");
816
+ this._closeButton = this.createCloseButton();
817
+ this._element.appendChild(this._closeButton);
818
+ document.body.appendChild(this._element);
819
+ }
820
+ createCloseButton() {
821
+ const path = document.createElementNS(
822
+ "http://www.w3.org/2000/svg",
823
+ "path"
824
+ );
825
+ path.setAttribute("d", "M 12,12 L 28,28 M 28,12 12,28");
826
+ path.setAttribute("stroke", "#fff");
827
+ path.setAttribute("stroke-width", "2");
828
+ const svg = document.createElementNS(
829
+ "http://www.w3.org/2000/svg",
830
+ "svg"
831
+ );
832
+ svg.setAttribute("width", "38");
833
+ svg.setAttribute("height", "38");
834
+ svg.style.position = "absolute";
835
+ svg.style.right = "20px";
836
+ svg.style.top = "20px";
837
+ svg.appendChild(path);
838
+ return svg;
839
+ }
840
+ };
841
+ }
842
+ });
843
+
844
+ // src/ar/webxr/crosshair/WebXRCrosshair.ts
845
+ var import_three6, DIVEWebXRCrosshair;
846
+ var init_WebXRCrosshair = __esm({
847
+ "src/ar/webxr/crosshair/WebXRCrosshair.ts"() {
848
+ "use strict";
849
+ import_three6 = require("three");
850
+ DIVEWebXRCrosshair = class extends import_three6.Object3D {
851
+ set mesh(mesh) {
852
+ this.clear();
853
+ if (mesh) {
854
+ this.add(mesh);
855
+ }
856
+ }
857
+ constructor(mesh) {
858
+ super();
859
+ if (mesh) {
860
+ this.mesh = mesh;
861
+ } else {
862
+ this.UseDefaultMesh();
863
+ }
864
+ this.matrixAutoUpdate = false;
865
+ return this;
866
+ }
867
+ UseDefaultMesh() {
868
+ const geometry = new import_three6.RingGeometry(0.08, 0.1, 32).rotateX(-Math.PI / 2);
869
+ const material = new import_three6.MeshBasicMaterial();
870
+ this.mesh = new import_three6.Mesh(geometry, material);
871
+ }
872
+ UpdateFromPose(pose) {
873
+ this.matrix.fromArray(pose.transform.matrix);
874
+ }
875
+ };
876
+ }
877
+ });
878
+
879
+ // src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts
880
+ var import_three7, DIVEWebXRRaycasterAR;
881
+ var init_WebXRRaycasterAR = __esm({
882
+ "src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts"() {
883
+ "use strict";
884
+ import_three7 = require("three");
885
+ DIVEWebXRRaycasterAR = class {
886
+ constructor(session, renderer) {
887
+ this._referenceSpaceBuffer = null;
888
+ this._requesting = false;
889
+ this._initialized = false;
890
+ this._session = session;
891
+ this._renderer = renderer;
892
+ this._hitMatrixBuffer = new import_three7.Matrix4();
893
+ }
894
+ Dispose() {
895
+ var _a;
896
+ (_a = this._transientHitTestSource) == null ? void 0 : _a.cancel();
897
+ this._transientHitTestSource = void 0;
898
+ this._initialized = false;
899
+ }
900
+ Init() {
901
+ return __async(this, null, function* () {
902
+ if (!this._session) {
903
+ console.error(
904
+ "DIVEWebXRRaycaster: No session set in Init()! Aborting initialization..."
905
+ );
906
+ return Promise.reject();
907
+ }
908
+ if (this._requesting) {
909
+ console.error(
910
+ "DIVEWebXRRaycaster: Currently initializing! Aborting initialization..."
911
+ );
912
+ return Promise.reject();
913
+ }
914
+ if (this._initialized) {
915
+ console.error(
916
+ "DIVEWebXRRaycaster: Already initialized! Aborting initialization..."
917
+ );
918
+ return Promise.reject();
919
+ }
920
+ this._requesting = true;
921
+ this._transientHitTestSource = yield this._session.requestHitTestSourceForTransientInput({
922
+ profile: "generic-touchscreen"
923
+ });
924
+ this._referenceSpaceBuffer = this._renderer.xr.getReferenceSpace();
925
+ this._requesting = false;
926
+ if (!this._transientHitTestSource) {
927
+ return Promise.reject();
928
+ }
929
+ this._initialized = true;
930
+ console.log("DIVEWebXRRaycasterAR: Initialized");
931
+ return Promise.resolve(this);
932
+ });
933
+ }
934
+ GetIntersections(frame) {
935
+ if (!this._transientHitTestSource) return [];
936
+ const touches = frame.getHitTestResultsForTransientInput(
937
+ this._transientHitTestSource
938
+ );
939
+ if (touches.length === 0) return [];
940
+ const hits = touches.map((touch) => {
941
+ if (!this._referenceSpaceBuffer) return void 0;
942
+ if (!touch.results[0]) return void 0;
943
+ if (!touch.results[0].getPose) return void 0;
944
+ const pose = touch.results[0].getPose(this._referenceSpaceBuffer);
945
+ if (!pose) return void 0;
946
+ this._hitMatrixBuffer.fromArray(pose.transform.matrix);
947
+ const position = new import_three7.Vector3().setFromMatrixPosition(
948
+ this._hitMatrixBuffer
949
+ );
950
+ return {
951
+ point: position,
952
+ matrix: this._hitMatrixBuffer,
953
+ object: void 0
954
+ };
955
+ });
956
+ return hits.filter((hit) => hit !== void 0);
957
+ }
958
+ };
959
+ }
960
+ });
961
+
962
+ // src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts
963
+ var import_three8, DIVEWebXRRaycasterTHREE;
964
+ var init_WebXRRaycasterTHREE = __esm({
965
+ "src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts"() {
966
+ "use strict";
967
+ import_three8 = require("three");
968
+ DIVEWebXRRaycasterTHREE = class {
969
+ constructor(renderer, scene) {
970
+ // internal raycaster
971
+ this._raycaster = new import_three8.Raycaster();
972
+ this._renderer = renderer;
973
+ this._scene = scene;
974
+ this._controller = this._renderer.xr.getController(0);
975
+ }
976
+ Init() {
977
+ return __async(this, null, function* () {
978
+ console.log("DIVEWebXRRaycasterTHREE: Initialized");
979
+ return Promise.resolve(this);
980
+ });
981
+ }
982
+ GetIntersections() {
983
+ this._controller.updateMatrixWorld();
984
+ this._raycaster.setFromXRController(this._controller);
985
+ const intersections = this._raycaster.intersectObjects(
986
+ this._scene.XRRoot.XRModelRoot.children
987
+ );
988
+ if (intersections.length === 0) return [];
989
+ return intersections.map((intersection) => {
990
+ return {
991
+ point: intersection.point,
992
+ matrix: intersection.object.matrixWorld,
993
+ object: intersection.object
994
+ };
995
+ });
996
+ }
997
+ };
998
+ }
999
+ });
1000
+
1001
+ // src/events/EventExecutor.ts
1002
+ var DIVEEventExecutor;
1003
+ var init_EventExecutor = __esm({
1004
+ "src/events/EventExecutor.ts"() {
1005
+ "use strict";
1006
+ DIVEEventExecutor = class {
1007
+ constructor() {
1008
+ this._listeners = /* @__PURE__ */ new Map();
1009
+ }
1010
+ Subscribe(type, listener) {
1011
+ if (!this._listeners.get(type)) this._listeners.set(type, []);
1012
+ this._listeners.get(type).push(listener);
1013
+ return () => {
1014
+ const listenerArray = this._listeners.get(type);
1015
+ if (!listenerArray) return false;
1016
+ const existingIndex = listenerArray.findIndex(
1017
+ (entry) => entry === listener
1018
+ );
1019
+ if (existingIndex === -1) return false;
1020
+ listenerArray.splice(existingIndex, 1);
1021
+ return true;
1022
+ };
1023
+ }
1024
+ dispatch(type, payload) {
1025
+ const listenerArray = this._listeners.get(type);
1026
+ if (!listenerArray) return;
1027
+ listenerArray.forEach((listener) => listener(payload));
1028
+ }
1029
+ };
1030
+ }
1031
+ });
1032
+
1033
+ // src/ar/webxr/raycaster/WebXRRaycaster.ts
1034
+ var DIVEWebXRRaycaster;
1035
+ var init_WebXRRaycaster = __esm({
1036
+ "src/ar/webxr/raycaster/WebXRRaycaster.ts"() {
1037
+ "use strict";
1038
+ init_WebXRRaycasterAR();
1039
+ init_WebXRRaycasterTHREE();
1040
+ init_EventExecutor();
1041
+ DIVEWebXRRaycaster = class extends DIVEEventExecutor {
1042
+ constructor(session, renderer, scene) {
1043
+ super();
1044
+ this._initialized = false;
1045
+ this._arHitResultBuffer = [];
1046
+ this._sceneHitResultBuffer = [];
1047
+ // buffers
1048
+ this._hasHit = false;
1049
+ this._session = session;
1050
+ this._threeRaycaster = new DIVEWebXRRaycasterTHREE(renderer, scene);
1051
+ this._arRaycaster = new DIVEWebXRRaycasterAR(session, renderer);
1052
+ }
1053
+ Dispose() {
1054
+ this._initialized = false;
1055
+ }
1056
+ Init() {
1057
+ return __async(this, null, function* () {
1058
+ if (!this._session) {
1059
+ console.error(
1060
+ "DIVEWebXRRaycaster: No session set in Init()! Aborting initialization..."
1061
+ );
1062
+ return Promise.reject();
1063
+ }
1064
+ if (this._initialized) {
1065
+ console.error(
1066
+ "DIVEWebXRRaycaster: Already initialized! Aborting initialization..."
1067
+ );
1068
+ return Promise.reject();
1069
+ }
1070
+ yield this._threeRaycaster.Init();
1071
+ yield this._arRaycaster.Init();
1072
+ console.log("DIVEWebXRRaycaster: Initialized");
1073
+ this._initialized = true;
1074
+ return Promise.resolve(this);
1075
+ });
1076
+ }
1077
+ GetARIntersections(frame) {
1078
+ this._arHitResultBuffer = this._arRaycaster.GetIntersections(frame);
1079
+ if (this._arHitResultBuffer.length > 0) {
1080
+ this.onARHitFound(this._arHitResultBuffer[0]);
1081
+ } else {
1082
+ this.onARHitLost();
1083
+ }
1084
+ return this._arHitResultBuffer;
1085
+ }
1086
+ GetSceneIntersections() {
1087
+ this._sceneHitResultBuffer = this._threeRaycaster.GetIntersections();
1088
+ if (this._sceneHitResultBuffer.length > 0) {
1089
+ this.onSceneHitFound(this._sceneHitResultBuffer[0]);
1090
+ } else {
1091
+ this.onSceneHitLost();
1092
+ }
1093
+ return this._sceneHitResultBuffer;
1094
+ }
1095
+ onARHitFound(hit) {
1096
+ this._hasHit = true;
1097
+ this.dispatch("AR_HIT_FOUND", { hit });
1098
+ }
1099
+ onARHitLost() {
1100
+ if (!this._hasHit) return;
1101
+ this._hasHit = false;
1102
+ this.dispatch("AR_HIT_LOST");
1103
+ }
1104
+ onSceneHitFound(hit) {
1105
+ this._hasHit = true;
1106
+ this.dispatch("SCENE_HIT_FOUND", { hit });
1107
+ }
1108
+ onSceneHitLost() {
1109
+ if (!this._hasHit) return;
1110
+ this._hasHit = false;
1111
+ this.dispatch("SCENE_HIT_LOST");
1112
+ }
1113
+ };
1114
+ }
1115
+ });
1116
+
1117
+ // src/ar/webxr/origin/WebXROrigin.ts
1118
+ var import_three9, DIVEWebXROrigin;
1119
+ var init_WebXROrigin = __esm({
1120
+ "src/ar/webxr/origin/WebXROrigin.ts"() {
1121
+ "use strict";
1122
+ import_three9 = require("three");
1123
+ DIVEWebXROrigin = class {
1124
+ constructor(session, renderer, entityTypes) {
1125
+ this._raycastHitCounter = 0;
1126
+ this._originSetResolve = () => {
1127
+ };
1128
+ this._renderer = renderer;
1129
+ this._session = session;
1130
+ this._originSet = new Promise((resolve) => {
1131
+ this._originSetResolve = resolve;
1132
+ });
1133
+ this._requesting = false;
1134
+ this._initialized = false;
1135
+ this._referenceSpaceBuffer = null;
1136
+ this._hitTestSource = null;
1137
+ this._entityTypes = entityTypes || ["plane"];
1138
+ this._hitTestResultBuffer = [];
1139
+ this._matrix = new import_three9.Matrix4();
1140
+ this._position = new import_three9.Vector3();
1141
+ this._quaternion = new import_three9.Quaternion();
1142
+ this._scale = new import_three9.Vector3();
1143
+ this._originSet.then(() => {
1144
+ this._matrix.decompose(
1145
+ this._position,
1146
+ this._quaternion,
1147
+ this._scale
1148
+ );
1149
+ });
1150
+ }
1151
+ get originSet() {
1152
+ return this._originSet;
1153
+ }
1154
+ get matrix() {
1155
+ return this._matrix;
1156
+ }
1157
+ set matrix(value) {
1158
+ this._matrix = value;
1159
+ this._matrix.decompose(this._position, this._quaternion, this._scale);
1160
+ }
1161
+ get position() {
1162
+ return this._position;
1163
+ }
1164
+ get quaternion() {
1165
+ return this._quaternion;
1166
+ }
1167
+ get scale() {
1168
+ return this._scale;
1169
+ }
1170
+ Init() {
1171
+ return __async(this, null, function* () {
1172
+ if (this._initialized) {
1173
+ return Promise.resolve(this);
1174
+ }
1175
+ if (!this._session) {
1176
+ console.error(
1177
+ "DIVEWebXROrigin: No session set in Init()! Aborting initialization..."
1178
+ );
1179
+ return Promise.reject();
1180
+ }
1181
+ if (this._requesting) {
1182
+ console.error(
1183
+ "DIVEWebXROrigin: Currently initializing! Aborting initialization..."
1184
+ );
1185
+ return Promise.reject();
1186
+ }
1187
+ this._requesting = true;
1188
+ const referenceSpace = yield this._session.requestReferenceSpace("viewer");
1189
+ this._hitTestSource = (yield this._session.requestHitTestSource({
1190
+ space: referenceSpace,
1191
+ entityTypes: this._entityTypes
1192
+ })) || null;
1193
+ this._requesting = false;
1194
+ if (!this._hitTestSource) {
1195
+ return Promise.reject();
1196
+ }
1197
+ this._initialized = true;
1198
+ return Promise.resolve(this);
1199
+ });
1200
+ }
1201
+ Dispose() {
1202
+ var _a;
1203
+ this._initialized = false;
1204
+ this._requesting = false;
1205
+ (_a = this._hitTestSource) == null ? void 0 : _a.cancel();
1206
+ this._hitTestSource = null;
1207
+ this._hitTestResultBuffer = [];
1208
+ this._matrix = new import_three9.Matrix4();
1209
+ this._position = new import_three9.Vector3();
1210
+ this._quaternion = new import_three9.Quaternion();
1211
+ this._scale = new import_three9.Vector3();
1212
+ }
1213
+ Update(frame) {
1214
+ if (!this._initialized) return;
1215
+ if (!this._hitTestSource) {
1216
+ throw new Error(
1217
+ "DIVEWebXRRaycaster: Critical Error: HitTestSource not available but WebXROrigin is initialized!"
1218
+ );
1219
+ }
1220
+ this._hitTestResultBuffer = frame.getHitTestResults(
1221
+ this._hitTestSource
1222
+ );
1223
+ if (this._hitTestResultBuffer.length > 0) {
1224
+ this._referenceSpaceBuffer = this._renderer.xr.getReferenceSpace();
1225
+ if (!this._referenceSpaceBuffer) {
1226
+ this.onHitLost();
1227
+ return;
1228
+ }
1229
+ const pose = this._hitTestResultBuffer[0].getPose(
1230
+ this._referenceSpaceBuffer
1231
+ );
1232
+ if (!pose) {
1233
+ this.onHitLost();
1234
+ return;
1235
+ }
1236
+ this.onHitFound(pose);
1237
+ } else {
1238
+ this.onHitLost();
1239
+ }
1240
+ }
1241
+ onHitFound(pose) {
1242
+ this._raycastHitCounter++;
1243
+ this.matrix.fromArray(pose.transform.matrix);
1244
+ if (this._raycastHitCounter > 50) {
1245
+ this._originSetResolve();
1246
+ }
1247
+ }
1248
+ onHitLost() {
1249
+ this._raycastHitCounter = 0;
1250
+ }
1251
+ };
1252
+ }
1253
+ });
1254
+
1255
+ // src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts
1256
+ var import_three10, DIVEWebXRTouchscreenControls;
1257
+ var init_WebXRTouchscreenControls = __esm({
1258
+ "src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts"() {
1259
+ "use strict";
1260
+ import_three10 = require("three");
1261
+ init_EventExecutor();
1262
+ DIVEWebXRTouchscreenControls = class extends DIVEEventExecutor {
1263
+ constructor(session) {
1264
+ super();
1265
+ // touch members
1266
+ this._touchCount = 0;
1267
+ this._touches = [];
1268
+ // rotate members
1269
+ this._handleRotateStarted = false;
1270
+ this._handleRotateMoved = false;
1271
+ this._handleRotateEnded = false;
1272
+ this._startAngle = 0;
1273
+ this._lastAngle = 0;
1274
+ this._angleDelta = 0;
1275
+ // scale members
1276
+ this._handlePinchStarted = false;
1277
+ this._handlePinchMoved = false;
1278
+ this._handlePinchEnded = false;
1279
+ this._scaleDistanceStart = 0;
1280
+ this._currentDistance = 1;
1281
+ this._deltaDistance = 0;
1282
+ this._session = session;
1283
+ this._touches = [
1284
+ {
1285
+ start: new import_three10.Vector2(),
1286
+ current: new import_three10.Vector2(),
1287
+ delta: new import_three10.Vector2()
1288
+ },
1289
+ {
1290
+ start: new import_three10.Vector2(),
1291
+ current: new import_three10.Vector2(),
1292
+ delta: new import_three10.Vector2()
1293
+ }
1294
+ ];
1295
+ this._handleRotateStarted = false;
1296
+ window.addEventListener(
1297
+ "touchstart",
1298
+ (e) => this.onTouchStart(e)
1299
+ );
1300
+ window.addEventListener(
1301
+ "touchmove",
1302
+ (e) => this.onTouchMove(e)
1303
+ );
1304
+ window.addEventListener(
1305
+ "touchend",
1306
+ (e) => this.onTouchEnd(e)
1307
+ );
1308
+ this._session.addEventListener(
1309
+ "selectstart",
1310
+ () => this.onSessionSelectStart()
1311
+ );
1312
+ this._session.addEventListener(
1313
+ "selectend",
1314
+ () => this.onSessionSelectEnd()
1315
+ );
1316
+ }
1317
+ Dispose() {
1318
+ window.removeEventListener(
1319
+ "touchstart",
1320
+ (e) => this.onTouchStart(e)
1321
+ );
1322
+ window.removeEventListener(
1323
+ "touchmove",
1324
+ (e) => this.onTouchMove(e)
1325
+ );
1326
+ window.removeEventListener(
1327
+ "touchend",
1328
+ (e) => this.onTouchEnd(e)
1329
+ );
1330
+ this._session.removeEventListener(
1331
+ "selectstart",
1332
+ () => this.onSessionSelectStart()
1333
+ );
1334
+ this._session.removeEventListener(
1335
+ "selectend",
1336
+ () => this.onSessionSelectEnd()
1337
+ );
1338
+ }
1339
+ onTouchStart(event) {
1340
+ this._touchCount = event.touches.length;
1341
+ this._touches[0].start.set(
1342
+ event.touches[0].clientX,
1343
+ event.touches[0].clientY
1344
+ );
1345
+ this._touches[0].current.set(
1346
+ event.touches[0].clientX,
1347
+ event.touches[0].clientY
1348
+ );
1349
+ this._touches[0].delta.set(0, 0);
1350
+ if (this._touchCount > 1) {
1351
+ this._touches[1].start.set(
1352
+ event.touches[1].clientX,
1353
+ event.touches[1].clientY
1354
+ );
1355
+ this._touches[1].current.set(
1356
+ event.touches[1].clientX,
1357
+ event.touches[1].clientY
1358
+ );
1359
+ this._touches[1].delta.set(0, 0);
1360
+ }
1361
+ if (this._touchCount === 2) {
1362
+ this.handleRotateStart();
1363
+ this.handlePinchStart();
1364
+ }
1365
+ if (this._handleRotateStarted) {
1366
+ this.dispatch("ROTATE_START", {
1367
+ current: 0
1368
+ });
1369
+ this._handleRotateStarted = false;
1370
+ }
1371
+ if (this._handlePinchStarted) {
1372
+ this.dispatch("PINCH_START", {
1373
+ current: 0
1374
+ });
1375
+ this._handlePinchStarted = false;
1376
+ }
1377
+ }
1378
+ onTouchMove(event) {
1379
+ this._touchCount = event.touches.length;
1380
+ this._touches[0].start.set(
1381
+ event.touches[0].clientX,
1382
+ event.touches[0].clientY
1383
+ );
1384
+ this._touches[0].current.set(
1385
+ event.touches[0].clientX,
1386
+ event.touches[0].clientY
1387
+ );
1388
+ this._touches[0].delta.copy(
1389
+ this._touches[0].current.clone().sub(this._touches[0].start)
1390
+ );
1391
+ if (this._touchCount > 1) {
1392
+ this._touches[1].start.set(
1393
+ event.touches[1].clientX,
1394
+ event.touches[1].clientY
1395
+ );
1396
+ this._touches[1].current.set(
1397
+ event.touches[1].clientX,
1398
+ event.touches[1].clientY
1399
+ );
1400
+ this._touches[1].delta.copy(
1401
+ this._touches[1].current.clone().sub(this._touches[1].start)
1402
+ );
1403
+ }
1404
+ if (this._touchCount === 2) {
1405
+ this.handleRotateMoved();
1406
+ this.handlePinchMoved();
1407
+ }
1408
+ if (this._touchCount === 1) {
1409
+ this.dispatch("TOUCH_MOVE", {
1410
+ touches: [
1411
+ {
1412
+ current: this._touches[0].current.clone(),
1413
+ delta: this._touches[0].delta.clone()
1414
+ },
1415
+ {
1416
+ current: this._touches[1].current.clone(),
1417
+ delta: this._touches[1].delta.clone()
1418
+ }
1419
+ ],
1420
+ touchCount: this._touchCount
1421
+ });
1422
+ }
1423
+ if (this._touchCount === 2) {
1424
+ if (this._handleRotateMoved) {
1425
+ this.dispatch("ROTATE_MOVE", {
1426
+ current: this._lastAngle,
1427
+ delta: this._angleDelta
1428
+ });
1429
+ this._handleRotateMoved = false;
1430
+ }
1431
+ if (this._handlePinchMoved) {
1432
+ this.dispatch("PINCH_MOVE", {
1433
+ current: this._currentDistance,
1434
+ delta: this._deltaDistance
1435
+ });
1436
+ this._handlePinchMoved = false;
1437
+ }
1438
+ }
1439
+ }
1440
+ onTouchEnd(event) {
1441
+ this._touchCount = event.touches.length;
1442
+ if (this._touchCount === 0) {
1443
+ this._touches[0].start.set(0, 0);
1444
+ this._touches[0].current.set(0, 0);
1445
+ this._touches[0].delta.set(0, 0);
1446
+ }
1447
+ if (this._touchCount === 1) {
1448
+ this.handleRotateEnded();
1449
+ this.handlePinchEnded();
1450
+ this._touches[1].start.set(0, 0);
1451
+ this._touches[1].current.set(0, 0);
1452
+ this._touches[1].delta.set(0, 0);
1453
+ }
1454
+ if (this._handleRotateEnded) {
1455
+ this.dispatch("ROTATE_END", {
1456
+ current: this._lastAngle
1457
+ });
1458
+ this._handleRotateEnded = false;
1459
+ }
1460
+ if (this._handlePinchEnded) {
1461
+ this.dispatch("PINCH_END", {
1462
+ current: this._currentDistance
1463
+ });
1464
+ this._handlePinchEnded = false;
1465
+ }
1466
+ }
1467
+ onSessionSelectStart() {
1468
+ this.dispatch("TOUCH_START", {
1469
+ touches: [
1470
+ {
1471
+ current: this._touches[0].current.clone()
1472
+ },
1473
+ {
1474
+ current: this._touches[1].current.clone()
1475
+ }
1476
+ ],
1477
+ touchCount: this._touchCount
1478
+ });
1479
+ }
1480
+ onSessionSelectEnd() {
1481
+ this.dispatch("TOUCH_END", {
1482
+ touches: [
1483
+ {
1484
+ current: this._touches[0].current.clone()
1485
+ },
1486
+ {
1487
+ current: this._touches[1].current.clone()
1488
+ }
1489
+ ],
1490
+ touchCount: this._touchCount
1491
+ });
1492
+ }
1493
+ // rotation handler
1494
+ handleRotateStart() {
1495
+ this._handleRotateStarted = true;
1496
+ this._startAngle = this._touches[1].start.clone().sub(this._touches[0].current).angle();
1497
+ }
1498
+ handleRotateMoved() {
1499
+ this._handleRotateMoved = true;
1500
+ const currentAngle = this._touches[1].current.clone().sub(this._touches[0].current).angle();
1501
+ this._angleDelta = currentAngle - this._startAngle;
1502
+ this._lastAngle = this._angleDelta * -1;
1503
+ }
1504
+ handleRotateEnded() {
1505
+ this._handleRotateEnded = true;
1506
+ }
1507
+ // pinch handler
1508
+ handlePinchStart() {
1509
+ this._handlePinchStarted = true;
1510
+ this._scaleDistanceStart = this._touches[1].start.distanceTo(
1511
+ this._touches[0].current
1512
+ );
1513
+ }
1514
+ handlePinchMoved() {
1515
+ this._handlePinchMoved = true;
1516
+ const beforeDistance = this._currentDistance;
1517
+ const distance = this._touches[1].current.distanceTo(
1518
+ this._touches[0].current
1519
+ );
1520
+ this._currentDistance = distance / this._scaleDistanceStart;
1521
+ this._deltaDistance = this._currentDistance - beforeDistance;
1522
+ }
1523
+ handlePinchEnded() {
1524
+ this._handlePinchEnded = true;
1525
+ }
1526
+ };
1527
+ }
1528
+ });
1529
+
1530
+ // src/ar/webxr/controller/WebXRController.ts
1531
+ var import_three11, DIVEWebXRController;
1532
+ var init_WebXRController = __esm({
1533
+ "src/ar/webxr/controller/WebXRController.ts"() {
1534
+ "use strict";
1535
+ import_three11 = require("three");
1536
+ init_WebXRCrosshair();
1537
+ init_WebXRRaycaster();
1538
+ init_WebXROrigin();
1539
+ init_WebXRTouchscreenControls();
1540
+ init_findInterface();
1541
+ DIVEWebXRController = class extends import_three11.Object3D {
1542
+ constructor(session, renderer, scene) {
1543
+ super();
1544
+ this._frameBuffer = null;
1545
+ this._handNodeInitialPosition = new import_three11.Vector3();
1546
+ this._placed = false;
1547
+ // grabbing
1548
+ this._grabbedObject = null;
1549
+ this._arHitPosition = new import_three11.Vector3();
1550
+ this._arHitQuaternion = new import_three11.Quaternion();
1551
+ this._arHitScale = new import_three11.Vector3(1, 1, 1);
1552
+ // grabbing position
1553
+ this._initialObjectPosition = null;
1554
+ this._initialRaycastHit = null;
1555
+ this._deltaRaycastHit = new import_three11.Vector3();
1556
+ // grabbing rotation
1557
+ this._touchQuaterion = new import_three11.Quaternion();
1558
+ // grabbing scale
1559
+ this._touchScale = 1;
1560
+ this._scaleThreshold = 0.1;
1561
+ this._startTouchQuaternion = new import_three11.Quaternion();
1562
+ this._startTouchScale = 1;
1563
+ this._renderer = renderer;
1564
+ this._scene = scene;
1565
+ this._session = session;
1566
+ this._xrRaycaster = new DIVEWebXRRaycaster(session, renderer, scene);
1567
+ this._origin = new DIVEWebXROrigin(this._session, this._renderer, [
1568
+ "plane"
1569
+ ]);
1570
+ this._crosshair = new DIVEWebXRCrosshair();
1571
+ this._crosshair.visible = false;
1572
+ this._xrCamera = this._renderer.xr.getCamera();
1573
+ this._scene.XRRoot.XRHandNode.position.set(0, -0.05, -0.25);
1574
+ this._handNodeInitialPosition = this._scene.XRRoot.XRHandNode.position.clone();
1575
+ this._touchscreenControls = new DIVEWebXRTouchscreenControls(
1576
+ this._session
1577
+ );
1578
+ this._touchscreenControls.Subscribe(
1579
+ "TOUCH_START",
1580
+ () => this.onTouchStart()
1581
+ );
1582
+ this._touchscreenControls.Subscribe(
1583
+ "TOUCH_MOVE",
1584
+ () => this.onTouchMove()
1585
+ );
1586
+ this._touchscreenControls.Subscribe(
1587
+ "TOUCH_END",
1588
+ (p) => this.onTouchEnd(p)
1589
+ );
1590
+ this._touchscreenControls.Subscribe(
1591
+ "ROTATE_START",
1592
+ () => this.onRotateStart()
1593
+ );
1594
+ this._touchscreenControls.Subscribe(
1595
+ "ROTATE_MOVE",
1596
+ (p) => this.onRotateMove(p)
1597
+ );
1598
+ this._touchscreenControls.Subscribe(
1599
+ "PINCH_START",
1600
+ () => this.onPinchStart()
1601
+ );
1602
+ this._touchscreenControls.Subscribe(
1603
+ "PINCH_MOVE",
1604
+ (p) => this.onPinchMove(p)
1605
+ );
1606
+ }
1607
+ Init() {
1608
+ return __async(this, null, function* () {
1609
+ this.prepareScene();
1610
+ yield this.initOrigin();
1611
+ yield this.initRaycaster();
1612
+ return Promise.resolve(this);
1613
+ });
1614
+ }
1615
+ Dispose() {
1616
+ this.restoreScene();
1617
+ this._origin.Dispose();
1618
+ this._xrRaycaster.Dispose();
1619
+ this._placed = false;
1620
+ }
1621
+ Update(frame) {
1622
+ this._frameBuffer = frame;
1623
+ if (!this._placed) {
1624
+ this._xrCamera.updateMatrixWorld();
1625
+ this._scene.XRRoot.XRHandNode.position.copy(
1626
+ this._handNodeInitialPosition.clone().applyMatrix4(this._xrCamera.matrixWorld)
1627
+ );
1628
+ this._scene.XRRoot.XRHandNode.quaternion.setFromRotationMatrix(
1629
+ this._xrCamera.matrixWorld
1630
+ );
1631
+ if (this._origin) {
1632
+ this._origin.Update(frame);
1633
+ }
1634
+ }
1635
+ }
1636
+ // placement
1637
+ initOrigin() {
1638
+ return __async(this, null, function* () {
1639
+ this._origin = yield this._origin.Init();
1640
+ this._origin.originSet.then(() => {
1641
+ this.placeObjects(this._origin.matrix);
1642
+ });
1643
+ });
1644
+ }
1645
+ placeObjects(matrix) {
1646
+ this._scene.XRRoot.XRModelRoot.matrix.copy(matrix);
1647
+ [...this._scene.XRRoot.XRHandNode.children].forEach((child) => {
1648
+ this._scene.XRRoot.XRModelRoot.add(child);
1649
+ });
1650
+ this._placed = true;
1651
+ }
1652
+ // grabbing
1653
+ updateObject() {
1654
+ if (!this._grabbedObject) return;
1655
+ this._grabbedObject.position.copy(this._arHitPosition);
1656
+ this._grabbedObject.quaternion.copy(
1657
+ this._arHitQuaternion.clone().multiply(this._touchQuaterion)
1658
+ );
1659
+ this._grabbedObject.scale.copy(
1660
+ new import_three11.Vector3(
1661
+ this._touchScale,
1662
+ this._touchScale,
1663
+ this._touchScale
1664
+ ).multiply(this._arHitScale)
1665
+ );
1666
+ }
1667
+ onTouchStart() {
1668
+ const sceneHits = this._xrRaycaster.GetSceneIntersections();
1669
+ console.log("sceneHits", sceneHits);
1670
+ if (sceneHits.length === 0) return;
1671
+ if (!sceneHits[0].object) return;
1672
+ const moveable = findInterface(
1673
+ sceneHits[0].object,
1674
+ "isMovable"
1675
+ );
1676
+ if (!moveable) return;
1677
+ this._grabbedObject = moveable;
1678
+ }
1679
+ onTouchMove() {
1680
+ if (!this._frameBuffer) return;
1681
+ if (!this._grabbedObject) return;
1682
+ const intersections = this._xrRaycaster.GetARIntersections(
1683
+ this._frameBuffer
1684
+ );
1685
+ if (intersections.length === 0) {
1686
+ this._crosshair.visible = false;
1687
+ return;
1688
+ }
1689
+ const hit = intersections[0];
1690
+ this._crosshair.visible = true;
1691
+ this._crosshair.matrix.copy(hit.matrix);
1692
+ if (!this._grabbedObject) return;
1693
+ if (!this._initialObjectPosition || !this._initialRaycastHit) {
1694
+ this._initialObjectPosition = this._grabbedObject.position.clone();
1695
+ this._initialRaycastHit = hit.point.clone();
1696
+ }
1697
+ hit.matrix.decompose(
1698
+ this._arHitPosition,
1699
+ this._arHitQuaternion,
1700
+ this._arHitScale
1701
+ );
1702
+ this._deltaRaycastHit.copy(
1703
+ hit.point.clone().sub(this._initialRaycastHit)
1704
+ );
1705
+ this._arHitPosition.copy(
1706
+ this._initialObjectPosition.clone().add(this._deltaRaycastHit)
1707
+ );
1708
+ console.log("arHitPosition", this._arHitPosition);
1709
+ this.updateObject();
1710
+ }
1711
+ onTouchEnd(payload) {
1712
+ if (payload.touchCount === 0) {
1713
+ this._crosshair.visible = false;
1714
+ this._initialObjectPosition = null;
1715
+ this._initialRaycastHit = null;
1716
+ this._grabbedObject = null;
1717
+ }
1718
+ }
1719
+ onRotateStart() {
1720
+ this._startTouchQuaternion = this._touchQuaterion.clone();
1721
+ }
1722
+ onRotateMove(payload) {
1723
+ this._touchQuaterion.setFromAxisAngle(
1724
+ new import_three11.Vector3(0, -1, 0),
1725
+ payload.delta * 3
1726
+ );
1727
+ this._touchQuaterion.multiply(this._startTouchQuaternion);
1728
+ this.updateObject();
1729
+ }
1730
+ onPinchStart() {
1731
+ this._startTouchScale = this._touchScale;
1732
+ }
1733
+ onPinchMove(payload) {
1734
+ this._touchScale = this._startTouchScale * payload.current;
1735
+ this.updateObject();
1736
+ }
1737
+ // prepare & cleanup scene
1738
+ prepareScene() {
1739
+ this._scene.XRRoot.XRModelRoot.matrixAutoUpdate = false;
1740
+ this._scene.add(this._crosshair);
1741
+ const children = [];
1742
+ this._scene.Root.children.forEach((child) => {
1743
+ const clone = child.clone();
1744
+ clone.layers.enableAll();
1745
+ clone.traverse((obj) => {
1746
+ obj.layers.enableAll();
1747
+ if (obj instanceof import_three11.Mesh) {
1748
+ obj.scale.set(0.1, 0.1, 0.1);
1749
+ }
1750
+ });
1751
+ clone.position.set(0, 0, 0);
1752
+ children.push(clone);
1753
+ });
1754
+ this._scene.XRRoot.XRHandNode.add(...children);
1755
+ }
1756
+ restoreScene() {
1757
+ this._scene.remove(this._crosshair);
1758
+ this._scene.XRRoot.XRHandNode.clear();
1759
+ this._scene.XRRoot.XRModelRoot.clear();
1760
+ this._scene.XRRoot.XRModelRoot.matrixAutoUpdate = true;
1761
+ }
1762
+ // raycast
1763
+ initRaycaster() {
1764
+ return __async(this, null, function* () {
1765
+ yield this._xrRaycaster.Init();
1766
+ if (!this._xrRaycaster) {
1767
+ console.error(
1768
+ "Raycaster not initialized successfully. Aborting WebXR..."
1769
+ );
1770
+ this.Dispose();
1771
+ return Promise.reject();
1772
+ }
1773
+ });
1774
+ }
1775
+ };
1776
+ }
1777
+ });
1778
+
1779
+ // src/ar/webxr/WebXR.ts
1780
+ var _DIVEWebXR, DIVEWebXR;
1781
+ var init_WebXR = __esm({
1782
+ "src/ar/webxr/WebXR.ts"() {
1783
+ "use strict";
1784
+ init_Overlay();
1785
+ init_WebXRController();
1786
+ _DIVEWebXR = class _DIVEWebXR {
1787
+ static Launch(renderer, scene, controller) {
1788
+ return __async(this, null, function* () {
1789
+ this._renderer = renderer;
1790
+ this._scene = scene;
1791
+ this._controller = controller;
1792
+ this._cameraPosition = this._controller.object.position.clone();
1793
+ this._cameraTarget = this._controller.target.clone();
1794
+ if (!navigator.xr) {
1795
+ console.error("WebXR not supported");
1796
+ return Promise.reject();
1797
+ }
1798
+ this._renderer.xr.enabled = true;
1799
+ this._scene.InitXR(renderer);
1800
+ if (!_DIVEWebXR._overlay) {
1801
+ const overlay = new Overlay();
1802
+ _DIVEWebXR._overlay = overlay;
1803
+ }
1804
+ _DIVEWebXR._options.domOverlay = { root: _DIVEWebXR._overlay.Element };
1805
+ const session = yield navigator.xr.requestSession(
1806
+ "immersive-ar",
1807
+ this._options
1808
+ );
1809
+ session.addEventListener("end", () => {
1810
+ this._onSessionEnded();
1811
+ });
1812
+ renderer.xr.setReferenceSpaceType(this._referenceSpaceType);
1813
+ yield renderer.xr.setSession(session);
1814
+ _DIVEWebXR._overlay.Element.style.display = "";
1815
+ this._session = session;
1816
+ _DIVEWebXR._overlay.CloseButton.addEventListener(
1817
+ "click",
1818
+ () => this.End()
1819
+ );
1820
+ yield this._onSessionStarted();
1821
+ return Promise.resolve();
1822
+ });
1823
+ }
1824
+ static Update(_time, frame) {
1825
+ if (!this._session) return;
1826
+ if (this._xrController) {
1827
+ this._xrController.Update(frame);
1828
+ }
1829
+ }
1830
+ static End() {
1831
+ if (!this._session) return;
1832
+ this._session.end();
1833
+ }
1834
+ static _onSessionStarted() {
1835
+ return __async(this, null, function* () {
1836
+ if (!this._session) return;
1837
+ this._renderCallbackId = this._renderer.AddPreRenderCallback(
1838
+ (time, frame) => {
1839
+ this.Update(time, frame);
1840
+ }
1841
+ );
1842
+ this._xrController = new DIVEWebXRController(
1843
+ this._session,
1844
+ this._renderer,
1845
+ this._scene
1846
+ );
1847
+ yield this._xrController.Init().catch(() => {
1848
+ this.End();
1849
+ });
1850
+ return Promise.resolve();
1851
+ });
1852
+ }
1853
+ static _onSessionEnded() {
1854
+ if (!this._session) return;
1855
+ if (this._xrController) {
1856
+ this._xrController.Dispose();
1857
+ }
1858
+ if (this._renderCallbackId) {
1859
+ this._renderer.RemovePreRenderCallback(this._renderCallbackId);
1860
+ this._renderCallbackId = null;
1861
+ }
1862
+ this._renderer.xr.enabled = false;
1863
+ const canvasWrapper = this._renderer.domElement.parentElement;
1864
+ if (canvasWrapper) {
1865
+ const { clientWidth, clientHeight } = canvasWrapper;
1866
+ this._renderer.OnResize(clientWidth, clientHeight);
1867
+ this._controller.object.OnResize(clientWidth, clientHeight);
1868
+ }
1869
+ this._controller.object.position.copy(this._cameraPosition);
1870
+ this._controller.target.copy(this._cameraTarget);
1871
+ this._cameraPosition.set(0, 0, 0);
1872
+ this._cameraTarget.set(0, 0, 0);
1873
+ this._scene.DisposeXR();
1874
+ this._session.removeEventListener("end", this._onSessionEnded);
1875
+ _DIVEWebXR._overlay.Element.style.display = "none";
1876
+ this._session = null;
1877
+ }
1878
+ };
1879
+ // render loop members
1880
+ _DIVEWebXR._renderCallbackId = null;
1881
+ // setup members
1882
+ _DIVEWebXR._session = null;
1883
+ _DIVEWebXR._referenceSpaceType = "local";
1884
+ _DIVEWebXR._overlay = null;
1885
+ _DIVEWebXR._options = {
1886
+ requiredFeatures: [
1887
+ "local",
1888
+ "hit-test"
1889
+ ],
1890
+ optionalFeatures: [
1891
+ "light-estimation",
1892
+ "local-floor",
1893
+ "dom-overlay",
1894
+ "depth-sensing"
1895
+ ],
1896
+ depthSensing: {
1897
+ usagePreference: ["gpu-optimized"],
1898
+ dataFormatPreference: []
1899
+ },
1900
+ domOverlay: { root: {} }
1901
+ };
1902
+ _DIVEWebXR._xrController = null;
1903
+ DIVEWebXR = _DIVEWebXR;
1904
+ }
1905
+ });
1906
+
1907
+ // src/ar/AR.ts
1908
+ var AR_exports = {};
1909
+ __export(AR_exports, {
1910
+ DIVEAR: () => DIVEAR
1911
+ });
1912
+ var DIVEAR;
1913
+ var init_AR = __esm({
1914
+ "src/ar/AR.ts"() {
1915
+ "use strict";
1916
+ init_Info();
1917
+ init_ARQuickLook();
1918
+ init_WebXR();
1919
+ DIVEAR = class {
1920
+ constructor(renderer, scene, controller) {
1921
+ this.arPlacement = "floor";
1922
+ this.arScale = "auto";
1923
+ this._renderer = renderer;
1924
+ this._scene = scene;
1925
+ this._controller = controller;
1926
+ }
1927
+ Launch() {
1928
+ return __async(this, null, function* () {
1929
+ const system = DIVEInfo.GetSystem();
1930
+ if (system === "iOS") {
1931
+ const support = DIVEInfo.GetSupportsARQuickLook();
1932
+ if (!support) {
1933
+ console.log("ARQuickLook not supported");
1934
+ return Promise.reject();
1935
+ }
1936
+ console.log("Launching AR on iOS");
1937
+ yield DIVEARQuickLook.Launch(this._scene);
1938
+ return Promise.resolve();
1939
+ }
1940
+ if (system === "Android") {
1941
+ this.openSceneViewer();
1942
+ return;
1943
+ const support = yield DIVEInfo.GetSupportsWebXR();
1944
+ if (!support) {
1945
+ console.log(
1946
+ "WebXR not supported. Reason: " + WebXRUnsupportedReason[DIVEInfo.GetWebXRUnsupportedReason()]
1947
+ );
1948
+ return Promise.reject();
1949
+ }
1950
+ console.log("Launching AR on Android");
1951
+ yield DIVEWebXR.Launch(
1952
+ this._renderer,
1953
+ this._scene,
1954
+ this._controller
1955
+ );
1956
+ return Promise.resolve();
1957
+ }
1958
+ console.log(
1959
+ "AR not supported. Not a mobile system. (System is " + system + ")"
1960
+ );
1961
+ });
1962
+ }
1963
+ openSceneViewer() {
1964
+ const src = this.createSceneViewerSrc();
1965
+ const anchor = document.createElement("a");
1966
+ const noArViewerSigil = "#model-viewer-no-ar-fallback";
1967
+ const location = self.location.toString();
1968
+ const locationUrl = new URL(location);
1969
+ const modelUrl = new URL(src, location);
1970
+ if (modelUrl.hash) modelUrl.hash = "";
1971
+ const params = new URLSearchParams(modelUrl.search);
1972
+ locationUrl.hash = noArViewerSigil;
1973
+ params.set("mode", "ar_preferred");
1974
+ if (!params.has("disable_occlusion")) {
1975
+ params.set("disable_occlusion", "true");
1976
+ }
1977
+ if (this.arScale === "fixed") {
1978
+ params.set("resizable", "false");
1979
+ }
1980
+ if (this.arPlacement === "wall") {
1981
+ params.set("enable_vertical_placement", "true");
1982
+ }
1983
+ if (params.has("sound")) {
1984
+ const soundUrl = new URL(params.get("sound"), location);
1985
+ params.set("sound", soundUrl.toString());
1986
+ }
1987
+ if (params.has("link")) {
1988
+ const linkUrl = new URL(params.get("link"), location);
1989
+ params.set("link", linkUrl.toString());
1990
+ }
1991
+ console.log("modelUrl.toString()", modelUrl.toString());
1992
+ console.log(
1993
+ "encodeURIComponent(modelUrl.toString())",
1994
+ encodeURIComponent(modelUrl.toString())
1995
+ );
1996
+ const intent = `intent://arvr.google.com/scene-viewer/1.2?${params.toString() + "&file=" + modelUrl.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(
1997
+ locationUrl.toString()
1998
+ )};end;`;
1999
+ console.log({ intent });
2000
+ const undoHashChange = () => {
2001
+ if (self.location.hash === noArViewerSigil) {
2002
+ self.history.back();
2003
+ console.warn(
2004
+ "Error while trying to present in AR with Scene Viewer"
2005
+ );
2006
+ console.warn("Falling back to next ar-mode");
2007
+ }
2008
+ };
2009
+ self.addEventListener("hashchange", undoHashChange, { once: true });
2010
+ anchor.setAttribute("href", intent);
2011
+ console.log("Attempting to present in AR with Scene Viewer...");
2012
+ anchor.click();
2013
+ }
2014
+ createSceneViewerSrc() {
2015
+ let uri = null;
2016
+ this._scene.traverse((object) => {
2017
+ if (uri) return;
2018
+ if (object.userData.uri) {
2019
+ uri = object.userData.uri;
2020
+ }
2021
+ });
2022
+ if (!uri) {
2023
+ throw new Error("No model found in scene");
2024
+ }
2025
+ return uri;
2026
+ }
2027
+ };
2028
+ }
2029
+ });
2030
+
639
2031
  // src/dive.ts
640
2032
  var dive_exports = {};
641
2033
  __export(dive_exports, {
@@ -686,8 +2078,8 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
686
2078
  }
687
2079
  // Starts the renderer with the given scene and camera.
688
2080
  StartRenderer(scene, cam) {
689
- this.setAnimationLoop(() => {
690
- this.internal_render(scene, cam);
2081
+ this.setAnimationLoop((time, frame) => {
2082
+ this.internal_render(scene, cam, time, frame);
691
2083
  });
692
2084
  this.running = true;
693
2085
  }
@@ -761,24 +2153,24 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
761
2153
  * @param scene Scene to render.
762
2154
  * @param cam Camera to render with.
763
2155
  */
764
- internal_render(scene, cam) {
2156
+ internal_render(scene, cam, time, frame) {
765
2157
  if ((this.paused || !this.running) && !this.force) return;
766
2158
  this.preRenderCallbacks.forEach((callback) => {
767
- callback();
2159
+ callback(time, frame);
768
2160
  });
769
2161
  this.render(scene, cam);
770
2162
  this.postRenderCallbacks.forEach((callback) => {
771
- callback();
2163
+ callback(time, frame);
772
2164
  });
773
2165
  this.force = false;
774
2166
  }
775
2167
  };
776
2168
 
777
2169
  // src/scene/Scene.ts
778
- var import_three14 = require("three");
2170
+ var import_three23 = require("three");
779
2171
 
780
2172
  // src/scene/root/Root.ts
781
- var import_three11 = require("three");
2173
+ var import_three18 = require("three");
782
2174
 
783
2175
  // src/light/AmbientLight.ts
784
2176
  var import_three2 = require("three");
@@ -805,7 +2197,7 @@ var DIVEAmbientLight = class extends import_three2.Object3D {
805
2197
  };
806
2198
 
807
2199
  // src/light/PointLight.ts
808
- var import_three5 = require("three");
2200
+ var import_three12 = require("three");
809
2201
 
810
2202
  // src/com/Communication.ts
811
2203
  var import_MathUtils = require("three/src/math/MathUtils");
@@ -823,6 +2215,7 @@ var _DIVECommunication = class _DIVECommunication {
823
2215
  this.toolbox = toolbox;
824
2216
  this._mediaGenerator = null;
825
2217
  this._io = null;
2218
+ this._ar = null;
826
2219
  _DIVECommunication.__instances.push(this);
827
2220
  }
828
2221
  static get(id) {
@@ -857,6 +2250,13 @@ var _DIVECommunication = class _DIVECommunication {
857
2250
  }
858
2251
  return this._io;
859
2252
  }
2253
+ get ar() {
2254
+ if (!this._ar) {
2255
+ const DIVEAR2 = (init_AR(), __toCommonJS(AR_exports)).DIVEAR;
2256
+ this._ar = new DIVEAR2(this.renderer, this.scene, this.controller);
2257
+ }
2258
+ return this._ar;
2259
+ }
860
2260
  DestroyInstance() {
861
2261
  const existingIndex = _DIVECommunication.__instances.findIndex(
862
2262
  (entry) => entry.id === this.id
@@ -1024,6 +2424,11 @@ var _DIVECommunication = class _DIVECommunication {
1024
2424
  );
1025
2425
  break;
1026
2426
  }
2427
+ case "LAUNCH_AR": {
2428
+ this.ar.Launch();
2429
+ returnValue = true;
2430
+ break;
2431
+ }
1027
2432
  default: {
1028
2433
  console.warn(
1029
2434
  `DIVECommunication.PerformAction: has been executed with unknown Action type ${action}`
@@ -1307,7 +2712,7 @@ var DIVECommunication = _DIVECommunication;
1307
2712
 
1308
2713
  // src/light/PointLight.ts
1309
2714
  init_VisibilityLayerMask();
1310
- var DIVEPointLight = class extends import_three5.Object3D {
2715
+ var DIVEPointLight = class extends import_three12.Object3D {
1311
2716
  constructor() {
1312
2717
  super();
1313
2718
  this.isDIVELight = true;
@@ -1316,25 +2721,25 @@ var DIVEPointLight = class extends import_three5.Object3D {
1316
2721
  this.isSelectable = true;
1317
2722
  this.gizmo = null;
1318
2723
  this.name = "DIVEPointLight";
1319
- this.light = new import_three5.PointLight(16777215, 1);
2724
+ this.light = new import_three12.PointLight(16777215, 1);
1320
2725
  this.light.layers.mask = PRODUCT_LAYER_MASK;
1321
2726
  this.light.castShadow = true;
1322
2727
  this.light.shadow.mapSize.width = 512;
1323
2728
  this.light.shadow.mapSize.height = 512;
1324
2729
  this.add(this.light);
1325
2730
  const geoSize = 0.1;
1326
- const geometry = new import_three5.SphereGeometry(
2731
+ const geometry = new import_three12.SphereGeometry(
1327
2732
  geoSize,
1328
2733
  geoSize * 320,
1329
2734
  geoSize * 320
1330
2735
  );
1331
- const material = new import_three5.MeshBasicMaterial({
2736
+ const material = new import_three12.MeshBasicMaterial({
1332
2737
  color: this.light.color,
1333
2738
  transparent: true,
1334
2739
  opacity: 0.8,
1335
- side: import_three5.FrontSide
2740
+ side: import_three12.FrontSide
1336
2741
  });
1337
- this.mesh = new import_three5.Mesh(geometry, material);
2742
+ this.mesh = new import_three12.Mesh(geometry, material);
1338
2743
  this.mesh.layers.mask = UI_LAYER_MASK;
1339
2744
  this.add(this.mesh);
1340
2745
  }
@@ -1374,18 +2779,18 @@ var DIVEPointLight = class extends import_three5.Object3D {
1374
2779
 
1375
2780
  // src/light/SceneLight.ts
1376
2781
  init_VisibilityLayerMask();
1377
- var import_three6 = require("three");
1378
- var DIVESceneLight = class extends import_three6.Object3D {
2782
+ var import_three13 = require("three");
2783
+ var DIVESceneLight = class extends import_three13.Object3D {
1379
2784
  constructor() {
1380
2785
  super();
1381
2786
  this.isDIVELight = true;
1382
2787
  this.isDIVESceneLight = true;
1383
2788
  this.name = "DIVESceneLight";
1384
- this._hemiLight = new import_three6.HemisphereLight(16777215, 16777215, 2);
2789
+ this._hemiLight = new import_three13.HemisphereLight(16777215, 16777215, 2);
1385
2790
  this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
1386
2791
  this._hemiLight.position.set(0, 50, 0);
1387
2792
  this.add(this._hemiLight);
1388
- this._dirLight = new import_three6.DirectionalLight(16777215, 3);
2793
+ this._dirLight = new import_three13.DirectionalLight(16777215, 3);
1389
2794
  this._dirLight.layers.mask = PRODUCT_LAYER_MASK;
1390
2795
  this._dirLight.position.set(1, 1.75, 1);
1391
2796
  this._dirLight.position.multiplyScalar(30);
@@ -1415,7 +2820,7 @@ var DIVESceneLight = class extends import_three6.Object3D {
1415
2820
  };
1416
2821
 
1417
2822
  // src/model/Model.ts
1418
- var import_three8 = require("three");
2823
+ var import_three15 = require("three");
1419
2824
  init_VisibilityLayerMask();
1420
2825
 
1421
2826
  // src/helper/findSceneRecursive/findSceneRecursive.ts
@@ -1427,9 +2832,9 @@ var findSceneRecursive = (object) => {
1427
2832
  };
1428
2833
 
1429
2834
  // src/node/Node.ts
1430
- var import_three7 = require("three");
2835
+ var import_three14 = require("three");
1431
2836
  init_VisibilityLayerMask();
1432
- var DIVENode = class extends import_three7.Object3D {
2837
+ var DIVENode = class extends import_three14.Object3D {
1433
2838
  constructor() {
1434
2839
  super();
1435
2840
  this.isDIVENode = true;
@@ -1437,15 +2842,15 @@ var DIVENode = class extends import_three7.Object3D {
1437
2842
  this.isMovable = true;
1438
2843
  this.gizmo = null;
1439
2844
  this.layers.mask = PRODUCT_LAYER_MASK;
1440
- this._positionWorldBuffer = new import_three7.Vector3();
1441
- this._boundingBox = new import_three7.Box3();
2845
+ this._positionWorldBuffer = new import_three14.Vector3();
2846
+ this._boundingBox = new import_three14.Box3();
1442
2847
  }
1443
2848
  SetPosition(position) {
1444
2849
  if (!this.parent) {
1445
2850
  this.position.set(position.x, position.y, position.z);
1446
2851
  return;
1447
2852
  }
1448
- const newPosition = new import_three7.Vector3(position.x, position.y, position.z);
2853
+ const newPosition = new import_three14.Vector3(position.x, position.y, position.z);
1449
2854
  this.position.copy(this.parent.worldToLocal(newPosition));
1450
2855
  if ("isDIVEGroup" in this.parent) {
1451
2856
  this.parent.UpdateLineTo(this);
@@ -1533,7 +2938,7 @@ var DIVEModel = class extends DIVENode {
1533
2938
  }
1534
2939
  SetMaterial(material) {
1535
2940
  if (!this._material) {
1536
- this._material = new import_three8.MeshStandardMaterial();
2941
+ this._material = new import_three15.MeshStandardMaterial();
1537
2942
  }
1538
2943
  if (material.vertexColors !== void 0) {
1539
2944
  this._material.vertexColors = material.vertexColors;
@@ -1595,10 +3000,10 @@ var DIVEModel = class extends DIVENode {
1595
3000
  }
1596
3001
  const bottomY = this._boundingBox.min.y * this.scale.y;
1597
3002
  const bbBottomCenter = this.localToWorld(
1598
- this._boundingBox.getCenter(new import_three8.Vector3()).multiply(this.scale)
3003
+ this._boundingBox.getCenter(new import_three15.Vector3()).multiply(this.scale)
1599
3004
  );
1600
3005
  bbBottomCenter.y = bottomY + this.position.y;
1601
- const raycaster = new import_three8.Raycaster(bbBottomCenter, new import_three8.Vector3(0, -1, 0));
3006
+ const raycaster = new import_three15.Raycaster(bbBottomCenter, new import_three15.Vector3(0, -1, 0));
1602
3007
  raycaster.layers.mask = PRODUCT_LAYER_MASK;
1603
3008
  const intersections = raycaster.intersectObjects(
1604
3009
  findSceneRecursive(this).Root.children,
@@ -1610,7 +3015,7 @@ var DIVEModel = class extends DIVENode {
1610
3015
  const meshBB = mesh.geometry.boundingBox;
1611
3016
  const worldPos = mesh.localToWorld(meshBB.max.clone());
1612
3017
  const oldPos = this.position.clone();
1613
- const newPos = this.position.clone().setY(worldPos.y).sub(new import_three8.Vector3(0, bottomY, 0));
3018
+ const newPos = this.position.clone().setY(worldPos.y).sub(new import_three15.Vector3(0, bottomY, 0));
1614
3019
  this.position.copy(newPos);
1615
3020
  if (this.position.y === oldPos.y) return;
1616
3021
  this.onMove();
@@ -1619,13 +3024,13 @@ var DIVEModel = class extends DIVENode {
1619
3024
  };
1620
3025
 
1621
3026
  // src/loadingmanager/LoadingManager.ts
1622
- var import_Addons2 = require("three/examples/jsm/Addons.js");
3027
+ var import_Addons = require("three/examples/jsm/Addons.js");
1623
3028
  var DIVELoadingManager = class {
1624
3029
  // ... maybe extend with other loaders later
1625
3030
  constructor() {
1626
3031
  this.progress = /* @__PURE__ */ new Map();
1627
- this.gltfloader = new import_Addons2.GLTFLoader();
1628
- this.dracoloader = new import_Addons2.DRACOLoader();
3032
+ this.gltfloader = new import_Addons.GLTFLoader();
3033
+ this.dracoloader = new import_Addons.DRACOLoader();
1629
3034
  this.dracoloader.setDecoderPath(
1630
3035
  "https://www.gstatic.com/draco/v1/decoders/"
1631
3036
  );
@@ -1653,17 +3058,17 @@ var DIVELoadingManager = class {
1653
3058
  };
1654
3059
 
1655
3060
  // src/primitive/Primitive.ts
1656
- var import_three9 = require("three");
3061
+ var import_three16 = require("three");
1657
3062
  init_VisibilityLayerMask();
1658
3063
  var DIVEPrimitive = class extends DIVENode {
1659
3064
  constructor() {
1660
3065
  super();
1661
3066
  this.isDIVEPrimitive = true;
1662
- this._mesh = new import_three9.Mesh();
3067
+ this._mesh = new import_three16.Mesh();
1663
3068
  this._mesh.layers.mask = PRODUCT_LAYER_MASK;
1664
3069
  this._mesh.castShadow = true;
1665
3070
  this._mesh.receiveShadow = true;
1666
- this._mesh.material = new import_three9.MeshStandardMaterial();
3071
+ this._mesh.material = new import_three16.MeshStandardMaterial();
1667
3072
  this.add(this._mesh);
1668
3073
  }
1669
3074
  SetGeometry(geometry) {
@@ -1678,7 +3083,7 @@ var DIVEPrimitive = class extends DIVENode {
1678
3083
  primitiveMaterial.vertexColors = material.vertexColors;
1679
3084
  }
1680
3085
  if (material.color !== void 0) {
1681
- primitiveMaterial.color = new import_three9.Color(material.color);
3086
+ primitiveMaterial.color = new import_three16.Color(material.color);
1682
3087
  }
1683
3088
  if (material.map !== void 0) {
1684
3089
  primitiveMaterial.map = material.map;
@@ -1732,10 +3137,10 @@ var DIVEPrimitive = class extends DIVENode {
1732
3137
  }
1733
3138
  const bottomY = this._boundingBox.min.y * this.scale.y;
1734
3139
  const bbBottomCenter = this.localToWorld(
1735
- this._boundingBox.getCenter(new import_three9.Vector3()).multiply(this.scale)
3140
+ this._boundingBox.getCenter(new import_three16.Vector3()).multiply(this.scale)
1736
3141
  );
1737
3142
  bbBottomCenter.y = bottomY + this.position.y;
1738
- const raycaster = new import_three9.Raycaster(bbBottomCenter, new import_three9.Vector3(0, -1, 0));
3143
+ const raycaster = new import_three16.Raycaster(bbBottomCenter, new import_three16.Vector3(0, -1, 0));
1739
3144
  raycaster.layers.mask = PRODUCT_LAYER_MASK;
1740
3145
  const intersections = raycaster.intersectObjects(
1741
3146
  findSceneRecursive(this).Root.children,
@@ -1747,7 +3152,7 @@ var DIVEPrimitive = class extends DIVENode {
1747
3152
  const meshBB = mesh.geometry.boundingBox;
1748
3153
  const worldPos = mesh.localToWorld(meshBB.max.clone());
1749
3154
  const oldPos = this.position.clone();
1750
- const newPos = this.position.clone().setY(worldPos.y).sub(new import_three9.Vector3(0, bottomY, 0));
3155
+ const newPos = this.position.clone().setY(worldPos.y).sub(new import_three16.Vector3(0, bottomY, 0));
1751
3156
  this.position.copy(newPos);
1752
3157
  if (this.position.y === oldPos.y) return;
1753
3158
  this.onMove();
@@ -1782,7 +3187,7 @@ var DIVEPrimitive = class extends DIVENode {
1782
3187
  }
1783
3188
  }
1784
3189
  createCylinderGeometry(geometry) {
1785
- const geo = new import_three9.CylinderGeometry(
3190
+ const geo = new import_three16.CylinderGeometry(
1786
3191
  geometry.width / 2,
1787
3192
  geometry.width / 2,
1788
3193
  geometry.height,
@@ -1792,7 +3197,7 @@ var DIVEPrimitive = class extends DIVENode {
1792
3197
  return geo;
1793
3198
  }
1794
3199
  createSphereGeometry(geometry) {
1795
- const geo = new import_three9.SphereGeometry(geometry.width / 2, 256, 256);
3200
+ const geo = new import_three16.SphereGeometry(geometry.width / 2, 256, 256);
1796
3201
  return geo;
1797
3202
  }
1798
3203
  createPyramidGeometry(geometry) {
@@ -1837,19 +3242,19 @@ var DIVEPrimitive = class extends DIVENode {
1837
3242
  4,
1838
3243
  0
1839
3244
  ]);
1840
- const geometryBuffer = new import_three9.BufferGeometry();
3245
+ const geometryBuffer = new import_three16.BufferGeometry();
1841
3246
  geometryBuffer.setAttribute(
1842
3247
  "position",
1843
- new import_three9.BufferAttribute(vertices, 3)
3248
+ new import_three16.BufferAttribute(vertices, 3)
1844
3249
  );
1845
- geometryBuffer.setIndex(new import_three9.BufferAttribute(indices, 1));
3250
+ geometryBuffer.setIndex(new import_three16.BufferAttribute(indices, 1));
1846
3251
  geometryBuffer.computeVertexNormals();
1847
3252
  geometryBuffer.computeBoundingBox();
1848
3253
  geometryBuffer.computeBoundingSphere();
1849
3254
  return geometryBuffer;
1850
3255
  }
1851
3256
  createBoxGeometry(geometry) {
1852
- const geo = new import_three9.BoxGeometry(
3257
+ const geo = new import_three16.BoxGeometry(
1853
3258
  geometry.width,
1854
3259
  geometry.height,
1855
3260
  geometry.depth
@@ -1858,12 +3263,12 @@ var DIVEPrimitive = class extends DIVENode {
1858
3263
  return geo;
1859
3264
  }
1860
3265
  createConeGeometry(geometry) {
1861
- const geo = new import_three9.ConeGeometry(geometry.width / 2, geometry.height, 256);
3266
+ const geo = new import_three16.ConeGeometry(geometry.width / 2, geometry.height, 256);
1862
3267
  geo.translate(0, geometry.height / 2, 0);
1863
3268
  return geo;
1864
3269
  }
1865
3270
  createWallGeometry(geometry) {
1866
- const geo = new import_three9.BoxGeometry(
3271
+ const geo = new import_three16.BoxGeometry(
1867
3272
  geometry.width,
1868
3273
  geometry.height,
1869
3274
  geometry.depth || 0.05,
@@ -1873,7 +3278,7 @@ var DIVEPrimitive = class extends DIVENode {
1873
3278
  return geo;
1874
3279
  }
1875
3280
  createPlaneGeometry(geometry) {
1876
- const geo = new import_three9.BoxGeometry(
3281
+ const geo = new import_three16.BoxGeometry(
1877
3282
  geometry.width,
1878
3283
  geometry.height,
1879
3284
  geometry.depth
@@ -1884,7 +3289,7 @@ var DIVEPrimitive = class extends DIVENode {
1884
3289
  };
1885
3290
 
1886
3291
  // src/group/Group.ts
1887
- var import_three10 = require("three");
3292
+ var import_three17 = require("three");
1888
3293
  var DIVEGroup = class extends DIVENode {
1889
3294
  // lines to children
1890
3295
  constructor() {
@@ -1946,13 +3351,13 @@ var DIVEGroup = class extends DIVENode {
1946
3351
  * Adds a line to this grouo as last child.
1947
3352
  */
1948
3353
  createLine() {
1949
- const geo = new import_three10.BufferGeometry();
1950
- const mat = new import_three10.LineDashedMaterial({
3354
+ const geo = new import_three17.BufferGeometry();
3355
+ const mat = new import_three17.LineDashedMaterial({
1951
3356
  color: 6710886,
1952
3357
  dashSize: 0.05,
1953
3358
  gapSize: 0.025
1954
3359
  });
1955
- const line = new import_three10.Line(geo, mat);
3360
+ const line = new import_three17.Line(geo, mat);
1956
3361
  line.visible = false;
1957
3362
  return line;
1958
3363
  }
@@ -1961,7 +3366,7 @@ var DIVEGroup = class extends DIVENode {
1961
3366
  */
1962
3367
  updateLineTo(line, object) {
1963
3368
  line.geometry.setFromPoints([
1964
- new import_three10.Vector3(0, 0, 0),
3369
+ new import_three17.Vector3(0, 0, 0),
1965
3370
  object.position.clone()
1966
3371
  ]);
1967
3372
  line.computeLineDistances();
@@ -2016,7 +3421,7 @@ var DIVEGroup = class extends DIVENode {
2016
3421
  };
2017
3422
 
2018
3423
  // src/scene/root/Root.ts
2019
- var DIVERoot = class extends import_three11.Object3D {
3424
+ var DIVERoot = class extends import_three18.Object3D {
2020
3425
  constructor() {
2021
3426
  super();
2022
3427
  this.isDIVERoot = true;
@@ -2024,7 +3429,7 @@ var DIVERoot = class extends import_three11.Object3D {
2024
3429
  this.loadingManager = new DIVELoadingManager();
2025
3430
  }
2026
3431
  ComputeSceneBB() {
2027
- const bb = new import_three11.Box3();
3432
+ const bb = new import_three18.Box3();
2028
3433
  this.traverse((object) => {
2029
3434
  if ("isObject3D" in object) {
2030
3435
  bb.expandByObject(object);
@@ -2188,7 +3593,7 @@ var DIVERoot = class extends import_three11.Object3D {
2188
3593
  );
2189
3594
  if (light.color !== void 0 && light.color !== null)
2190
3595
  sceneObject.SetColor(
2191
- new import_three11.Color(light.color)
3596
+ new import_three18.Color(light.color)
2192
3597
  );
2193
3598
  if (light.visible !== void 0 && light.visible !== null)
2194
3599
  sceneObject.visible = light.visible;
@@ -2201,6 +3606,7 @@ var DIVERoot = class extends import_three11.Object3D {
2201
3606
  const created = new DIVEModel();
2202
3607
  sceneObject = created;
2203
3608
  sceneObject.userData.id = model.id;
3609
+ sceneObject.userData.uri = model.uri;
2204
3610
  this.add(sceneObject);
2205
3611
  }
2206
3612
  if (model.uri !== void 0) {
@@ -2359,12 +3765,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
2359
3765
 
2360
3766
  // src/grid/Grid.ts
2361
3767
  init_VisibilityLayerMask();
2362
- var import_three12 = require("three");
2363
- var DIVEGrid = class extends import_three12.Object3D {
3768
+ var import_three19 = require("three");
3769
+ var DIVEGrid = class extends import_three19.Object3D {
2364
3770
  constructor() {
2365
3771
  super();
2366
3772
  this.name = "Grid";
2367
- const grid = new import_three12.GridHelper(
3773
+ const grid = new import_three19.GridHelper(
2368
3774
  100,
2369
3775
  100,
2370
3776
  GRID_CENTER_LINE_COLOR,
@@ -2380,14 +3786,14 @@ var DIVEGrid = class extends import_three12.Object3D {
2380
3786
  };
2381
3787
 
2382
3788
  // src/primitive/floor/Floor.ts
2383
- var import_three13 = require("three");
3789
+ var import_three20 = require("three");
2384
3790
  init_VisibilityLayerMask();
2385
- var DIVEFloor = class extends import_three13.Mesh {
3791
+ var DIVEFloor = class extends import_three20.Mesh {
2386
3792
  constructor() {
2387
3793
  super(
2388
- new import_three13.PlaneGeometry(1e4, 1e4),
2389
- new import_three13.MeshStandardMaterial({
2390
- color: new import_three13.Color(150 / 255, 150 / 255, 150 / 255)
3794
+ new import_three20.PlaneGeometry(1e4, 1e4),
3795
+ new import_three20.MeshStandardMaterial({
3796
+ color: new import_three20.Color(150 / 255, 150 / 255, 150 / 255)
2391
3797
  })
2392
3798
  );
2393
3799
  this.isFloor = true;
@@ -2400,33 +3806,148 @@ var DIVEFloor = class extends import_three13.Mesh {
2400
3806
  this.visible = visible;
2401
3807
  }
2402
3808
  SetColor(color) {
2403
- this.material.color = new import_three13.Color(color);
3809
+ this.material.color = new import_three20.Color(color);
3810
+ }
3811
+ };
3812
+
3813
+ // src/scene/xrroot/XRRoot.ts
3814
+ var import_three22 = require("three");
3815
+
3816
+ // src/scene/xrroot/xrlightroot/XRLightRoot.ts
3817
+ var import_XREstimatedLight = require("three/examples/jsm/webxr/XREstimatedLight");
3818
+ var import_three21 = require("three");
3819
+ init_VisibilityLayerMask();
3820
+ var DIVEXRLightRoot = class extends import_three21.Object3D {
3821
+ constructor(scene) {
3822
+ super();
3823
+ this.name = "XRLightRoot";
3824
+ this._scene = scene;
3825
+ this._xrLight = null;
3826
+ this._lightRoot = new DIVERoot();
3827
+ this._lightRoot.UpdateSceneObject({
3828
+ id: "XRSceneLight",
3829
+ entityType: "light",
3830
+ name: "XRSceneLight",
3831
+ type: "scene",
3832
+ color: 16777215,
3833
+ intensity: 1,
3834
+ enabled: true,
3835
+ visible: true
3836
+ });
3837
+ this.add(this._lightRoot);
3838
+ }
3839
+ InitLightEstimation(renderer) {
3840
+ if (!this._xrLight) {
3841
+ this._xrLight = new import_XREstimatedLight.XREstimatedLight(renderer, true);
3842
+ this._xrLight.layers.mask = PRODUCT_LAYER_MASK;
3843
+ this.add(this._xrLight);
3844
+ }
3845
+ this._xrLight.addEventListener("estimationstart", () => {
3846
+ this.onEstimationStart();
3847
+ });
3848
+ this._xrLight.addEventListener("estimationend", () => {
3849
+ this.onEstimationEnd();
3850
+ });
3851
+ }
3852
+ DisposeLightEstimation() {
3853
+ if (!this._xrLight) return;
3854
+ this._xrLight.removeEventListener("estimationstart", () => {
3855
+ this.onEstimationStart();
3856
+ });
3857
+ this._xrLight.removeEventListener("estimationend", () => {
3858
+ this.onEstimationEnd();
3859
+ });
3860
+ }
3861
+ onEstimationStart() {
3862
+ this._lightRoot.visible = false;
3863
+ if (!this._xrLight) return;
3864
+ if (this._xrLight.environment) {
3865
+ this._scene.environment = this._xrLight.environment;
3866
+ }
3867
+ }
3868
+ onEstimationEnd() {
3869
+ this._lightRoot.visible = true;
3870
+ this._scene.environment = null;
3871
+ if (!this._xrLight) return;
3872
+ }
3873
+ };
3874
+
3875
+ // src/scene/xrroot/XRRoot.ts
3876
+ var DIVEXRRoot = class extends import_three22.Object3D {
3877
+ get XRModelRoot() {
3878
+ return this._xrModelRoot;
3879
+ }
3880
+ get XRLightRoot() {
3881
+ return this._xrLightRoot;
3882
+ }
3883
+ get XRHandNode() {
3884
+ return this._xrHandNode;
3885
+ }
3886
+ constructor(scene) {
3887
+ super();
3888
+ this.name = "XRRoot";
3889
+ this._xrModelRoot = new DIVERoot();
3890
+ this._xrModelRoot.name = "XRModelRoot";
3891
+ this.add(this._xrModelRoot);
3892
+ this._xrShadowPlane = new import_three22.Mesh(
3893
+ new import_three22.PlaneGeometry(100, 100),
3894
+ new import_three22.ShadowMaterial({ opacity: 1, transparent: true })
3895
+ );
3896
+ this._xrModelRoot.add(this._xrShadowPlane);
3897
+ this._xrLightRoot = new DIVEXRLightRoot(scene);
3898
+ this._xrLightRoot.name = "XRLightRoot";
3899
+ this.add(this._xrLightRoot);
3900
+ this._xrHandNode = new import_three22.Object3D();
3901
+ this._xrHandNode.name = "XRHandNode";
3902
+ this.add(this._xrHandNode);
3903
+ }
3904
+ InitLightEstimation(renderer) {
3905
+ this._xrLightRoot.InitLightEstimation(renderer);
3906
+ }
3907
+ DisposeLightEstimation() {
3908
+ this._xrLightRoot.DisposeLightEstimation();
2404
3909
  }
2405
3910
  };
2406
3911
 
2407
3912
  // src/scene/Scene.ts
2408
- var DIVEScene = class extends import_three14.Scene {
3913
+ var DIVEScene = class extends import_three23.Scene {
2409
3914
  get Root() {
2410
- return this.root;
3915
+ return this._root;
3916
+ }
3917
+ get XRRoot() {
3918
+ return this._xrRoot;
2411
3919
  }
2412
3920
  get Floor() {
2413
- return this.floor;
3921
+ return this._floor;
2414
3922
  }
2415
3923
  get Grid() {
2416
- return this.grid;
3924
+ return this._grid;
2417
3925
  }
2418
3926
  constructor() {
2419
3927
  super();
2420
- this.background = new import_three14.Color(16777215);
2421
- this.root = new DIVERoot();
2422
- this.add(this.root);
2423
- this.floor = new DIVEFloor();
2424
- this.add(this.floor);
2425
- this.grid = new DIVEGrid();
2426
- this.add(this.grid);
3928
+ this.background = new import_three23.Color(16777215);
3929
+ this._root = new DIVERoot();
3930
+ this.add(this._root);
3931
+ this._floor = new DIVEFloor();
3932
+ this.add(this._floor);
3933
+ this._grid = new DIVEGrid();
3934
+ this.add(this._grid);
3935
+ this._xrRoot = new DIVEXRRoot(this);
3936
+ this._xrRoot.visible = false;
3937
+ this.add(this._xrRoot);
3938
+ }
3939
+ InitXR(renderer) {
3940
+ this._root.visible = false;
3941
+ this._xrRoot.visible = true;
3942
+ this._xrRoot.InitLightEstimation(renderer);
3943
+ }
3944
+ DisposeXR() {
3945
+ this._root.visible = true;
3946
+ this._xrRoot.visible = false;
3947
+ this._xrRoot.DisposeLightEstimation();
2427
3948
  }
2428
3949
  SetBackground(color) {
2429
- this.background = new import_three14.Color(color);
3950
+ this.background = new import_three23.Color(color);
2430
3951
  }
2431
3952
  ComputeSceneBB() {
2432
3953
  return this.Root.ComputeSceneBB();
@@ -2453,7 +3974,7 @@ init_PerspectiveCamera();
2453
3974
 
2454
3975
  // src/controls/OrbitControls.ts
2455
3976
  var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
2456
- var import_three15 = require("three");
3977
+ var import_three24 = require("three");
2457
3978
  var import_tween = require("@tweenjs/tween.js");
2458
3979
  var DIVEOrbitControlsDefaultSettings = {
2459
3980
  enableDamping: true,
@@ -2495,8 +4016,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
2495
4016
  this.dispose();
2496
4017
  }
2497
4018
  ComputeEncompassingView(bb) {
2498
- const center = bb.getCenter(new import_three15.Vector3());
2499
- const size = bb.getSize(new import_three15.Vector3());
4019
+ const center = bb.getCenter(new import_three24.Vector3());
4020
+ const size = bb.getSize(new import_three24.Vector3());
2500
4021
  const distance = Math.max(size.x, size.y, size.z) * 1.25;
2501
4022
  const direction = this.object.position.clone().normalize();
2502
4023
  return {
@@ -2507,7 +4028,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
2507
4028
  ZoomIn(by) {
2508
4029
  const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
2509
4030
  const { minDistance, maxDistance } = this;
2510
- this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(
4031
+ this.minDistance = this.maxDistance = import_three24.MathUtils.clamp(
2511
4032
  this.getDistance() - zoomBy,
2512
4033
  minDistance + zoomBy,
2513
4034
  maxDistance - zoomBy
@@ -2519,7 +4040,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
2519
4040
  ZoomOut(by) {
2520
4041
  const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
2521
4042
  const { minDistance, maxDistance } = this;
2522
- this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(
4043
+ this.minDistance = this.maxDistance = import_three24.MathUtils.clamp(
2523
4044
  this.getDistance() + zoomBy,
2524
4045
  minDistance + zoomBy,
2525
4046
  maxDistance - zoomBy
@@ -2702,7 +4223,7 @@ var DIVEAnimationSystem = class {
2702
4223
  };
2703
4224
 
2704
4225
  // src/axiscamera/AxisCamera.ts
2705
- var import_three16 = require("three");
4226
+ var import_three25 = require("three");
2706
4227
  var import_three_spritetext = __toESM(require("three-spritetext"), 1);
2707
4228
  init_VisibilityLayerMask();
2708
4229
 
@@ -2715,18 +4236,18 @@ var AxesColorGreen = AxesColorGreenLetter;
2715
4236
  var AxesColorBlue = AxesColorBlueLetter;
2716
4237
 
2717
4238
  // src/axiscamera/AxisCamera.ts
2718
- var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
4239
+ var DIVEAxisCamera = class extends import_three25.OrthographicCamera {
2719
4240
  constructor(renderer, scene, controls) {
2720
4241
  super(-1, 1, 1, -1, 0.1, 100);
2721
4242
  this.layers.mask = COORDINATE_LAYER_MASK;
2722
- this.axesHelper = new import_three16.AxesHelper(0.5);
4243
+ this.axesHelper = new import_three25.AxesHelper(0.5);
2723
4244
  this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
2724
4245
  this.axesHelper.material.depthTest = false;
2725
4246
  this.axesHelper.position.set(0, 0, -1);
2726
4247
  this.axesHelper.setColors(
2727
- new import_three16.Color(AxesColorRed),
2728
- new import_three16.Color(AxesColorGreen),
2729
- new import_three16.Color(AxesColorBlue)
4248
+ new import_three25.Color(AxesColorRed),
4249
+ new import_three25.Color(AxesColorGreen),
4250
+ new import_three25.Color(AxesColorBlue)
2730
4251
  );
2731
4252
  const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
2732
4253
  const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
@@ -2744,7 +4265,7 @@ var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
2744
4265
  this._renderer = renderer;
2745
4266
  this._scene = scene;
2746
4267
  this._scene.add(this);
2747
- const restoreViewport = new import_three16.Vector4();
4268
+ const restoreViewport = new import_three25.Vector4();
2748
4269
  this._renderCallbackId = renderer.AddPostRenderCallback(() => {
2749
4270
  const restoreBackground = scene.background;
2750
4271
  scene.background = null;
@@ -2764,7 +4285,7 @@ var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
2764
4285
  }
2765
4286
  SetFromCameraMatrix(matrix) {
2766
4287
  this.axesHelper.rotation.setFromRotationMatrix(
2767
- new import_three16.Matrix4().extractRotation(matrix).invert()
4288
+ new import_three25.Matrix4().extractRotation(matrix).invert()
2768
4289
  );
2769
4290
  }
2770
4291
  };
@@ -2837,108 +4358,12 @@ var getObjectDelta = (a, b) => {
2837
4358
 
2838
4359
  // src/dive.ts
2839
4360
  var import_MathUtils2 = require("three/src/math/MathUtils");
2840
-
2841
- // src/info/Info.ts
2842
- var DIVEInfo = class {
2843
- /**
2844
- *
2845
- * @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
2846
- */
2847
- static GetSystem() {
2848
- const platform = navigator.platform;
2849
- if (/Android/.test(navigator.userAgent)) {
2850
- return "Android";
2851
- } else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
2852
- return "iOS";
2853
- } else if (platform.startsWith("Win")) {
2854
- return "Windows";
2855
- } else if (platform.startsWith("Mac")) {
2856
- return "MacOS";
2857
- } else if (platform.startsWith("Linux")) {
2858
- return "Linux";
2859
- } else {
2860
- return "Unknown";
2861
- }
2862
- }
2863
- /**
2864
- * @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
2865
- */
2866
- static GetSupportsWebXR() {
2867
- return __async(this, null, function* () {
2868
- if (this._supportsWebXR !== null) {
2869
- return this._supportsWebXR;
2870
- }
2871
- if (!navigator.xr) {
2872
- this._supportsWebXR = false;
2873
- return this._supportsWebXR;
2874
- }
2875
- try {
2876
- const supported = yield navigator.xr.isSessionSupported("immersive-ar");
2877
- this._supportsWebXR = supported;
2878
- } catch (error) {
2879
- this._supportsWebXR = false;
2880
- }
2881
- return this._supportsWebXR;
2882
- });
2883
- }
2884
- /**
2885
- * @returns A boolean indicating whether the user's device supports AR Quick Look.
2886
- */
2887
- static GetSupportsARQuickLook() {
2888
- const a = document.createElement("a");
2889
- if (a.relList.supports("ar")) {
2890
- return true;
2891
- }
2892
- const userAgent = navigator.userAgent;
2893
- const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
2894
- if (!isIOS) {
2895
- return false;
2896
- }
2897
- const match = userAgent.match(/OS (\d+)_/);
2898
- if (!match || match.length < 2) {
2899
- return false;
2900
- }
2901
- const iOSVersion = parseInt(match[1], 10);
2902
- const minQuickLookVersion = 12;
2903
- if (iOSVersion < minQuickLookVersion) {
2904
- return false;
2905
- }
2906
- const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
2907
- if (isSupportedBrowser) {
2908
- return true;
2909
- }
2910
- return false;
2911
- }
2912
- /**
2913
- * @returns A boolean indicating whether the user's device is a mobile device.
2914
- */
2915
- static get isMobile() {
2916
- return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
2917
- }
2918
- /**
2919
- * @returns A boolean indicating whether the user's device is a desktop device.
2920
- */
2921
- static get isDesktop() {
2922
- return !this.isMobile;
2923
- }
2924
- /**
2925
- * @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
2926
- */
2927
- static GetIsARCapable() {
2928
- return __async(this, null, function* () {
2929
- if (this.GetSupportsARQuickLook()) {
2930
- return true;
2931
- }
2932
- return yield this.GetSupportsWebXR();
2933
- });
2934
- }
2935
- };
2936
- DIVEInfo._supportsWebXR = null;
4361
+ init_Info();
2937
4362
 
2938
4363
  // package.json
2939
4364
  var package_default = {
2940
4365
  name: "@shopware-ag/dive",
2941
- version: "1.16.24",
4366
+ version: "1.16.26-beta.0",
2942
4367
  description: "Shopware Spatial Framework",
2943
4368
  type: "module",
2944
4369
  main: "./build/dive.cjs",
@@ -3057,15 +4482,15 @@ function truncateExp(number, decimals = 0) {
3057
4482
  }
3058
4483
 
3059
4484
  // src/math/radToDeg/radToDeg.ts
3060
- var import_three17 = require("three");
4485
+ var import_three26 = require("three");
3061
4486
  function radToDeg(radians) {
3062
- return (import_three17.MathUtils.radToDeg(radians) + 360) % 360;
4487
+ return (import_three26.MathUtils.radToDeg(radians) + 360) % 360;
3063
4488
  }
3064
4489
 
3065
4490
  // src/math/degToRad/degToRad.ts
3066
- var import_three18 = require("three");
4491
+ var import_three27 = require("three");
3067
4492
  function degToRad(degrees) {
3068
- return import_three18.MathUtils.degToRad(degrees);
4493
+ return import_three27.MathUtils.degToRad(degrees);
3069
4494
  }
3070
4495
 
3071
4496
  // src/math/index.ts
@@ -3090,8 +4515,8 @@ var DIVEDefaultSettings = {
3090
4515
  };
3091
4516
  var DIVE = class _DIVE {
3092
4517
  // static members
3093
- static QuickView(uri) {
3094
- const dive = new _DIVE();
4518
+ static QuickView(uri, settings) {
4519
+ const dive = new _DIVE(settings);
3095
4520
  dive.Communication.PerformAction("SET_CAMERA_TRANSFORM", {
3096
4521
  position: { x: 0, y: 2, z: 2 },
3097
4522
  target: { x: 0, y: 0.5, z: 0 }
@@ -3110,9 +4535,6 @@ var DIVE = class _DIVE {
3110
4535
  const modelid = (0, import_MathUtils2.generateUUID)();
3111
4536
  dive.Communication.Subscribe("MODEL_LOADED", (data) => {
3112
4537
  if (data.id !== modelid) return;
3113
- dive.Communication.PerformAction("PLACE_ON_FLOOR", {
3114
- id: modelid
3115
- });
3116
4538
  const transform = dive.Communication.PerformAction(
3117
4539
  "COMPUTE_ENCOMPASSING_VIEW",
3118
4540
  {}
@@ -3235,9 +4657,36 @@ var DIVE = class _DIVE {
3235
4657
  console.log(this.scene);
3236
4658
  }
3237
4659
  };
3238
- console.log(
3239
- `DIVE ${package_default.version} initialized ${false ? "in development mode" : ""}`
3240
- );
4660
+ console.log(`
4661
+ @@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
4662
+ @@@@+-:::::::---------------------==------------------------------=#@@@@
4663
+ @@%=::::.......::---------------------------------------------------------+@@
4664
+ @@+:::...........::-----------------------------------------------------------#@@
4665
+ @@=:::.........::::::--------------${" DIVE " + package_default.version.padStart(7, " ") + " "}---------------------------------%@
4666
+ @%:::.......:::::::-------------------${false ? " DEV MODE " : "--------------"}------------------------------------#@
4667
+ @*:::.....:::::-----------------------------------------------------------------------*@
4668
+ @%::::::.::::---------------------------------------------------------------------------@@
4669
+ @@-:::::::::-----------------------------------------------------------------------------=@
4670
+ @%::::::::--------------------------------------------------------------------------------%@
4671
+ @+::::::::--------------------------------=@@@@@%-----------------------------------------%@
4672
+ @=:::::::--------------------------------*@@ @@+---------------------------------------#@
4673
+ @+:::::::-------------------------------*@ @*--------------------------------------%@
4674
+ @#::::::::-----------------------------=@@ @@=-------------------------------------%@
4675
+ @@-::::::::----------------------------@@ @@------------------------------------=@
4676
+ @%:::::::::--------------------------*@ @*-----------------------------------@@
4677
+ @*:::::::::-------------------------@@ @@----------------------------------%@
4678
+ @#::::::::::----------------------%@ @%--------------------------------%@
4679
+ @#:::::::::::-------------------=@@ @@=------------------------------%@
4680
+ @@-::::::::::::----------------%@ @%----------------------------=@@
4681
+ @@#::::::::::::::------------*@ @*--------------------------#@@
4682
+ @@+::::::::::::::::--------@@ @@------------------------+@@
4683
+ @@*:::::::::::::::::----@@ @@---------------------+@@
4684
+ @@@-:::::::::::::::--#@ @#-----------------=%@@
4685
+ @@%-::::::::::::-%@ @%-------------=%@@
4686
+ @@@@+:::::::#@@ @@*-------*@@@@
4687
+ @@@@@@@ @@@@@@
4688
+
4689
+ `);
3241
4690
  }
3242
4691
  Dispose() {
3243
4692
  var _a;