@shopware-ag/dive 1.16.16-beta.0 → 1.16.17
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 +203 -1652
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +8 -50
- package/build/dive.d.ts +8 -50
- package/build/dive.js +159 -1619
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/axiscamera/AxisCamera.ts +4 -4
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -4
- package/src/com/Communication.ts +0 -17
- package/src/com/__test__/Communication.test.ts +1 -1
- package/src/com/actions/index.ts +0 -2
- package/src/dive.ts +9 -51
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +2 -2
- package/src/info/Info.ts +1 -37
- package/src/info/__test__/Info.test.ts +5 -45
- package/src/mediacreator/MediaCreator.ts +4 -4
- package/src/mediacreator/__test__/MediaCreator.test.ts +2 -7
- package/src/renderer/Renderer.ts +11 -21
- package/src/renderer/__test__/Renderer.test.ts +1 -19
- package/src/scene/Scene.ts +12 -35
- package/src/scene/__test__/Scene.test.ts +5 -39
- package/src/scene/root/Root.ts +0 -1
- package/src/toolbox/BaseTool.ts +3 -9
- package/src/toolbox/Toolbox.ts +1 -1
- package/src/toolbox/__test__/Toolbox.test.ts +1 -1
- package/src/toolbox/select/SelectTool.ts +1 -1
- package/src/toolbox/select/__test__/SelectTool.test.ts +1 -1
- package/src/toolbox/transform/TransformTool.ts +4 -4
- package/src/toolbox/transform/__test__/TransformTool.test.ts +4 -2
- package/src/ar/AR.ts +0 -164
- package/src/ar/arquicklook/ARQuickLook.ts +0 -42
- package/src/ar/webxr/WebXR.ts +0 -176
- package/src/ar/webxr/controller/WebXRController.ts +0 -334
- package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
- package/src/ar/webxr/origin/WebXROrigin.ts +0 -191
- package/src/ar/webxr/overlay/Overlay.ts +0 -50
- package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
- package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
- package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
- package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
- package/src/events/EventExecutor.ts +0 -35
- package/src/scene/xrroot/XRRoot.ts +0 -56
- package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
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
|
|
328
|
+
var import_Addons, DIVETransformTool;
|
|
329
329
|
var init_TransformTool = __esm({
|
|
330
330
|
"src/toolbox/transform/TransformTool.ts"() {
|
|
331
331
|
"use strict";
|
|
332
332
|
init_BaseTool();
|
|
333
|
-
|
|
333
|
+
import_Addons = require("three/examples/jsm/Addons");
|
|
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
|
|
340
|
+
this._gizmo = new import_Addons.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
|
-
|
|
374
|
+
scene.add(this._gizmo);
|
|
375
375
|
}
|
|
376
376
|
Activate() {
|
|
377
377
|
}
|
|
@@ -636,1398 +636,6 @@ 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
|
-
|
|
2031
639
|
// src/dive.ts
|
|
2032
640
|
var dive_exports = {};
|
|
2033
641
|
__export(dive_exports, {
|
|
@@ -2078,8 +686,8 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
|
2078
686
|
}
|
|
2079
687
|
// Starts the renderer with the given scene and camera.
|
|
2080
688
|
StartRenderer(scene, cam) {
|
|
2081
|
-
this.setAnimationLoop((
|
|
2082
|
-
this.internal_render(scene, cam
|
|
689
|
+
this.setAnimationLoop(() => {
|
|
690
|
+
this.internal_render(scene, cam);
|
|
2083
691
|
});
|
|
2084
692
|
this.running = true;
|
|
2085
693
|
}
|
|
@@ -2153,24 +761,24 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
|
2153
761
|
* @param scene Scene to render.
|
|
2154
762
|
* @param cam Camera to render with.
|
|
2155
763
|
*/
|
|
2156
|
-
internal_render(scene, cam
|
|
764
|
+
internal_render(scene, cam) {
|
|
2157
765
|
if ((this.paused || !this.running) && !this.force) return;
|
|
2158
766
|
this.preRenderCallbacks.forEach((callback) => {
|
|
2159
|
-
callback(
|
|
767
|
+
callback();
|
|
2160
768
|
});
|
|
2161
769
|
this.render(scene, cam);
|
|
2162
770
|
this.postRenderCallbacks.forEach((callback) => {
|
|
2163
|
-
callback(
|
|
771
|
+
callback();
|
|
2164
772
|
});
|
|
2165
773
|
this.force = false;
|
|
2166
774
|
}
|
|
2167
775
|
};
|
|
2168
776
|
|
|
2169
777
|
// src/scene/Scene.ts
|
|
2170
|
-
var
|
|
778
|
+
var import_three14 = require("three");
|
|
2171
779
|
|
|
2172
780
|
// src/scene/root/Root.ts
|
|
2173
|
-
var
|
|
781
|
+
var import_three11 = require("three");
|
|
2174
782
|
|
|
2175
783
|
// src/light/AmbientLight.ts
|
|
2176
784
|
var import_three2 = require("three");
|
|
@@ -2197,7 +805,7 @@ var DIVEAmbientLight = class extends import_three2.Object3D {
|
|
|
2197
805
|
};
|
|
2198
806
|
|
|
2199
807
|
// src/light/PointLight.ts
|
|
2200
|
-
var
|
|
808
|
+
var import_three5 = require("three");
|
|
2201
809
|
|
|
2202
810
|
// src/com/Communication.ts
|
|
2203
811
|
var import_MathUtils = require("three/src/math/MathUtils");
|
|
@@ -2215,7 +823,6 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2215
823
|
this.toolbox = toolbox;
|
|
2216
824
|
this._mediaGenerator = null;
|
|
2217
825
|
this._io = null;
|
|
2218
|
-
this._ar = null;
|
|
2219
826
|
_DIVECommunication.__instances.push(this);
|
|
2220
827
|
}
|
|
2221
828
|
static get(id) {
|
|
@@ -2250,13 +857,6 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2250
857
|
}
|
|
2251
858
|
return this._io;
|
|
2252
859
|
}
|
|
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
|
-
}
|
|
2260
860
|
DestroyInstance() {
|
|
2261
861
|
const existingIndex = _DIVECommunication.__instances.findIndex(
|
|
2262
862
|
(entry) => entry.id === this.id
|
|
@@ -2424,11 +1024,6 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2424
1024
|
);
|
|
2425
1025
|
break;
|
|
2426
1026
|
}
|
|
2427
|
-
case "LAUNCH_AR": {
|
|
2428
|
-
this.ar.Launch();
|
|
2429
|
-
returnValue = true;
|
|
2430
|
-
break;
|
|
2431
|
-
}
|
|
2432
1027
|
default: {
|
|
2433
1028
|
console.warn(
|
|
2434
1029
|
`DIVECommunication.PerformAction: has been executed with unknown Action type ${action}`
|
|
@@ -2712,7 +1307,7 @@ var DIVECommunication = _DIVECommunication;
|
|
|
2712
1307
|
|
|
2713
1308
|
// src/light/PointLight.ts
|
|
2714
1309
|
init_VisibilityLayerMask();
|
|
2715
|
-
var DIVEPointLight = class extends
|
|
1310
|
+
var DIVEPointLight = class extends import_three5.Object3D {
|
|
2716
1311
|
constructor() {
|
|
2717
1312
|
super();
|
|
2718
1313
|
this.isDIVELight = true;
|
|
@@ -2721,25 +1316,25 @@ var DIVEPointLight = class extends import_three12.Object3D {
|
|
|
2721
1316
|
this.isSelectable = true;
|
|
2722
1317
|
this.gizmo = null;
|
|
2723
1318
|
this.name = "DIVEPointLight";
|
|
2724
|
-
this.light = new
|
|
1319
|
+
this.light = new import_three5.PointLight(16777215, 1);
|
|
2725
1320
|
this.light.layers.mask = PRODUCT_LAYER_MASK;
|
|
2726
1321
|
this.light.castShadow = true;
|
|
2727
1322
|
this.light.shadow.mapSize.width = 512;
|
|
2728
1323
|
this.light.shadow.mapSize.height = 512;
|
|
2729
1324
|
this.add(this.light);
|
|
2730
1325
|
const geoSize = 0.1;
|
|
2731
|
-
const geometry = new
|
|
1326
|
+
const geometry = new import_three5.SphereGeometry(
|
|
2732
1327
|
geoSize,
|
|
2733
1328
|
geoSize * 320,
|
|
2734
1329
|
geoSize * 320
|
|
2735
1330
|
);
|
|
2736
|
-
const material = new
|
|
1331
|
+
const material = new import_three5.MeshBasicMaterial({
|
|
2737
1332
|
color: this.light.color,
|
|
2738
1333
|
transparent: true,
|
|
2739
1334
|
opacity: 0.8,
|
|
2740
|
-
side:
|
|
1335
|
+
side: import_three5.FrontSide
|
|
2741
1336
|
});
|
|
2742
|
-
this.mesh = new
|
|
1337
|
+
this.mesh = new import_three5.Mesh(geometry, material);
|
|
2743
1338
|
this.mesh.layers.mask = UI_LAYER_MASK;
|
|
2744
1339
|
this.add(this.mesh);
|
|
2745
1340
|
}
|
|
@@ -2779,18 +1374,18 @@ var DIVEPointLight = class extends import_three12.Object3D {
|
|
|
2779
1374
|
|
|
2780
1375
|
// src/light/SceneLight.ts
|
|
2781
1376
|
init_VisibilityLayerMask();
|
|
2782
|
-
var
|
|
2783
|
-
var DIVESceneLight = class extends
|
|
1377
|
+
var import_three6 = require("three");
|
|
1378
|
+
var DIVESceneLight = class extends import_three6.Object3D {
|
|
2784
1379
|
constructor() {
|
|
2785
1380
|
super();
|
|
2786
1381
|
this.isDIVELight = true;
|
|
2787
1382
|
this.isDIVESceneLight = true;
|
|
2788
1383
|
this.name = "DIVESceneLight";
|
|
2789
|
-
this._hemiLight = new
|
|
1384
|
+
this._hemiLight = new import_three6.HemisphereLight(16777215, 16777215, 2);
|
|
2790
1385
|
this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
2791
1386
|
this._hemiLight.position.set(0, 50, 0);
|
|
2792
1387
|
this.add(this._hemiLight);
|
|
2793
|
-
this._dirLight = new
|
|
1388
|
+
this._dirLight = new import_three6.DirectionalLight(16777215, 3);
|
|
2794
1389
|
this._dirLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
2795
1390
|
this._dirLight.position.set(1, 1.75, 1);
|
|
2796
1391
|
this._dirLight.position.multiplyScalar(30);
|
|
@@ -2820,7 +1415,7 @@ var DIVESceneLight = class extends import_three13.Object3D {
|
|
|
2820
1415
|
};
|
|
2821
1416
|
|
|
2822
1417
|
// src/model/Model.ts
|
|
2823
|
-
var
|
|
1418
|
+
var import_three8 = require("three");
|
|
2824
1419
|
init_VisibilityLayerMask();
|
|
2825
1420
|
|
|
2826
1421
|
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
@@ -2832,9 +1427,9 @@ var findSceneRecursive = (object) => {
|
|
|
2832
1427
|
};
|
|
2833
1428
|
|
|
2834
1429
|
// src/node/Node.ts
|
|
2835
|
-
var
|
|
1430
|
+
var import_three7 = require("three");
|
|
2836
1431
|
init_VisibilityLayerMask();
|
|
2837
|
-
var DIVENode = class extends
|
|
1432
|
+
var DIVENode = class extends import_three7.Object3D {
|
|
2838
1433
|
constructor() {
|
|
2839
1434
|
super();
|
|
2840
1435
|
this.isDIVENode = true;
|
|
@@ -2842,15 +1437,15 @@ var DIVENode = class extends import_three14.Object3D {
|
|
|
2842
1437
|
this.isMovable = true;
|
|
2843
1438
|
this.gizmo = null;
|
|
2844
1439
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
2845
|
-
this._positionWorldBuffer = new
|
|
2846
|
-
this._boundingBox = new
|
|
1440
|
+
this._positionWorldBuffer = new import_three7.Vector3();
|
|
1441
|
+
this._boundingBox = new import_three7.Box3();
|
|
2847
1442
|
}
|
|
2848
1443
|
SetPosition(position) {
|
|
2849
1444
|
if (!this.parent) {
|
|
2850
1445
|
this.position.set(position.x, position.y, position.z);
|
|
2851
1446
|
return;
|
|
2852
1447
|
}
|
|
2853
|
-
const newPosition = new
|
|
1448
|
+
const newPosition = new import_three7.Vector3(position.x, position.y, position.z);
|
|
2854
1449
|
this.position.copy(this.parent.worldToLocal(newPosition));
|
|
2855
1450
|
if ("isDIVEGroup" in this.parent) {
|
|
2856
1451
|
this.parent.UpdateLineTo(this);
|
|
@@ -2938,7 +1533,7 @@ var DIVEModel = class extends DIVENode {
|
|
|
2938
1533
|
}
|
|
2939
1534
|
SetMaterial(material) {
|
|
2940
1535
|
if (!this._material) {
|
|
2941
|
-
this._material = new
|
|
1536
|
+
this._material = new import_three8.MeshStandardMaterial();
|
|
2942
1537
|
}
|
|
2943
1538
|
if (material.vertexColors !== void 0) {
|
|
2944
1539
|
this._material.vertexColors = material.vertexColors;
|
|
@@ -3000,10 +1595,10 @@ var DIVEModel = class extends DIVENode {
|
|
|
3000
1595
|
}
|
|
3001
1596
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
3002
1597
|
const bbBottomCenter = this.localToWorld(
|
|
3003
|
-
this._boundingBox.getCenter(new
|
|
1598
|
+
this._boundingBox.getCenter(new import_three8.Vector3()).multiply(this.scale)
|
|
3004
1599
|
);
|
|
3005
1600
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
3006
|
-
const raycaster = new
|
|
1601
|
+
const raycaster = new import_three8.Raycaster(bbBottomCenter, new import_three8.Vector3(0, -1, 0));
|
|
3007
1602
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
3008
1603
|
const intersections = raycaster.intersectObjects(
|
|
3009
1604
|
findSceneRecursive(this).Root.children,
|
|
@@ -3015,7 +1610,7 @@ var DIVEModel = class extends DIVENode {
|
|
|
3015
1610
|
const meshBB = mesh.geometry.boundingBox;
|
|
3016
1611
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
3017
1612
|
const oldPos = this.position.clone();
|
|
3018
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1613
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three8.Vector3(0, bottomY, 0));
|
|
3019
1614
|
this.position.copy(newPos);
|
|
3020
1615
|
if (this.position.y === oldPos.y) return;
|
|
3021
1616
|
this.onMove();
|
|
@@ -3024,13 +1619,13 @@ var DIVEModel = class extends DIVENode {
|
|
|
3024
1619
|
};
|
|
3025
1620
|
|
|
3026
1621
|
// src/loadingmanager/LoadingManager.ts
|
|
3027
|
-
var
|
|
1622
|
+
var import_Addons2 = require("three/examples/jsm/Addons.js");
|
|
3028
1623
|
var DIVELoadingManager = class {
|
|
3029
1624
|
// ... maybe extend with other loaders later
|
|
3030
1625
|
constructor() {
|
|
3031
1626
|
this.progress = /* @__PURE__ */ new Map();
|
|
3032
|
-
this.gltfloader = new
|
|
3033
|
-
this.dracoloader = new
|
|
1627
|
+
this.gltfloader = new import_Addons2.GLTFLoader();
|
|
1628
|
+
this.dracoloader = new import_Addons2.DRACOLoader();
|
|
3034
1629
|
this.dracoloader.setDecoderPath(
|
|
3035
1630
|
"https://www.gstatic.com/draco/v1/decoders/"
|
|
3036
1631
|
);
|
|
@@ -3058,17 +1653,17 @@ var DIVELoadingManager = class {
|
|
|
3058
1653
|
};
|
|
3059
1654
|
|
|
3060
1655
|
// src/primitive/Primitive.ts
|
|
3061
|
-
var
|
|
1656
|
+
var import_three9 = require("three");
|
|
3062
1657
|
init_VisibilityLayerMask();
|
|
3063
1658
|
var DIVEPrimitive = class extends DIVENode {
|
|
3064
1659
|
constructor() {
|
|
3065
1660
|
super();
|
|
3066
1661
|
this.isDIVEPrimitive = true;
|
|
3067
|
-
this._mesh = new
|
|
1662
|
+
this._mesh = new import_three9.Mesh();
|
|
3068
1663
|
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
3069
1664
|
this._mesh.castShadow = true;
|
|
3070
1665
|
this._mesh.receiveShadow = true;
|
|
3071
|
-
this._mesh.material = new
|
|
1666
|
+
this._mesh.material = new import_three9.MeshStandardMaterial();
|
|
3072
1667
|
this.add(this._mesh);
|
|
3073
1668
|
}
|
|
3074
1669
|
SetGeometry(geometry) {
|
|
@@ -3083,7 +1678,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3083
1678
|
primitiveMaterial.vertexColors = material.vertexColors;
|
|
3084
1679
|
}
|
|
3085
1680
|
if (material.color !== void 0) {
|
|
3086
|
-
primitiveMaterial.color = new
|
|
1681
|
+
primitiveMaterial.color = new import_three9.Color(material.color);
|
|
3087
1682
|
}
|
|
3088
1683
|
if (material.map !== void 0) {
|
|
3089
1684
|
primitiveMaterial.map = material.map;
|
|
@@ -3137,10 +1732,10 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3137
1732
|
}
|
|
3138
1733
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
3139
1734
|
const bbBottomCenter = this.localToWorld(
|
|
3140
|
-
this._boundingBox.getCenter(new
|
|
1735
|
+
this._boundingBox.getCenter(new import_three9.Vector3()).multiply(this.scale)
|
|
3141
1736
|
);
|
|
3142
1737
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
3143
|
-
const raycaster = new
|
|
1738
|
+
const raycaster = new import_three9.Raycaster(bbBottomCenter, new import_three9.Vector3(0, -1, 0));
|
|
3144
1739
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
3145
1740
|
const intersections = raycaster.intersectObjects(
|
|
3146
1741
|
findSceneRecursive(this).Root.children,
|
|
@@ -3152,7 +1747,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3152
1747
|
const meshBB = mesh.geometry.boundingBox;
|
|
3153
1748
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
3154
1749
|
const oldPos = this.position.clone();
|
|
3155
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1750
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three9.Vector3(0, bottomY, 0));
|
|
3156
1751
|
this.position.copy(newPos);
|
|
3157
1752
|
if (this.position.y === oldPos.y) return;
|
|
3158
1753
|
this.onMove();
|
|
@@ -3187,7 +1782,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3187
1782
|
}
|
|
3188
1783
|
}
|
|
3189
1784
|
createCylinderGeometry(geometry) {
|
|
3190
|
-
const geo = new
|
|
1785
|
+
const geo = new import_three9.CylinderGeometry(
|
|
3191
1786
|
geometry.width / 2,
|
|
3192
1787
|
geometry.width / 2,
|
|
3193
1788
|
geometry.height,
|
|
@@ -3197,7 +1792,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3197
1792
|
return geo;
|
|
3198
1793
|
}
|
|
3199
1794
|
createSphereGeometry(geometry) {
|
|
3200
|
-
const geo = new
|
|
1795
|
+
const geo = new import_three9.SphereGeometry(geometry.width / 2, 256, 256);
|
|
3201
1796
|
return geo;
|
|
3202
1797
|
}
|
|
3203
1798
|
createPyramidGeometry(geometry) {
|
|
@@ -3242,19 +1837,19 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3242
1837
|
4,
|
|
3243
1838
|
0
|
|
3244
1839
|
]);
|
|
3245
|
-
const geometryBuffer = new
|
|
1840
|
+
const geometryBuffer = new import_three9.BufferGeometry();
|
|
3246
1841
|
geometryBuffer.setAttribute(
|
|
3247
1842
|
"position",
|
|
3248
|
-
new
|
|
1843
|
+
new import_three9.BufferAttribute(vertices, 3)
|
|
3249
1844
|
);
|
|
3250
|
-
geometryBuffer.setIndex(new
|
|
1845
|
+
geometryBuffer.setIndex(new import_three9.BufferAttribute(indices, 1));
|
|
3251
1846
|
geometryBuffer.computeVertexNormals();
|
|
3252
1847
|
geometryBuffer.computeBoundingBox();
|
|
3253
1848
|
geometryBuffer.computeBoundingSphere();
|
|
3254
1849
|
return geometryBuffer;
|
|
3255
1850
|
}
|
|
3256
1851
|
createBoxGeometry(geometry) {
|
|
3257
|
-
const geo = new
|
|
1852
|
+
const geo = new import_three9.BoxGeometry(
|
|
3258
1853
|
geometry.width,
|
|
3259
1854
|
geometry.height,
|
|
3260
1855
|
geometry.depth
|
|
@@ -3263,12 +1858,12 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3263
1858
|
return geo;
|
|
3264
1859
|
}
|
|
3265
1860
|
createConeGeometry(geometry) {
|
|
3266
|
-
const geo = new
|
|
1861
|
+
const geo = new import_three9.ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
3267
1862
|
geo.translate(0, geometry.height / 2, 0);
|
|
3268
1863
|
return geo;
|
|
3269
1864
|
}
|
|
3270
1865
|
createWallGeometry(geometry) {
|
|
3271
|
-
const geo = new
|
|
1866
|
+
const geo = new import_three9.BoxGeometry(
|
|
3272
1867
|
geometry.width,
|
|
3273
1868
|
geometry.height,
|
|
3274
1869
|
geometry.depth || 0.05,
|
|
@@ -3278,7 +1873,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3278
1873
|
return geo;
|
|
3279
1874
|
}
|
|
3280
1875
|
createPlaneGeometry(geometry) {
|
|
3281
|
-
const geo = new
|
|
1876
|
+
const geo = new import_three9.BoxGeometry(
|
|
3282
1877
|
geometry.width,
|
|
3283
1878
|
geometry.height,
|
|
3284
1879
|
geometry.depth
|
|
@@ -3289,7 +1884,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3289
1884
|
};
|
|
3290
1885
|
|
|
3291
1886
|
// src/group/Group.ts
|
|
3292
|
-
var
|
|
1887
|
+
var import_three10 = require("three");
|
|
3293
1888
|
var DIVEGroup = class extends DIVENode {
|
|
3294
1889
|
// lines to children
|
|
3295
1890
|
constructor() {
|
|
@@ -3351,13 +1946,13 @@ var DIVEGroup = class extends DIVENode {
|
|
|
3351
1946
|
* Adds a line to this grouo as last child.
|
|
3352
1947
|
*/
|
|
3353
1948
|
createLine() {
|
|
3354
|
-
const geo = new
|
|
3355
|
-
const mat = new
|
|
1949
|
+
const geo = new import_three10.BufferGeometry();
|
|
1950
|
+
const mat = new import_three10.LineDashedMaterial({
|
|
3356
1951
|
color: 6710886,
|
|
3357
1952
|
dashSize: 0.05,
|
|
3358
1953
|
gapSize: 0.025
|
|
3359
1954
|
});
|
|
3360
|
-
const line = new
|
|
1955
|
+
const line = new import_three10.Line(geo, mat);
|
|
3361
1956
|
line.visible = false;
|
|
3362
1957
|
return line;
|
|
3363
1958
|
}
|
|
@@ -3366,7 +1961,7 @@ var DIVEGroup = class extends DIVENode {
|
|
|
3366
1961
|
*/
|
|
3367
1962
|
updateLineTo(line, object) {
|
|
3368
1963
|
line.geometry.setFromPoints([
|
|
3369
|
-
new
|
|
1964
|
+
new import_three10.Vector3(0, 0, 0),
|
|
3370
1965
|
object.position.clone()
|
|
3371
1966
|
]);
|
|
3372
1967
|
line.computeLineDistances();
|
|
@@ -3421,7 +2016,7 @@ var DIVEGroup = class extends DIVENode {
|
|
|
3421
2016
|
};
|
|
3422
2017
|
|
|
3423
2018
|
// src/scene/root/Root.ts
|
|
3424
|
-
var DIVERoot = class extends
|
|
2019
|
+
var DIVERoot = class extends import_three11.Object3D {
|
|
3425
2020
|
constructor() {
|
|
3426
2021
|
super();
|
|
3427
2022
|
this.isDIVERoot = true;
|
|
@@ -3429,7 +2024,7 @@ var DIVERoot = class extends import_three18.Object3D {
|
|
|
3429
2024
|
this.loadingManager = new DIVELoadingManager();
|
|
3430
2025
|
}
|
|
3431
2026
|
ComputeSceneBB() {
|
|
3432
|
-
const bb = new
|
|
2027
|
+
const bb = new import_three11.Box3();
|
|
3433
2028
|
this.traverse((object) => {
|
|
3434
2029
|
if ("isObject3D" in object) {
|
|
3435
2030
|
bb.expandByObject(object);
|
|
@@ -3593,7 +2188,7 @@ var DIVERoot = class extends import_three18.Object3D {
|
|
|
3593
2188
|
);
|
|
3594
2189
|
if (light.color !== void 0 && light.color !== null)
|
|
3595
2190
|
sceneObject.SetColor(
|
|
3596
|
-
new
|
|
2191
|
+
new import_three11.Color(light.color)
|
|
3597
2192
|
);
|
|
3598
2193
|
if (light.visible !== void 0 && light.visible !== null)
|
|
3599
2194
|
sceneObject.visible = light.visible;
|
|
@@ -3606,7 +2201,6 @@ var DIVERoot = class extends import_three18.Object3D {
|
|
|
3606
2201
|
const created = new DIVEModel();
|
|
3607
2202
|
sceneObject = created;
|
|
3608
2203
|
sceneObject.userData.id = model.id;
|
|
3609
|
-
sceneObject.userData.uri = model.uri;
|
|
3610
2204
|
this.add(sceneObject);
|
|
3611
2205
|
}
|
|
3612
2206
|
if (model.uri !== void 0) {
|
|
@@ -3765,12 +2359,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
3765
2359
|
|
|
3766
2360
|
// src/grid/Grid.ts
|
|
3767
2361
|
init_VisibilityLayerMask();
|
|
3768
|
-
var
|
|
3769
|
-
var DIVEGrid = class extends
|
|
2362
|
+
var import_three12 = require("three");
|
|
2363
|
+
var DIVEGrid = class extends import_three12.Object3D {
|
|
3770
2364
|
constructor() {
|
|
3771
2365
|
super();
|
|
3772
2366
|
this.name = "Grid";
|
|
3773
|
-
const grid = new
|
|
2367
|
+
const grid = new import_three12.GridHelper(
|
|
3774
2368
|
100,
|
|
3775
2369
|
100,
|
|
3776
2370
|
GRID_CENTER_LINE_COLOR,
|
|
@@ -3786,14 +2380,14 @@ var DIVEGrid = class extends import_three19.Object3D {
|
|
|
3786
2380
|
};
|
|
3787
2381
|
|
|
3788
2382
|
// src/primitive/floor/Floor.ts
|
|
3789
|
-
var
|
|
2383
|
+
var import_three13 = require("three");
|
|
3790
2384
|
init_VisibilityLayerMask();
|
|
3791
|
-
var DIVEFloor = class extends
|
|
2385
|
+
var DIVEFloor = class extends import_three13.Mesh {
|
|
3792
2386
|
constructor() {
|
|
3793
2387
|
super(
|
|
3794
|
-
new
|
|
3795
|
-
new
|
|
3796
|
-
color: new
|
|
2388
|
+
new import_three13.PlaneGeometry(1e4, 1e4),
|
|
2389
|
+
new import_three13.MeshStandardMaterial({
|
|
2390
|
+
color: new import_three13.Color(150 / 255, 150 / 255, 150 / 255)
|
|
3797
2391
|
})
|
|
3798
2392
|
);
|
|
3799
2393
|
this.isFloor = true;
|
|
@@ -3806,148 +2400,33 @@ var DIVEFloor = class extends import_three20.Mesh {
|
|
|
3806
2400
|
this.visible = visible;
|
|
3807
2401
|
}
|
|
3808
2402
|
SetColor(color) {
|
|
3809
|
-
this.material.color = new
|
|
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();
|
|
2403
|
+
this.material.color = new import_three13.Color(color);
|
|
3909
2404
|
}
|
|
3910
2405
|
};
|
|
3911
2406
|
|
|
3912
2407
|
// src/scene/Scene.ts
|
|
3913
|
-
var DIVEScene = class extends
|
|
2408
|
+
var DIVEScene = class extends import_three14.Scene {
|
|
3914
2409
|
get Root() {
|
|
3915
|
-
return this.
|
|
3916
|
-
}
|
|
3917
|
-
get XRRoot() {
|
|
3918
|
-
return this._xrRoot;
|
|
2410
|
+
return this.root;
|
|
3919
2411
|
}
|
|
3920
2412
|
get Floor() {
|
|
3921
|
-
return this.
|
|
2413
|
+
return this.floor;
|
|
3922
2414
|
}
|
|
3923
2415
|
get Grid() {
|
|
3924
|
-
return this.
|
|
2416
|
+
return this.grid;
|
|
3925
2417
|
}
|
|
3926
2418
|
constructor() {
|
|
3927
2419
|
super();
|
|
3928
|
-
this.background = new
|
|
3929
|
-
this.
|
|
3930
|
-
this.add(this.
|
|
3931
|
-
this.
|
|
3932
|
-
this.add(this.
|
|
3933
|
-
this.
|
|
3934
|
-
this.add(this.
|
|
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();
|
|
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);
|
|
3948
2427
|
}
|
|
3949
2428
|
SetBackground(color) {
|
|
3950
|
-
this.background = new
|
|
2429
|
+
this.background = new import_three14.Color(color);
|
|
3951
2430
|
}
|
|
3952
2431
|
ComputeSceneBB() {
|
|
3953
2432
|
return this.Root.ComputeSceneBB();
|
|
@@ -3974,7 +2453,7 @@ init_PerspectiveCamera();
|
|
|
3974
2453
|
|
|
3975
2454
|
// src/controls/OrbitControls.ts
|
|
3976
2455
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
3977
|
-
var
|
|
2456
|
+
var import_three15 = require("three");
|
|
3978
2457
|
var import_tween = require("@tweenjs/tween.js");
|
|
3979
2458
|
var DIVEOrbitControlsDefaultSettings = {
|
|
3980
2459
|
enableDamping: true,
|
|
@@ -4016,8 +2495,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
4016
2495
|
this.dispose();
|
|
4017
2496
|
}
|
|
4018
2497
|
ComputeEncompassingView(bb) {
|
|
4019
|
-
const center = bb.getCenter(new
|
|
4020
|
-
const size = bb.getSize(new
|
|
2498
|
+
const center = bb.getCenter(new import_three15.Vector3());
|
|
2499
|
+
const size = bb.getSize(new import_three15.Vector3());
|
|
4021
2500
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
4022
2501
|
const direction = this.object.position.clone().normalize();
|
|
4023
2502
|
return {
|
|
@@ -4028,7 +2507,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
4028
2507
|
ZoomIn(by) {
|
|
4029
2508
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
4030
2509
|
const { minDistance, maxDistance } = this;
|
|
4031
|
-
this.minDistance = this.maxDistance =
|
|
2510
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(
|
|
4032
2511
|
this.getDistance() - zoomBy,
|
|
4033
2512
|
minDistance + zoomBy,
|
|
4034
2513
|
maxDistance - zoomBy
|
|
@@ -4040,7 +2519,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
4040
2519
|
ZoomOut(by) {
|
|
4041
2520
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
4042
2521
|
const { minDistance, maxDistance } = this;
|
|
4043
|
-
this.minDistance = this.maxDistance =
|
|
2522
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(
|
|
4044
2523
|
this.getDistance() + zoomBy,
|
|
4045
2524
|
minDistance + zoomBy,
|
|
4046
2525
|
maxDistance - zoomBy
|
|
@@ -4223,7 +2702,7 @@ var DIVEAnimationSystem = class {
|
|
|
4223
2702
|
};
|
|
4224
2703
|
|
|
4225
2704
|
// src/axiscamera/AxisCamera.ts
|
|
4226
|
-
var
|
|
2705
|
+
var import_three16 = require("three");
|
|
4227
2706
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
4228
2707
|
init_VisibilityLayerMask();
|
|
4229
2708
|
|
|
@@ -4236,18 +2715,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
4236
2715
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
4237
2716
|
|
|
4238
2717
|
// src/axiscamera/AxisCamera.ts
|
|
4239
|
-
var DIVEAxisCamera = class extends
|
|
2718
|
+
var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
|
|
4240
2719
|
constructor(renderer, scene, controls) {
|
|
4241
2720
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
4242
2721
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
4243
|
-
this.axesHelper = new
|
|
2722
|
+
this.axesHelper = new import_three16.AxesHelper(0.5);
|
|
4244
2723
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
4245
2724
|
this.axesHelper.material.depthTest = false;
|
|
4246
2725
|
this.axesHelper.position.set(0, 0, -1);
|
|
4247
2726
|
this.axesHelper.setColors(
|
|
4248
|
-
new
|
|
4249
|
-
new
|
|
4250
|
-
new
|
|
2727
|
+
new import_three16.Color(AxesColorRed),
|
|
2728
|
+
new import_three16.Color(AxesColorGreen),
|
|
2729
|
+
new import_three16.Color(AxesColorBlue)
|
|
4251
2730
|
);
|
|
4252
2731
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
4253
2732
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -4265,7 +2744,7 @@ var DIVEAxisCamera = class extends import_three25.OrthographicCamera {
|
|
|
4265
2744
|
this._renderer = renderer;
|
|
4266
2745
|
this._scene = scene;
|
|
4267
2746
|
this._scene.add(this);
|
|
4268
|
-
const restoreViewport = new
|
|
2747
|
+
const restoreViewport = new import_three16.Vector4();
|
|
4269
2748
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
4270
2749
|
const restoreBackground = scene.background;
|
|
4271
2750
|
scene.background = null;
|
|
@@ -4285,7 +2764,7 @@ var DIVEAxisCamera = class extends import_three25.OrthographicCamera {
|
|
|
4285
2764
|
}
|
|
4286
2765
|
SetFromCameraMatrix(matrix) {
|
|
4287
2766
|
this.axesHelper.rotation.setFromRotationMatrix(
|
|
4288
|
-
new
|
|
2767
|
+
new import_three16.Matrix4().extractRotation(matrix).invert()
|
|
4289
2768
|
);
|
|
4290
2769
|
}
|
|
4291
2770
|
};
|
|
@@ -4358,12 +2837,108 @@ var getObjectDelta = (a, b) => {
|
|
|
4358
2837
|
|
|
4359
2838
|
// src/dive.ts
|
|
4360
2839
|
var import_MathUtils2 = require("three/src/math/MathUtils");
|
|
4361
|
-
|
|
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;
|
|
4362
2937
|
|
|
4363
2938
|
// package.json
|
|
4364
2939
|
var package_default = {
|
|
4365
2940
|
name: "@shopware-ag/dive",
|
|
4366
|
-
version: "1.16.
|
|
2941
|
+
version: "1.16.17",
|
|
4367
2942
|
description: "Shopware Spatial Framework",
|
|
4368
2943
|
type: "module",
|
|
4369
2944
|
main: "./build/dive.cjs",
|
|
@@ -4482,15 +3057,15 @@ function truncateExp(number, decimals = 0) {
|
|
|
4482
3057
|
}
|
|
4483
3058
|
|
|
4484
3059
|
// src/math/radToDeg/radToDeg.ts
|
|
4485
|
-
var
|
|
3060
|
+
var import_three17 = require("three");
|
|
4486
3061
|
function radToDeg(radians) {
|
|
4487
|
-
return (
|
|
3062
|
+
return (import_three17.MathUtils.radToDeg(radians) + 360) % 360;
|
|
4488
3063
|
}
|
|
4489
3064
|
|
|
4490
3065
|
// src/math/degToRad/degToRad.ts
|
|
4491
|
-
var
|
|
3066
|
+
var import_three18 = require("three");
|
|
4492
3067
|
function degToRad(degrees) {
|
|
4493
|
-
return
|
|
3068
|
+
return import_three18.MathUtils.degToRad(degrees);
|
|
4494
3069
|
}
|
|
4495
3070
|
|
|
4496
3071
|
// src/math/index.ts
|
|
@@ -4515,8 +3090,8 @@ var DIVEDefaultSettings = {
|
|
|
4515
3090
|
};
|
|
4516
3091
|
var DIVE = class _DIVE {
|
|
4517
3092
|
// static members
|
|
4518
|
-
static QuickView(uri
|
|
4519
|
-
const dive = new _DIVE(
|
|
3093
|
+
static QuickView(uri) {
|
|
3094
|
+
const dive = new _DIVE();
|
|
4520
3095
|
dive.Communication.PerformAction("SET_CAMERA_TRANSFORM", {
|
|
4521
3096
|
position: { x: 0, y: 2, z: 2 },
|
|
4522
3097
|
target: { x: 0, y: 0.5, z: 0 }
|
|
@@ -4535,6 +3110,9 @@ var DIVE = class _DIVE {
|
|
|
4535
3110
|
const modelid = (0, import_MathUtils2.generateUUID)();
|
|
4536
3111
|
dive.Communication.Subscribe("MODEL_LOADED", (data) => {
|
|
4537
3112
|
if (data.id !== modelid) return;
|
|
3113
|
+
dive.Communication.PerformAction("PLACE_ON_FLOOR", {
|
|
3114
|
+
id: modelid
|
|
3115
|
+
});
|
|
4538
3116
|
const transform = dive.Communication.PerformAction(
|
|
4539
3117
|
"COMPUTE_ENCOMPASSING_VIEW",
|
|
4540
3118
|
{}
|
|
@@ -4657,36 +3235,9 @@ var DIVE = class _DIVE {
|
|
|
4657
3235
|
console.log(this.scene);
|
|
4658
3236
|
}
|
|
4659
3237
|
};
|
|
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
|
-
`);
|
|
3238
|
+
console.log(
|
|
3239
|
+
`DIVE ${package_default.version} initialized ${false ? "in development mode" : ""}`
|
|
3240
|
+
);
|
|
4690
3241
|
}
|
|
4691
3242
|
Dispose() {
|
|
4692
3243
|
var _a;
|