@shopware-ag/dive 1.16.26-beta.3 → 1.17.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 +8 -0
- package/build/dive.cjs +133 -110
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +16 -1
- package/build/dive.d.ts +16 -1
- package/build/dive.js +134 -109
- package/build/dive.js.map +1 -1
- package/package.json +3 -2
- package/src/__test__/DIVE.test.ts +2 -2
- package/src/ar/AR.ts +51 -125
- package/src/ar/__test__/AR.test.ts +187 -0
- package/src/ar/arquicklook/ARQuickLook.ts +29 -7
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +268 -0
- package/src/ar/sceneviewer/SceneViewer.ts +74 -0
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +245 -0
- package/src/ar/webxr/controller/WebXRController.ts +17 -11
- package/src/ar/webxr/origin/WebXROrigin.ts +1 -0
- package/src/com/Communication.ts +4 -3
- package/src/com/__test__/Communication.test.ts +47 -2
- package/src/com/actions/index.ts +2 -2
- package/src/com/actions/scene/launchar.ts +7 -0
- package/src/dive.ts +0 -16
- package/src/exporters/usdz/USDZExporter.ts +21 -0
- package/src/group/__test__/Group.test.ts +2 -0
- package/src/scene/__test__/Scene.test.ts +10 -0
- package/src/toolbox/transform/__test__/TransformTool.test.ts +4 -1
package/README.md
CHANGED
|
@@ -305,6 +305,14 @@ DIVECommunication class via
|
|
|
305
305
|
Returns a list of objects of given IDs.
|
|
306
306
|
</td>
|
|
307
307
|
</tr>
|
|
308
|
+
<tr>
|
|
309
|
+
<td>
|
|
310
|
+
<a href="src/com/actions/scene/launchar.ts"> LAUNCH_AR </a>
|
|
311
|
+
</td>
|
|
312
|
+
<td>
|
|
313
|
+
Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)
|
|
314
|
+
</td>
|
|
315
|
+
</tr>
|
|
308
316
|
<tr>
|
|
309
317
|
<td>
|
|
310
318
|
<a href="src/com/actions/object/model/modelloaded.ts"> MODEL_LOADED </a>
|
package/build/dive.cjs
CHANGED
|
@@ -766,26 +766,51 @@ var init_Info = __esm({
|
|
|
766
766
|
}
|
|
767
767
|
});
|
|
768
768
|
|
|
769
|
+
// src/exporters/usdz/USDZExporter.ts
|
|
770
|
+
var import_USDZExporter, DIVEUSDZExporter;
|
|
771
|
+
var init_USDZExporter = __esm({
|
|
772
|
+
"src/exporters/usdz/USDZExporter.ts"() {
|
|
773
|
+
"use strict";
|
|
774
|
+
import_USDZExporter = require("three/examples/jsm/exporters/USDZExporter");
|
|
775
|
+
DIVEUSDZExporter = class extends import_USDZExporter.USDZExporter {
|
|
776
|
+
parse(scene, options) {
|
|
777
|
+
return super.parse(scene, options);
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
|
|
769
783
|
// src/ar/arquicklook/ARQuickLook.ts
|
|
770
|
-
var import_three5,
|
|
784
|
+
var import_three5, DIVEARQuickLook;
|
|
771
785
|
var init_ARQuickLook = __esm({
|
|
772
786
|
"src/ar/arquicklook/ARQuickLook.ts"() {
|
|
773
787
|
"use strict";
|
|
774
788
|
import_three5 = require("three");
|
|
775
|
-
|
|
789
|
+
init_USDZExporter();
|
|
776
790
|
DIVEARQuickLook = class {
|
|
777
|
-
static Launch(scene) {
|
|
791
|
+
static Launch(scene, options) {
|
|
778
792
|
const quickLookScene = new import_three5.Object3D();
|
|
779
793
|
quickLookScene.add(...this.extractModels(scene));
|
|
780
|
-
return this.launchARFromNode(quickLookScene);
|
|
794
|
+
return this.launchARFromNode(quickLookScene, options);
|
|
781
795
|
}
|
|
782
796
|
static extractModels(scene) {
|
|
783
797
|
return scene.Root.children;
|
|
784
798
|
}
|
|
785
|
-
static launchARFromNode(node) {
|
|
786
|
-
return this._usdzExporter.parse(node, {
|
|
799
|
+
static launchARFromNode(node, options) {
|
|
800
|
+
return this._usdzExporter.parse(node, {
|
|
801
|
+
quickLookCompatible: true,
|
|
802
|
+
ar: {
|
|
803
|
+
anchoring: { type: "plane" },
|
|
804
|
+
planeAnchoring: {
|
|
805
|
+
alignment: (options == null ? void 0 : options.arPlacement) === "vertical" ? "vertical" : "horizontal"
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}).then((usdz) => {
|
|
787
809
|
const blob = new Blob([usdz], { type: "model/vnd.usdz+zip" });
|
|
788
|
-
|
|
810
|
+
let url = URL.createObjectURL(blob);
|
|
811
|
+
if ((options == null ? void 0 : options.arScale) === "fixed") {
|
|
812
|
+
url = url.concat("#allowsContentScaling=0");
|
|
813
|
+
}
|
|
789
814
|
const a = document.createElement("a");
|
|
790
815
|
a.innerHTML = "<picture></picture>";
|
|
791
816
|
a.rel = "ar";
|
|
@@ -795,7 +820,7 @@ var init_ARQuickLook = __esm({
|
|
|
795
820
|
});
|
|
796
821
|
}
|
|
797
822
|
};
|
|
798
|
-
DIVEARQuickLook._usdzExporter = new
|
|
823
|
+
DIVEARQuickLook._usdzExporter = new DIVEUSDZExporter();
|
|
799
824
|
}
|
|
800
825
|
});
|
|
801
826
|
|
|
@@ -1621,18 +1646,21 @@ var init_WebXRController = __esm({
|
|
|
1621
1646
|
Update(frame) {
|
|
1622
1647
|
this._frameBuffer = frame;
|
|
1623
1648
|
if (!this._placed) {
|
|
1624
|
-
this.
|
|
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
|
-
);
|
|
1649
|
+
this.updateHandNode();
|
|
1631
1650
|
if (this._origin) {
|
|
1632
1651
|
this._origin.Update(frame);
|
|
1633
1652
|
}
|
|
1634
1653
|
}
|
|
1635
1654
|
}
|
|
1655
|
+
updateHandNode() {
|
|
1656
|
+
this._xrCamera.updateMatrixWorld();
|
|
1657
|
+
this._scene.XRRoot.XRHandNode.position.copy(
|
|
1658
|
+
this._handNodeInitialPosition.clone().applyMatrix4(this._xrCamera.matrixWorld)
|
|
1659
|
+
);
|
|
1660
|
+
this._scene.XRRoot.XRHandNode.quaternion.setFromRotationMatrix(
|
|
1661
|
+
this._xrCamera.matrixWorld
|
|
1662
|
+
);
|
|
1663
|
+
}
|
|
1636
1664
|
// placement
|
|
1637
1665
|
initOrigin() {
|
|
1638
1666
|
return __async(this, null, function* () {
|
|
@@ -1904,6 +1932,54 @@ var init_WebXR = __esm({
|
|
|
1904
1932
|
}
|
|
1905
1933
|
});
|
|
1906
1934
|
|
|
1935
|
+
// src/ar/sceneviewer/SceneViewer.ts
|
|
1936
|
+
var DIVESceneViewer;
|
|
1937
|
+
var init_SceneViewer = __esm({
|
|
1938
|
+
"src/ar/sceneviewer/SceneViewer.ts"() {
|
|
1939
|
+
"use strict";
|
|
1940
|
+
DIVESceneViewer = class {
|
|
1941
|
+
static Launch(scene, options) {
|
|
1942
|
+
const url = this.findSceneViewerSrc(scene);
|
|
1943
|
+
this.launchSceneViewer(url, options);
|
|
1944
|
+
}
|
|
1945
|
+
static launchSceneViewer(url, options) {
|
|
1946
|
+
const anchor = document.createElement("a");
|
|
1947
|
+
const noArViewerSigil = "#model-viewer-no-ar-fallback";
|
|
1948
|
+
const location = self.location.toString();
|
|
1949
|
+
const locationUrl = new URL(location);
|
|
1950
|
+
const modelUrl = new URL(url, location);
|
|
1951
|
+
const params = new URLSearchParams(modelUrl.search);
|
|
1952
|
+
locationUrl.hash = noArViewerSigil;
|
|
1953
|
+
params.set("mode", "ar_only");
|
|
1954
|
+
if ((options == null ? void 0 : options.arScale) === "fixed") {
|
|
1955
|
+
params.set("resizable", "false");
|
|
1956
|
+
}
|
|
1957
|
+
if ((options == null ? void 0 : options.arPlacement) === "vertical") {
|
|
1958
|
+
params.set("enable_vertical_placement", "true");
|
|
1959
|
+
}
|
|
1960
|
+
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(
|
|
1961
|
+
locationUrl.toString()
|
|
1962
|
+
)};end;`;
|
|
1963
|
+
anchor.setAttribute("href", intent);
|
|
1964
|
+
anchor.click();
|
|
1965
|
+
}
|
|
1966
|
+
static findSceneViewerSrc(scene) {
|
|
1967
|
+
let uri = null;
|
|
1968
|
+
scene.traverse((object) => {
|
|
1969
|
+
if (uri) return;
|
|
1970
|
+
if (object.userData.uri) {
|
|
1971
|
+
uri = object.userData.uri;
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
if (!uri) {
|
|
1975
|
+
throw new Error("No model found in scene");
|
|
1976
|
+
}
|
|
1977
|
+
return uri;
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
});
|
|
1982
|
+
|
|
1907
1983
|
// src/ar/AR.ts
|
|
1908
1984
|
var AR_exports = {};
|
|
1909
1985
|
__export(AR_exports, {
|
|
@@ -1916,118 +1992,63 @@ var init_AR = __esm({
|
|
|
1916
1992
|
init_Info();
|
|
1917
1993
|
init_ARQuickLook();
|
|
1918
1994
|
init_WebXR();
|
|
1995
|
+
init_SceneViewer();
|
|
1919
1996
|
DIVEAR = class {
|
|
1920
1997
|
constructor(renderer, scene, controller) {
|
|
1921
|
-
this.arPlacement = "floor";
|
|
1922
|
-
this.arScale = "auto";
|
|
1923
1998
|
this._renderer = renderer;
|
|
1924
1999
|
this._scene = scene;
|
|
1925
2000
|
this._controller = controller;
|
|
1926
2001
|
}
|
|
1927
|
-
Launch() {
|
|
2002
|
+
Launch(options) {
|
|
1928
2003
|
return __async(this, null, function* () {
|
|
1929
2004
|
const system = DIVEInfo.GetSystem();
|
|
1930
2005
|
if (system === "iOS") {
|
|
1931
|
-
|
|
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();
|
|
2006
|
+
return this.tryARQuickLook();
|
|
1939
2007
|
}
|
|
1940
2008
|
if (system === "Android") {
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
if (!support) {
|
|
1945
|
-
console.log(
|
|
1946
|
-
"WebXR not supported. Reason: " + WebXRUnsupportedReason[DIVEInfo.GetWebXRUnsupportedReason()]
|
|
1947
|
-
);
|
|
1948
|
-
return Promise.reject();
|
|
2009
|
+
if (options == null ? void 0 : options.useWebXR) {
|
|
2010
|
+
console.warn("DIVE: WebXR is experimental on Android.");
|
|
2011
|
+
return this.tryWebXR();
|
|
1949
2012
|
}
|
|
1950
|
-
|
|
1951
|
-
yield DIVEWebXR.Launch(
|
|
1952
|
-
this._renderer,
|
|
1953
|
-
this._scene,
|
|
1954
|
-
this._controller
|
|
1955
|
-
);
|
|
1956
|
-
return Promise.resolve();
|
|
2013
|
+
return this.trySceneViewer();
|
|
1957
2014
|
}
|
|
1958
2015
|
console.log(
|
|
1959
|
-
"AR not supported. Not a mobile system. (System is " + system + ")"
|
|
2016
|
+
"DIVE: AR not supported. Not a mobile system. (System is " + system + ")"
|
|
1960
2017
|
);
|
|
1961
2018
|
});
|
|
1962
2019
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
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 version = "1.0";
|
|
1997
|
-
console.log("USING SCENE VIEWER");
|
|
1998
|
-
console.log("version:", version);
|
|
1999
|
-
console.log("params:", params.toString());
|
|
2000
|
-
console.log("modelUrl:", modelUrl.toString());
|
|
2001
|
-
console.log("locationUrl:", locationUrl.toString());
|
|
2002
|
-
const intent = `intent://arvr.google.com/scene-viewer/${version}?${params.toString() + "&file=" + modelUrl.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(
|
|
2003
|
-
locationUrl.toString()
|
|
2004
|
-
)};end;`;
|
|
2005
|
-
console.log({ intent });
|
|
2006
|
-
const undoHashChange = () => {
|
|
2007
|
-
if (self.location.hash === noArViewerSigil) {
|
|
2008
|
-
self.history.back();
|
|
2009
|
-
console.warn(
|
|
2010
|
-
"Error while trying to present in AR with Scene Viewer"
|
|
2011
|
-
);
|
|
2012
|
-
console.warn("Falling back to next ar-mode");
|
|
2020
|
+
tryARQuickLook(options) {
|
|
2021
|
+
return __async(this, null, function* () {
|
|
2022
|
+
const support = DIVEInfo.GetSupportsARQuickLook();
|
|
2023
|
+
if (!support) {
|
|
2024
|
+
console.log("ARQuickLook not supported");
|
|
2025
|
+
return Promise.reject();
|
|
2013
2026
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2027
|
+
console.log("DIVE: Launching AR with ARQuickLook ...");
|
|
2028
|
+
yield DIVEARQuickLook.Launch(this._scene, options);
|
|
2029
|
+
return Promise.resolve();
|
|
2030
|
+
});
|
|
2018
2031
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
if (
|
|
2023
|
-
|
|
2024
|
-
|
|
2032
|
+
tryWebXR() {
|
|
2033
|
+
return __async(this, null, function* () {
|
|
2034
|
+
const support = yield DIVEInfo.GetSupportsWebXR();
|
|
2035
|
+
if (!support) {
|
|
2036
|
+
console.log(
|
|
2037
|
+
"WebXR not supported. Reason: " + WebXRUnsupportedReason[DIVEInfo.GetWebXRUnsupportedReason()]
|
|
2038
|
+
);
|
|
2039
|
+
return Promise.reject();
|
|
2025
2040
|
}
|
|
2041
|
+
console.log("DIVE: Launching AR with WebXR ...");
|
|
2042
|
+
yield DIVEWebXR.Launch(this._renderer, this._scene, this._controller);
|
|
2043
|
+
return Promise.resolve();
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
trySceneViewer(options) {
|
|
2047
|
+
return __async(this, null, function* () {
|
|
2048
|
+
console.log("DIVE: Launching AR with SceneViewer ...");
|
|
2049
|
+
DIVESceneViewer.Launch(this._scene, options);
|
|
2050
|
+
return Promise.resolve();
|
|
2026
2051
|
});
|
|
2027
|
-
if (!uri) {
|
|
2028
|
-
throw new Error("No model found in scene");
|
|
2029
|
-
}
|
|
2030
|
-
return uri;
|
|
2031
2052
|
}
|
|
2032
2053
|
};
|
|
2033
2054
|
}
|
|
@@ -2430,8 +2451,9 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2430
2451
|
break;
|
|
2431
2452
|
}
|
|
2432
2453
|
case "LAUNCH_AR": {
|
|
2433
|
-
this.ar.Launch(
|
|
2434
|
-
|
|
2454
|
+
returnValue = this.ar.Launch(
|
|
2455
|
+
payload
|
|
2456
|
+
);
|
|
2435
2457
|
break;
|
|
2436
2458
|
}
|
|
2437
2459
|
default: {
|
|
@@ -4368,7 +4390,7 @@ init_Info();
|
|
|
4368
4390
|
// package.json
|
|
4369
4391
|
var package_default = {
|
|
4370
4392
|
name: "@shopware-ag/dive",
|
|
4371
|
-
version: "1.
|
|
4393
|
+
version: "1.17.0",
|
|
4372
4394
|
description: "Shopware Spatial Framework",
|
|
4373
4395
|
type: "module",
|
|
4374
4396
|
main: "./build/dive.cjs",
|
|
@@ -4437,7 +4459,8 @@ var package_default = {
|
|
|
4437
4459
|
"generate-readme": "yarn generate-readme:transpile && yarn generate-readme:write && yarn generate-readme:cleanup",
|
|
4438
4460
|
"generate-readme:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/readme/generate-readme.ts && mv ci/readme/generate-readme.js ci/readme/generate-readme.cjs",
|
|
4439
4461
|
"generate-readme:write": "node ci/readme/generate-readme.cjs",
|
|
4440
|
-
"generate-readme:cleanup": `node -e "require('fs').unlinkSync('ci/readme/generate-readme.cjs')"
|
|
4462
|
+
"generate-readme:cleanup": `node -e "require('fs').unlinkSync('ci/readme/generate-readme.cjs')"`,
|
|
4463
|
+
ci: "yarn lint && yarn coverage && yarn prettier:check && yarn build && bash ci/lint/lint-actions.sh"
|
|
4441
4464
|
}
|
|
4442
4465
|
};
|
|
4443
4466
|
|