@shopware-ag/dive 1.6.5 → 1.8.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 CHANGED
@@ -5,16 +5,13 @@
5
5
 
6
6
  <p align="center">
7
7
  <a href="#badge">
8
- <img alt="dive: downloads" src="https://img.shields.io/npm/v/%40shopware-ag%2Fdive">
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: downloads" src="https://img.shields.io/npm/d18m/%40shopware-ag%2Fdive">
11
+ <img alt="dive: license" src="https://img.shields.io/npm/l/%40shopware-ag%2Fdive">
12
12
  </a>
13
13
  <a href="#badge">
14
- <img alt="dive: downloads" src="https://img.shields.io/npm/l/%40shopware-ag%2Fdive">
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
- In the following you find a list of all available actions to perform on DIVECommunication class via `com.PerformAction()`.
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
@@ -460,7 +460,12 @@ var init_PerspectiveCamera = __esm({
460
460
  };
461
461
  _DIVEPerspectiveCamera = class _DIVEPerspectiveCamera extends import_three4.PerspectiveCamera {
462
462
  constructor(settings = DIVEPerspectiveCameraDefaultSettings) {
463
- super(settings.fov, 1, settings.near, settings.far);
463
+ super(
464
+ settings.fov || DIVEPerspectiveCameraDefaultSettings.fov,
465
+ 1,
466
+ settings.near || DIVEPerspectiveCameraDefaultSettings.near,
467
+ settings.far || DIVEPerspectiveCameraDefaultSettings.far
468
+ );
464
469
  this.onSetCameraLayer = () => {
465
470
  };
466
471
  this.layers.mask = _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
@@ -546,14 +551,16 @@ var DIVERendererDefaultSettings = {
546
551
  stencil: false,
547
552
  shadowMapEnabled: true,
548
553
  shadowMapType: import_three.PCFSoftShadowMap,
549
- toneMapping: import_three.NoToneMapping
554
+ toneMapping: import_three.NoToneMapping,
555
+ canvas: void 0
550
556
  };
551
557
  var DIVERenderer = class extends import_three.WebGLRenderer {
552
558
  constructor(rendererSettings = DIVERendererDefaultSettings) {
553
559
  super({
554
- antialias: rendererSettings.antialias,
555
- alpha: rendererSettings.alpha,
556
- preserveDrawingBuffer: true
560
+ antialias: rendererSettings.antialias || DIVERendererDefaultSettings.antialias,
561
+ alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha,
562
+ preserveDrawingBuffer: true,
563
+ canvas: rendererSettings.canvas
557
564
  });
558
565
  // basic functionality members
559
566
  this.paused = false;
@@ -563,9 +570,9 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
563
570
  this.preRenderCallbacks = /* @__PURE__ */ new Map();
564
571
  this.postRenderCallbacks = /* @__PURE__ */ new Map();
565
572
  this.setPixelRatio(window.devicePixelRatio);
566
- this.shadowMap.enabled = rendererSettings.shadowMapEnabled;
567
- this.shadowMap.type = rendererSettings.shadowMapType;
568
- this.toneMapping = rendererSettings.toneMapping;
573
+ this.shadowMap.enabled = rendererSettings.shadowMapEnabled || DIVERendererDefaultSettings.shadowMapEnabled;
574
+ this.shadowMap.type = rendererSettings.shadowMapType || DIVERendererDefaultSettings.shadowMapType;
575
+ this.toneMapping = rendererSettings.toneMapping || DIVERendererDefaultSettings.toneMapping;
569
576
  this.debug.checkShaderErrors = false;
570
577
  }
571
578
  // Stops renderings and disposes the renderer.
@@ -1574,14 +1581,14 @@ var DIVEScene = class extends import_three13.Scene {
1574
1581
  init_PerspectiveCamera();
1575
1582
 
1576
1583
  // src/controls/OrbitControls.ts
1577
- var import_Addons3 = require("three/examples/jsm/Addons.js");
1584
+ var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
1578
1585
  var import_three14 = require("three");
1579
1586
  var import_tween = require("@tweenjs/tween.js");
1580
1587
  var DIVEOrbitControlsDefaultSettings = {
1581
1588
  enableDamping: true,
1582
1589
  dampingFactor: 0.04
1583
1590
  };
1584
- var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitControls {
1591
+ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.OrbitControls {
1585
1592
  constructor(camera, renderer, animationSystem, settings = DIVEOrbitControlsDefaultSettings) {
1586
1593
  super(camera, renderer.domElement);
1587
1594
  this.last = null;
@@ -1606,8 +1613,11 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
1606
1613
  this._removePreRenderCallback = () => {
1607
1614
  renderer.RemovePreRenderCallback(id);
1608
1615
  };
1609
- this.enableDamping = settings.enableDamping;
1610
- this.dampingFactor = settings.dampingFactor;
1616
+ this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping;
1617
+ this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor;
1618
+ this.object.position.set(0, 2, 2);
1619
+ this.target.copy({ x: 0, y: 0.5, z: 0 });
1620
+ this.update();
1611
1621
  }
1612
1622
  Dispose() {
1613
1623
  this._removePreRenderCallback();
@@ -1961,6 +1971,105 @@ var DIVEMath = {
1961
1971
 
1962
1972
  // src/dive.ts
1963
1973
  var import_MathUtils2 = require("three/src/math/MathUtils");
1974
+
1975
+ // src/info/Info.ts
1976
+ var DIVEInfo = class {
1977
+ /**
1978
+ *
1979
+ * @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
1980
+ */
1981
+ static GetSystem() {
1982
+ const platform = navigator.platform;
1983
+ if (/Android/.test(navigator.userAgent)) {
1984
+ return "Android";
1985
+ } else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
1986
+ return "iOS";
1987
+ } else if (platform.startsWith("Win")) {
1988
+ return "Windows";
1989
+ } else if (platform.startsWith("Mac")) {
1990
+ return "MacOS";
1991
+ } else if (platform.startsWith("Linux")) {
1992
+ return "Linux";
1993
+ } else {
1994
+ return "Unknown";
1995
+ }
1996
+ }
1997
+ /**
1998
+ * @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
1999
+ */
2000
+ static GetSupportsWebXR() {
2001
+ return __async(this, null, function* () {
2002
+ if (this._supportsWebXR !== null) {
2003
+ return this._supportsWebXR;
2004
+ }
2005
+ if (!navigator.xr) {
2006
+ this._supportsWebXR = false;
2007
+ return this._supportsWebXR;
2008
+ }
2009
+ try {
2010
+ const supported = yield navigator.xr.isSessionSupported("immersive-ar");
2011
+ this._supportsWebXR = supported;
2012
+ } catch (error) {
2013
+ this._supportsWebXR = false;
2014
+ }
2015
+ return this._supportsWebXR;
2016
+ });
2017
+ }
2018
+ /**
2019
+ * @returns A boolean indicating whether the user's device supports AR Quick Look.
2020
+ */
2021
+ static GetSupportsARQuickLook() {
2022
+ const a = document.createElement("a");
2023
+ if (a.relList.supports("ar")) {
2024
+ return true;
2025
+ }
2026
+ const userAgent = navigator.userAgent;
2027
+ const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
2028
+ if (!isIOS) {
2029
+ return false;
2030
+ }
2031
+ const match = userAgent.match(/OS (\d+)_/);
2032
+ if (!match || match.length < 2) {
2033
+ return false;
2034
+ }
2035
+ const iOSVersion = parseInt(match[1], 10);
2036
+ const minQuickLookVersion = 12;
2037
+ if (iOSVersion < minQuickLookVersion) {
2038
+ return false;
2039
+ }
2040
+ const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
2041
+ if (isSupportedBrowser) {
2042
+ return true;
2043
+ }
2044
+ return false;
2045
+ }
2046
+ /**
2047
+ * @returns A boolean indicating whether the user's device is a mobile device.
2048
+ */
2049
+ static get isMobile() {
2050
+ return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
2051
+ }
2052
+ /**
2053
+ * @returns A boolean indicating whether the user's device is a desktop device.
2054
+ */
2055
+ static get isDesktop() {
2056
+ return !this.isMobile;
2057
+ }
2058
+ /**
2059
+ * @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
2060
+ */
2061
+ static GetIsARCapable() {
2062
+ return __async(this, null, function* () {
2063
+ if (this.GetSupportsARQuickLook()) {
2064
+ return true;
2065
+ }
2066
+ return yield this.GetSupportsWebXR();
2067
+ });
2068
+ }
2069
+ };
2070
+ DIVEInfo._supportsWebXR = null;
2071
+
2072
+ // src/dive.ts
1964
2073
  var DIVEDefaultSettings = {
1965
2074
  autoResize: true,
1966
2075
  displayAxes: false,
@@ -2024,20 +2133,23 @@ var DIVE = class _DIVE {
2024
2133
  get Canvas() {
2025
2134
  return this.renderer.domElement;
2026
2135
  }
2136
+ get Info() {
2137
+ return DIVEInfo;
2138
+ }
2027
2139
  // setters
2028
2140
  set Settings(settings) {
2029
2141
  var _a;
2030
2142
  const settingsDelta = getObjectDelta(this._settings, settings);
2031
2143
  if (settingsDelta.renderer) this.renderer = new DIVERenderer(this._settings.renderer);
2032
2144
  if (settingsDelta.perspectiveCamera) {
2033
- this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
2034
- this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
2035
- this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
2145
+ if (settingsDelta.perspectiveCamera.fov !== void 0) this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
2146
+ if (settingsDelta.perspectiveCamera.near !== void 0) this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
2147
+ if (settingsDelta.perspectiveCamera.far !== void 0) this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
2036
2148
  this.perspectiveCamera.OnResize(this.renderer.domElement.width, this.renderer.domElement.height);
2037
2149
  }
2038
2150
  if (settingsDelta.orbitControls) {
2039
- this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
2040
- this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
2151
+ if (settingsDelta.orbitControls.enableDamping !== void 0) this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
2152
+ if (settingsDelta.orbitControls.dampingFactor !== void 0) this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
2041
2153
  }
2042
2154
  if (settingsDelta.autoResize !== this._settings.autoResize) {
2043
2155
  if (settingsDelta.autoResize) {
@@ -2080,6 +2192,7 @@ var DIVE = class _DIVE {
2080
2192
  console.log(this.scene);
2081
2193
  }
2082
2194
  };
2195
+ console.log("DIVE initialized");
2083
2196
  }
2084
2197
  Dispose() {
2085
2198
  var _a;