@shopware-ag/dive 1.6.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/build/dive.cjs +119 -2
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +34 -1
- package/build/dive.d.ts +34 -1
- package/build/dive.js +119 -2
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +6 -0
- package/src/com/Communication.ts +8 -2
- package/src/com/__test__/Communication.test.ts +18 -1
- package/src/controls/OrbitControls.ts +12 -1
- package/src/controls/__test__/OrbitControls.test.ts +5 -0
- package/src/dive.ts +6 -0
- package/src/info/Info.ts +114 -0
- package/src/info/__test__/Info.test.ts +267 -0
package/build/dive.d.cts
CHANGED
|
@@ -122,7 +122,9 @@ declare class DIVEOrbitControls extends OrbitControls {
|
|
|
122
122
|
private stopRevertLast;
|
|
123
123
|
object: DIVEPerspectiveCamera;
|
|
124
124
|
domElement: HTMLCanvasElement;
|
|
125
|
+
private _removePreRenderCallback;
|
|
125
126
|
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings?: DIVEOrbitControlsSettings);
|
|
127
|
+
Dispose(): void;
|
|
126
128
|
ComputeEncompassingView(bb: Box3): {
|
|
127
129
|
position: Vector3Like;
|
|
128
130
|
target: Vector3Like;
|
|
@@ -605,7 +607,8 @@ type Unsubscribe = () => boolean;
|
|
|
605
607
|
declare class DIVECommunication {
|
|
606
608
|
private static __instances;
|
|
607
609
|
static get(id: string): DIVECommunication | undefined;
|
|
608
|
-
private
|
|
610
|
+
private _id;
|
|
611
|
+
get id(): string;
|
|
609
612
|
private renderer;
|
|
610
613
|
private scene;
|
|
611
614
|
private controller;
|
|
@@ -673,6 +676,35 @@ declare const DIVEMath: {
|
|
|
673
676
|
signedAngleTo: typeof signedAngleTo;
|
|
674
677
|
};
|
|
675
678
|
|
|
679
|
+
declare class DIVEInfo {
|
|
680
|
+
private static _supportsWebXR;
|
|
681
|
+
/**
|
|
682
|
+
*
|
|
683
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
684
|
+
*/
|
|
685
|
+
static GetSystem(): string;
|
|
686
|
+
/**
|
|
687
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
688
|
+
*/
|
|
689
|
+
static GetSupportsWebXR(): Promise<boolean>;
|
|
690
|
+
/**
|
|
691
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
692
|
+
*/
|
|
693
|
+
static GetSupportsARQuickLook(): boolean;
|
|
694
|
+
/**
|
|
695
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
696
|
+
*/
|
|
697
|
+
static get isMobile(): boolean;
|
|
698
|
+
/**
|
|
699
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
700
|
+
*/
|
|
701
|
+
static get isDesktop(): boolean;
|
|
702
|
+
/**
|
|
703
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
704
|
+
*/
|
|
705
|
+
static GetIsARCapable(): Promise<boolean>;
|
|
706
|
+
}
|
|
707
|
+
|
|
676
708
|
type DIVESettings = {
|
|
677
709
|
autoResize: boolean;
|
|
678
710
|
displayAxes: boolean;
|
|
@@ -719,6 +751,7 @@ declare class DIVE {
|
|
|
719
751
|
private axisCamera;
|
|
720
752
|
get Communication(): DIVECommunication;
|
|
721
753
|
get Canvas(): HTMLCanvasElement;
|
|
754
|
+
get Info(): DIVEInfo;
|
|
722
755
|
set Settings(settings: Partial<DIVESettings>);
|
|
723
756
|
constructor(settings?: Partial<DIVESettings>);
|
|
724
757
|
Dispose(): void;
|
package/build/dive.d.ts
CHANGED
|
@@ -122,7 +122,9 @@ declare class DIVEOrbitControls extends OrbitControls {
|
|
|
122
122
|
private stopRevertLast;
|
|
123
123
|
object: DIVEPerspectiveCamera;
|
|
124
124
|
domElement: HTMLCanvasElement;
|
|
125
|
+
private _removePreRenderCallback;
|
|
125
126
|
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings?: DIVEOrbitControlsSettings);
|
|
127
|
+
Dispose(): void;
|
|
126
128
|
ComputeEncompassingView(bb: Box3): {
|
|
127
129
|
position: Vector3Like;
|
|
128
130
|
target: Vector3Like;
|
|
@@ -605,7 +607,8 @@ type Unsubscribe = () => boolean;
|
|
|
605
607
|
declare class DIVECommunication {
|
|
606
608
|
private static __instances;
|
|
607
609
|
static get(id: string): DIVECommunication | undefined;
|
|
608
|
-
private
|
|
610
|
+
private _id;
|
|
611
|
+
get id(): string;
|
|
609
612
|
private renderer;
|
|
610
613
|
private scene;
|
|
611
614
|
private controller;
|
|
@@ -673,6 +676,35 @@ declare const DIVEMath: {
|
|
|
673
676
|
signedAngleTo: typeof signedAngleTo;
|
|
674
677
|
};
|
|
675
678
|
|
|
679
|
+
declare class DIVEInfo {
|
|
680
|
+
private static _supportsWebXR;
|
|
681
|
+
/**
|
|
682
|
+
*
|
|
683
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
684
|
+
*/
|
|
685
|
+
static GetSystem(): string;
|
|
686
|
+
/**
|
|
687
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
688
|
+
*/
|
|
689
|
+
static GetSupportsWebXR(): Promise<boolean>;
|
|
690
|
+
/**
|
|
691
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
692
|
+
*/
|
|
693
|
+
static GetSupportsARQuickLook(): boolean;
|
|
694
|
+
/**
|
|
695
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
696
|
+
*/
|
|
697
|
+
static get isMobile(): boolean;
|
|
698
|
+
/**
|
|
699
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
700
|
+
*/
|
|
701
|
+
static get isDesktop(): boolean;
|
|
702
|
+
/**
|
|
703
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
704
|
+
*/
|
|
705
|
+
static GetIsARCapable(): Promise<boolean>;
|
|
706
|
+
}
|
|
707
|
+
|
|
676
708
|
type DIVESettings = {
|
|
677
709
|
autoResize: boolean;
|
|
678
710
|
displayAxes: boolean;
|
|
@@ -719,6 +751,7 @@ declare class DIVE {
|
|
|
719
751
|
private axisCamera;
|
|
720
752
|
get Communication(): DIVECommunication;
|
|
721
753
|
get Canvas(): HTMLCanvasElement;
|
|
754
|
+
get Info(): DIVEInfo;
|
|
722
755
|
set Settings(settings: Partial<DIVESettings>);
|
|
723
756
|
constructor(settings?: Partial<DIVESettings>);
|
|
724
757
|
Dispose(): void;
|
package/build/dive.js
CHANGED
|
@@ -683,7 +683,7 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
683
683
|
this.registered = /* @__PURE__ */ new Map();
|
|
684
684
|
// private listeners: { [key: string]: EventListener[] } = {};
|
|
685
685
|
this.listeners = /* @__PURE__ */ new Map();
|
|
686
|
-
this.
|
|
686
|
+
this._id = generateUUID();
|
|
687
687
|
this.renderer = renderer;
|
|
688
688
|
this.scene = scene;
|
|
689
689
|
this.controller = controls;
|
|
@@ -692,8 +692,13 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
692
692
|
_DIVECommunication.__instances.push(this);
|
|
693
693
|
}
|
|
694
694
|
static get(id) {
|
|
695
|
+
const fromComID = this.__instances.find((instance) => instance.id === id);
|
|
696
|
+
if (fromComID) return fromComID;
|
|
695
697
|
return this.__instances.find((instance) => Array.from(instance.registered.values()).find((object) => object.id === id));
|
|
696
698
|
}
|
|
699
|
+
get id() {
|
|
700
|
+
return this._id;
|
|
701
|
+
}
|
|
697
702
|
get mediaGenerator() {
|
|
698
703
|
if (!this._mediaGenerator) {
|
|
699
704
|
const DIVEMediaCreator2 = (init_MediaCreator(), __toCommonJS(MediaCreator_exports)).DIVEMediaCreator;
|
|
@@ -1564,6 +1569,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1564
1569
|
};
|
|
1565
1570
|
this.stopRevertLast = () => {
|
|
1566
1571
|
};
|
|
1572
|
+
this._removePreRenderCallback = () => {
|
|
1573
|
+
};
|
|
1567
1574
|
this.preRenderCallback = () => {
|
|
1568
1575
|
if (this.locked) return;
|
|
1569
1576
|
this.update();
|
|
@@ -1571,12 +1578,19 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1571
1578
|
this._animationSystem = animationSystem;
|
|
1572
1579
|
this.domElement = renderer.domElement;
|
|
1573
1580
|
this.object = camera;
|
|
1574
|
-
renderer.AddPreRenderCallback(() => {
|
|
1581
|
+
const id = renderer.AddPreRenderCallback(() => {
|
|
1575
1582
|
this.preRenderCallback();
|
|
1576
1583
|
});
|
|
1584
|
+
this._removePreRenderCallback = () => {
|
|
1585
|
+
renderer.RemovePreRenderCallback(id);
|
|
1586
|
+
};
|
|
1577
1587
|
this.enableDamping = settings.enableDamping;
|
|
1578
1588
|
this.dampingFactor = settings.dampingFactor;
|
|
1579
1589
|
}
|
|
1590
|
+
Dispose() {
|
|
1591
|
+
this._removePreRenderCallback();
|
|
1592
|
+
this.dispose();
|
|
1593
|
+
}
|
|
1580
1594
|
ComputeEncompassingView(bb) {
|
|
1581
1595
|
const center = bb.getCenter(new Vector33());
|
|
1582
1596
|
const size = bb.getSize(new Vector33());
|
|
@@ -1925,6 +1939,105 @@ var DIVEMath = {
|
|
|
1925
1939
|
|
|
1926
1940
|
// src/dive.ts
|
|
1927
1941
|
import { generateUUID as generateUUID2 } from "three/src/math/MathUtils";
|
|
1942
|
+
|
|
1943
|
+
// src/info/Info.ts
|
|
1944
|
+
var DIVEInfo = class {
|
|
1945
|
+
/**
|
|
1946
|
+
*
|
|
1947
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
1948
|
+
*/
|
|
1949
|
+
static GetSystem() {
|
|
1950
|
+
const platform = navigator.platform;
|
|
1951
|
+
if (/Android/.test(navigator.userAgent)) {
|
|
1952
|
+
return "Android";
|
|
1953
|
+
} else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
|
|
1954
|
+
return "iOS";
|
|
1955
|
+
} else if (platform.startsWith("Win")) {
|
|
1956
|
+
return "Windows";
|
|
1957
|
+
} else if (platform.startsWith("Mac")) {
|
|
1958
|
+
return "MacOS";
|
|
1959
|
+
} else if (platform.startsWith("Linux")) {
|
|
1960
|
+
return "Linux";
|
|
1961
|
+
} else {
|
|
1962
|
+
return "Unknown";
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
1967
|
+
*/
|
|
1968
|
+
static GetSupportsWebXR() {
|
|
1969
|
+
return __async(this, null, function* () {
|
|
1970
|
+
if (this._supportsWebXR !== null) {
|
|
1971
|
+
return this._supportsWebXR;
|
|
1972
|
+
}
|
|
1973
|
+
if (!navigator.xr) {
|
|
1974
|
+
this._supportsWebXR = false;
|
|
1975
|
+
return this._supportsWebXR;
|
|
1976
|
+
}
|
|
1977
|
+
try {
|
|
1978
|
+
const supported = yield navigator.xr.isSessionSupported("immersive-ar");
|
|
1979
|
+
this._supportsWebXR = supported;
|
|
1980
|
+
} catch (error) {
|
|
1981
|
+
this._supportsWebXR = false;
|
|
1982
|
+
}
|
|
1983
|
+
return this._supportsWebXR;
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
1988
|
+
*/
|
|
1989
|
+
static GetSupportsARQuickLook() {
|
|
1990
|
+
const a = document.createElement("a");
|
|
1991
|
+
if (a.relList.supports("ar")) {
|
|
1992
|
+
return true;
|
|
1993
|
+
}
|
|
1994
|
+
const userAgent = navigator.userAgent;
|
|
1995
|
+
const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
|
|
1996
|
+
if (!isIOS) {
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
const match = userAgent.match(/OS (\d+)_/);
|
|
2000
|
+
if (!match || match.length < 2) {
|
|
2001
|
+
return false;
|
|
2002
|
+
}
|
|
2003
|
+
const iOSVersion = parseInt(match[1], 10);
|
|
2004
|
+
const minQuickLookVersion = 12;
|
|
2005
|
+
if (iOSVersion < minQuickLookVersion) {
|
|
2006
|
+
return false;
|
|
2007
|
+
}
|
|
2008
|
+
const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
|
|
2009
|
+
if (isSupportedBrowser) {
|
|
2010
|
+
return true;
|
|
2011
|
+
}
|
|
2012
|
+
return false;
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
2016
|
+
*/
|
|
2017
|
+
static get isMobile() {
|
|
2018
|
+
return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
|
|
2019
|
+
}
|
|
2020
|
+
/**
|
|
2021
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
2022
|
+
*/
|
|
2023
|
+
static get isDesktop() {
|
|
2024
|
+
return !this.isMobile;
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
2028
|
+
*/
|
|
2029
|
+
static GetIsARCapable() {
|
|
2030
|
+
return __async(this, null, function* () {
|
|
2031
|
+
if (this.GetSupportsARQuickLook()) {
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
2034
|
+
return yield this.GetSupportsWebXR();
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
DIVEInfo._supportsWebXR = null;
|
|
2039
|
+
|
|
2040
|
+
// src/dive.ts
|
|
1928
2041
|
var DIVEDefaultSettings = {
|
|
1929
2042
|
autoResize: true,
|
|
1930
2043
|
displayAxes: false,
|
|
@@ -1988,6 +2101,9 @@ var DIVE = class _DIVE {
|
|
|
1988
2101
|
get Canvas() {
|
|
1989
2102
|
return this.renderer.domElement;
|
|
1990
2103
|
}
|
|
2104
|
+
get Info() {
|
|
2105
|
+
return DIVEInfo;
|
|
2106
|
+
}
|
|
1991
2107
|
// setters
|
|
1992
2108
|
set Settings(settings) {
|
|
1993
2109
|
var _a;
|
|
@@ -2049,6 +2165,7 @@ var DIVE = class _DIVE {
|
|
|
2049
2165
|
var _a;
|
|
2050
2166
|
this.removeResizeObserver();
|
|
2051
2167
|
this.renderer.Dispose();
|
|
2168
|
+
this.orbitControls.Dispose();
|
|
2052
2169
|
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
2053
2170
|
this.animationSystem.Dispose();
|
|
2054
2171
|
this.toolbox.Dispose();
|