@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/README.md
CHANGED
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<a href="#badge">
|
|
8
|
-
<img alt="dive:
|
|
8
|
+
<img alt="dive: npm" src="https://img.shields.io/npm/v/%40shopware-ag%2Fdive">
|
|
9
9
|
</a>
|
|
10
10
|
<a href="#badge">
|
|
11
|
-
<img alt="dive:
|
|
11
|
+
<img alt="dive: licenst" src="https://img.shields.io/npm/l/%40shopware-ag%2Fdive">
|
|
12
12
|
</a>
|
|
13
13
|
<a href="#badge">
|
|
14
|
-
<img alt="dive:
|
|
15
|
-
</a>
|
|
16
|
-
<a href="#badge">
|
|
17
|
-
<img alt="dive: downloads" src="https://img.shields.io/npm/types/%40shopware-ag%2Fdive">
|
|
14
|
+
<img alt="dive: types" src="https://img.shields.io/npm/types/%40shopware-ag%2Fdive">
|
|
18
15
|
</a>
|
|
19
16
|
</p>
|
|
20
17
|
|
|
@@ -169,14 +166,14 @@ com.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
|
169
166
|
unsubscribe(); // <-- execute unsubscribe callback when done
|
|
170
167
|
```
|
|
171
168
|
|
|
172
|
-
|
|
169
|
+
# Actions (List)
|
|
170
|
+
In the following you find a list of all available actions to perform on DIVECommunication class via [`com.PerformAction()`](https://github.com/shopware/dive/blob/2e193c58843939ce07a1d35bfbd5b3c9d26eeeca/src/com/Communication.ts#L85).
|
|
173
171
|
|
|
174
172
|
| Action | Description
|
|
175
173
|
|:--------------------------------------------------------------------------------------| :---
|
|
176
174
|
| [GET_ALL_SCENE_DATA](./src/com/actions/scene/getallscenedata.ts) | Return all scene data that is currently set
|
|
177
175
|
| [GET_ALL_OBJECTS](./src/com/actions/object/getallobjects.ts) | Return a map of all objects
|
|
178
176
|
| [GET_OBJECTS](./src/com/actions/object/getobjects.ts) | Return an array of all objects with given ids
|
|
179
|
-
| [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Set a model onto to the floor
|
|
180
177
|
| [ADD_OBJECT](./src/com/actions/object/addobject.ts) | Add an object to the scene
|
|
181
178
|
| [UPDATE_OBJECT](./src/com/actions/object/updateobject.ts) | Update an existing object
|
|
182
179
|
| [DELETE_OBJECT](./src/com/actions/object/deleteobject.ts) | Delete an existing object
|
|
@@ -194,6 +191,7 @@ In the following you find a list of all available actions to perform on DIVEComm
|
|
|
194
191
|
| [ZOOM_CAMERA](./src/com/actions/camera/zoomcamera.ts) | Zoom in or out
|
|
195
192
|
| [SET_GIZMO_MODE](./src/com/actions/toolbox/select/setgizmomode.ts) | Set gizmo mode
|
|
196
193
|
| [SET_GIZMO_VISIBILITY](./src/com/actions/toolbox/select/setgizmovisibility.ts) | Set gizmo visibility
|
|
194
|
+
| [USE_TOOL](./src/com/actions/toolbox/usetool.ts) | Use a specific tool
|
|
197
195
|
| [MODEL_LOADED](./src/com/actions/object/model/modelloaded.ts) | Is performed when a model file is completely loaded
|
|
198
196
|
| [UPDATE_SCENE](./src/com/actions/scene/updatescene.ts) | Update scene data
|
|
199
197
|
| [GENERATE_MEDIA](./src/com/actions/media/generatemedia.ts) | Generate a screenshot with the specified parameters
|
package/build/dive.cjs
CHANGED
|
@@ -705,7 +705,7 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
705
705
|
this.registered = /* @__PURE__ */ new Map();
|
|
706
706
|
// private listeners: { [key: string]: EventListener[] } = {};
|
|
707
707
|
this.listeners = /* @__PURE__ */ new Map();
|
|
708
|
-
this.
|
|
708
|
+
this._id = (0, import_MathUtils.generateUUID)();
|
|
709
709
|
this.renderer = renderer;
|
|
710
710
|
this.scene = scene;
|
|
711
711
|
this.controller = controls;
|
|
@@ -714,8 +714,13 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
714
714
|
_DIVECommunication.__instances.push(this);
|
|
715
715
|
}
|
|
716
716
|
static get(id) {
|
|
717
|
+
const fromComID = this.__instances.find((instance) => instance.id === id);
|
|
718
|
+
if (fromComID) return fromComID;
|
|
717
719
|
return this.__instances.find((instance) => Array.from(instance.registered.values()).find((object) => object.id === id));
|
|
718
720
|
}
|
|
721
|
+
get id() {
|
|
722
|
+
return this._id;
|
|
723
|
+
}
|
|
719
724
|
get mediaGenerator() {
|
|
720
725
|
if (!this._mediaGenerator) {
|
|
721
726
|
const DIVEMediaCreator2 = (init_MediaCreator(), __toCommonJS(MediaCreator_exports)).DIVEMediaCreator;
|
|
@@ -1586,6 +1591,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
|
|
|
1586
1591
|
};
|
|
1587
1592
|
this.stopRevertLast = () => {
|
|
1588
1593
|
};
|
|
1594
|
+
this._removePreRenderCallback = () => {
|
|
1595
|
+
};
|
|
1589
1596
|
this.preRenderCallback = () => {
|
|
1590
1597
|
if (this.locked) return;
|
|
1591
1598
|
this.update();
|
|
@@ -1593,12 +1600,19 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
|
|
|
1593
1600
|
this._animationSystem = animationSystem;
|
|
1594
1601
|
this.domElement = renderer.domElement;
|
|
1595
1602
|
this.object = camera;
|
|
1596
|
-
renderer.AddPreRenderCallback(() => {
|
|
1603
|
+
const id = renderer.AddPreRenderCallback(() => {
|
|
1597
1604
|
this.preRenderCallback();
|
|
1598
1605
|
});
|
|
1606
|
+
this._removePreRenderCallback = () => {
|
|
1607
|
+
renderer.RemovePreRenderCallback(id);
|
|
1608
|
+
};
|
|
1599
1609
|
this.enableDamping = settings.enableDamping;
|
|
1600
1610
|
this.dampingFactor = settings.dampingFactor;
|
|
1601
1611
|
}
|
|
1612
|
+
Dispose() {
|
|
1613
|
+
this._removePreRenderCallback();
|
|
1614
|
+
this.dispose();
|
|
1615
|
+
}
|
|
1602
1616
|
ComputeEncompassingView(bb) {
|
|
1603
1617
|
const center = bb.getCenter(new import_three14.Vector3());
|
|
1604
1618
|
const size = bb.getSize(new import_three14.Vector3());
|
|
@@ -1947,6 +1961,105 @@ var DIVEMath = {
|
|
|
1947
1961
|
|
|
1948
1962
|
// src/dive.ts
|
|
1949
1963
|
var import_MathUtils2 = require("three/src/math/MathUtils");
|
|
1964
|
+
|
|
1965
|
+
// src/info/Info.ts
|
|
1966
|
+
var DIVEInfo = class {
|
|
1967
|
+
/**
|
|
1968
|
+
*
|
|
1969
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
1970
|
+
*/
|
|
1971
|
+
static GetSystem() {
|
|
1972
|
+
const platform = navigator.platform;
|
|
1973
|
+
if (/Android/.test(navigator.userAgent)) {
|
|
1974
|
+
return "Android";
|
|
1975
|
+
} else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
|
|
1976
|
+
return "iOS";
|
|
1977
|
+
} else if (platform.startsWith("Win")) {
|
|
1978
|
+
return "Windows";
|
|
1979
|
+
} else if (platform.startsWith("Mac")) {
|
|
1980
|
+
return "MacOS";
|
|
1981
|
+
} else if (platform.startsWith("Linux")) {
|
|
1982
|
+
return "Linux";
|
|
1983
|
+
} else {
|
|
1984
|
+
return "Unknown";
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
1989
|
+
*/
|
|
1990
|
+
static GetSupportsWebXR() {
|
|
1991
|
+
return __async(this, null, function* () {
|
|
1992
|
+
if (this._supportsWebXR !== null) {
|
|
1993
|
+
return this._supportsWebXR;
|
|
1994
|
+
}
|
|
1995
|
+
if (!navigator.xr) {
|
|
1996
|
+
this._supportsWebXR = false;
|
|
1997
|
+
return this._supportsWebXR;
|
|
1998
|
+
}
|
|
1999
|
+
try {
|
|
2000
|
+
const supported = yield navigator.xr.isSessionSupported("immersive-ar");
|
|
2001
|
+
this._supportsWebXR = supported;
|
|
2002
|
+
} catch (error) {
|
|
2003
|
+
this._supportsWebXR = false;
|
|
2004
|
+
}
|
|
2005
|
+
return this._supportsWebXR;
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
/**
|
|
2009
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
2010
|
+
*/
|
|
2011
|
+
static GetSupportsARQuickLook() {
|
|
2012
|
+
const a = document.createElement("a");
|
|
2013
|
+
if (a.relList.supports("ar")) {
|
|
2014
|
+
return true;
|
|
2015
|
+
}
|
|
2016
|
+
const userAgent = navigator.userAgent;
|
|
2017
|
+
const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
|
|
2018
|
+
if (!isIOS) {
|
|
2019
|
+
return false;
|
|
2020
|
+
}
|
|
2021
|
+
const match = userAgent.match(/OS (\d+)_/);
|
|
2022
|
+
if (!match || match.length < 2) {
|
|
2023
|
+
return false;
|
|
2024
|
+
}
|
|
2025
|
+
const iOSVersion = parseInt(match[1], 10);
|
|
2026
|
+
const minQuickLookVersion = 12;
|
|
2027
|
+
if (iOSVersion < minQuickLookVersion) {
|
|
2028
|
+
return false;
|
|
2029
|
+
}
|
|
2030
|
+
const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
|
|
2031
|
+
if (isSupportedBrowser) {
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
2034
|
+
return false;
|
|
2035
|
+
}
|
|
2036
|
+
/**
|
|
2037
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
2038
|
+
*/
|
|
2039
|
+
static get isMobile() {
|
|
2040
|
+
return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
2044
|
+
*/
|
|
2045
|
+
static get isDesktop() {
|
|
2046
|
+
return !this.isMobile;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
2050
|
+
*/
|
|
2051
|
+
static GetIsARCapable() {
|
|
2052
|
+
return __async(this, null, function* () {
|
|
2053
|
+
if (this.GetSupportsARQuickLook()) {
|
|
2054
|
+
return true;
|
|
2055
|
+
}
|
|
2056
|
+
return yield this.GetSupportsWebXR();
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
DIVEInfo._supportsWebXR = null;
|
|
2061
|
+
|
|
2062
|
+
// src/dive.ts
|
|
1950
2063
|
var DIVEDefaultSettings = {
|
|
1951
2064
|
autoResize: true,
|
|
1952
2065
|
displayAxes: false,
|
|
@@ -2010,6 +2123,9 @@ var DIVE = class _DIVE {
|
|
|
2010
2123
|
get Canvas() {
|
|
2011
2124
|
return this.renderer.domElement;
|
|
2012
2125
|
}
|
|
2126
|
+
get Info() {
|
|
2127
|
+
return DIVEInfo;
|
|
2128
|
+
}
|
|
2013
2129
|
// setters
|
|
2014
2130
|
set Settings(settings) {
|
|
2015
2131
|
var _a;
|
|
@@ -2071,6 +2187,7 @@ var DIVE = class _DIVE {
|
|
|
2071
2187
|
var _a;
|
|
2072
2188
|
this.removeResizeObserver();
|
|
2073
2189
|
this.renderer.Dispose();
|
|
2190
|
+
this.orbitControls.Dispose();
|
|
2074
2191
|
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
2075
2192
|
this.animationSystem.Dispose();
|
|
2076
2193
|
this.toolbox.Dispose();
|