@shopware-ag/dive 2.0.3 → 2.1.1
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 +0 -1
- package/build/chunks/{AssetCache-DNwNkGms.cjs → AssetCache-B02vAmfm.cjs} +1 -1
- package/build/chunks/{AssetCache-BpdA1GQf.mjs → AssetCache-DP95DtBA.mjs} +1 -1
- package/build/chunks/{AssetLoader-DJKZltSW.mjs → AssetLoader-BOnrkFcl.mjs} +2 -2
- package/build/chunks/{AssetLoader-Ct1Lh-P1.cjs → AssetLoader-C6MLrKu2.cjs} +1 -1
- package/build/chunks/FileTypes-BobMthbh.cjs +29 -0
- package/build/chunks/FileTypes-D5zw1toN.mjs +1884 -0
- package/build/chunks/PerspectiveCamera-8tnOn5YS.mjs +39 -0
- package/build/chunks/PerspectiveCamera-Dp8ElZGj.cjs +1 -0
- package/build/chunks/{SelectTool-DxVRSIoF.mjs → SelectTool-BNZdhIaO.mjs} +2 -2
- package/build/chunks/SelectTool-J55L_APQ.cjs +1 -0
- package/build/{src/components → components}/index.d.ts +1 -0
- package/build/{src/components → components}/model/Model.d.ts +3 -2
- package/build/dive.cjs +1 -1
- package/build/dive.d.ts +1 -1
- package/build/dive.mjs +69 -68
- package/build/engine/AsciiArt.d.ts +1 -0
- package/build/engine/Dive.d.ts +98 -0
- package/build/{src/engine → engine}/camera/PerspectiveCamera.d.ts +1 -0
- package/build/{src/engine → engine}/clock/Clock.d.ts +1 -4
- package/build/{src/engine → engine}/index.d.ts +2 -1
- package/build/{src/engine → engine}/renderer/Renderer.d.ts +12 -5
- package/build/{src/engine → engine}/resize/ResizeManager.d.ts +5 -2
- package/build/engine/scene/Scene.d.ts +41 -0
- package/build/{src/engine → engine}/scene/xrroot/XRRoot.d.ts +2 -2
- package/build/{src/engine → engine}/scene/xrroot/xrlightroot/XRLightRoot.d.ts +2 -2
- package/build/engine/view/View.d.ts +24 -0
- package/build/{src/index.d.ts → index.d.ts} +1 -1
- package/build/plugins/animation/index.cjs +1 -1
- package/build/plugins/animation/index.d.ts +2 -2
- package/build/plugins/animation/index.mjs +11 -11
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.d.ts +4 -2
- package/build/plugins/ar/index.mjs +1 -1
- package/build/{src/plugins → plugins}/ar/src/webxr/WebXR.d.ts +2 -2
- package/build/{src/plugins → plugins}/ar/src/webxr/controller/WebXRController.d.ts +2 -2
- package/build/{src/plugins → plugins}/ar/src/webxr/origin/WebXROrigin.d.ts +2 -2
- package/build/{src/plugins → plugins}/ar/src/webxr/raycaster/WebXRRaycaster.d.ts +2 -2
- package/build/{src/plugins → plugins}/ar/src/webxr/raycaster/ar/WebXRRaycasterAR.d.ts +2 -2
- package/build/{src/plugins → plugins}/ar/src/webxr/raycaster/three/WebXRRaycasterTHREE.d.ts +2 -2
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.d.ts +1 -2
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetconverter/index.d.ts +1 -2
- package/build/plugins/assetexporter/index.d.ts +1 -2
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.d.ts +3 -2
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.d.ts +2 -2
- package/build/plugins/mediacreator/index.mjs +8 -8
- package/build/{src/plugins → plugins}/mediacreator/src/MediaCreator.d.ts +2 -2
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.d.ts +1 -2
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orbitcontroller/src/OrbitController.d.ts +195 -0
- package/build/plugins/orbitcontroller/types/OrbitControllerState.types.d.ts +9 -0
- package/build/plugins/orbitcontroller/types/index.d.ts +1 -0
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.d.ts +2 -2
- package/build/plugins/orientationdisplay/index.mjs +1 -1
- package/build/{src/plugins → plugins}/orientationdisplay/src/OrientationDisplay.d.ts +2 -2
- package/build/plugins/quickview/index.cjs +1 -0
- package/build/plugins/quickview/index.d.ts +2 -0
- package/build/plugins/quickview/index.mjs +22 -0
- package/build/plugins/quickview/src/QuickView.d.ts +14 -0
- package/build/plugins/quickview/types/QuickViewSettings.d.ts +4 -0
- package/build/plugins/quickview/types/index.d.ts +1 -0
- package/build/plugins/state/index.cjs +7 -7
- package/build/plugins/state/index.d.ts +4 -2
- package/build/plugins/state/index.mjs +310 -316
- package/build/{src/plugins → plugins}/state/src/State.d.ts +2 -2
- package/build/{src/plugins → plugins}/state/src/actions/media/generatemedia.d.ts +1 -1
- package/build/{src/plugins → plugins}/state/types/ActionTypes.d.ts +2 -2
- package/build/plugins/systeminfo/index.d.ts +2 -2
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.d.ts +5 -2
- package/build/plugins/toolbox/index.mjs +2 -2
- package/package.json +6 -1
- package/build/chunks/FileTypes-BawiSSTm.mjs +0 -1059
- package/build/chunks/FileTypes-DYdmsV-9.cjs +0 -30
- package/build/chunks/MathUtils-CBW56ZuG.cjs +0 -1
- package/build/chunks/MathUtils-CFGjHuVF.mjs +0 -159
- package/build/chunks/OrbitController-BQ6SV1O_.mjs +0 -1159
- package/build/chunks/OrbitController-CpFQ3A1H.cjs +0 -1
- package/build/chunks/PerspectiveCamera-BByyG5R4.cjs +0 -1
- package/build/chunks/PerspectiveCamera-PMJPzAn3.mjs +0 -34
- package/build/chunks/SelectTool-bi-2zWyT.cjs +0 -1
- package/build/chunks/VisibilityLayerMask-BI7jPKdx.cjs +0 -1
- package/build/chunks/VisibilityLayerMask-CXgt1fJc.mjs +0 -8
- package/build/chunks/package-Cfclzhv-.cjs +0 -1
- package/build/chunks/package-YeeRzGDk.mjs +0 -39
- package/build/src/core/Dive.d.ts +0 -58
- package/build/src/core/index.d.ts +0 -1
- package/build/src/engine/Engine.d.ts +0 -28
- package/build/src/engine/scene/Scene.d.ts +0 -19
- package/build/src/plugins/animation/index.d.ts +0 -2
- package/build/src/plugins/ar/index.d.ts +0 -4
- package/build/src/plugins/assetcache/index.d.ts +0 -1
- package/build/src/plugins/assetconverter/index.d.ts +0 -1
- package/build/src/plugins/assetexporter/index.d.ts +0 -1
- package/build/src/plugins/assetloader/index.d.ts +0 -3
- package/build/src/plugins/mediacreator/index.d.ts +0 -2
- package/build/src/plugins/orbitcontroller/index.d.ts +0 -1
- package/build/src/plugins/orbitcontroller/src/OrbitController.d.ts +0 -45
- package/build/src/plugins/orientationdisplay/index.d.ts +0 -2
- package/build/src/plugins/state/index.d.ts +0 -4
- package/build/src/plugins/systeminfo/index.d.ts +0 -2
- package/build/src/plugins/toolbox/index.d.ts +0 -5
- /package/build/{src/components → components}/boundingbox/BoundingBox.d.ts +0 -0
- /package/build/{src/components → components}/floor/Floor.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/Gizmo.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/handles/AxisHandle.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/handles/RadialHandle.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/handles/ScaleHandle.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/plane/GizmoPlane.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/rotate/RotateGizmo.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/scale/ScaleGizmo.d.ts +0 -0
- /package/build/{src/components → components}/gizmo/translate/TranslateGizmo.d.ts +0 -0
- /package/build/{src/components → components}/grid/Grid.d.ts +0 -0
- /package/build/{src/components → components}/group/Group.d.ts +0 -0
- /package/build/{src/components → components}/light/AmbientLight.d.ts +0 -0
- /package/build/{src/components → components}/light/PointLight.d.ts +0 -0
- /package/build/{src/components → components}/light/SceneLight.d.ts +0 -0
- /package/build/{src/components → components}/light/index.d.ts +0 -0
- /package/build/{src/components → components}/node/Node.d.ts +0 -0
- /package/build/{src/components → components}/primitive/Primitive.d.ts +0 -0
- /package/build/{src/components → components}/root/Root.d.ts +0 -0
- /package/build/{src/constants → constants}/AxisHelperColors.d.ts +0 -0
- /package/build/{src/constants → constants}/GridColors.d.ts +0 -0
- /package/build/{src/constants → constants}/VisibilityLayerMask.d.ts +0 -0
- /package/build/{src/constants → constants}/index.d.ts +0 -0
- /package/build/{src/error → error}/file-content/file-content-error.d.ts +0 -0
- /package/build/{src/error → error}/file-type/file-type-error.d.ts +0 -0
- /package/build/{src/error → error}/index.d.ts +0 -0
- /package/build/{src/error → error}/network/network-error.d.ts +0 -0
- /package/build/{src/error → error}/parse/parse-error.d.ts +0 -0
- /package/build/{src/events → events}/dispatcher/EventDispatcher.d.ts +0 -0
- /package/build/{src/events → events}/index.d.ts +0 -0
- /package/build/{src/helpers → helpers}/applyMixins/applyMixins.d.ts +0 -0
- /package/build/{src/helpers → helpers}/deepClone/deepClone.d.ts +0 -0
- /package/build/{src/helpers → helpers}/findInterface/findInterface.d.ts +0 -0
- /package/build/{src/helpers → helpers}/findSceneRecursive/findSceneRecursive.d.ts +0 -0
- /package/build/{src/helpers → helpers}/getFileTypeFromUri/getFileTypeFromUri.d.ts +0 -0
- /package/build/{src/helpers → helpers}/getObjectDelta/getObjectDelta.d.ts +0 -0
- /package/build/{src/helpers → helpers}/implementsInterface/implementsInterface.d.ts +0 -0
- /package/build/{src/helpers → helpers}/index.d.ts +0 -0
- /package/build/{src/helpers → helpers}/isFileTypeSupported/isFileTypeSupported.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/ceil/ceilExp.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/degToRad/degToRad.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/floor/floorExp.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/helper/shift.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/index.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/radToDeg/radToDeg.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/round/roundExp.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/signedAngleTo/signedAngleTo.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/toFixed/toFixedExp.d.ts +0 -0
- /package/build/{src/helpers → helpers}/math/truncate/truncateExp.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/Draggable.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/Hoverable.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/Movable.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/Rotatable.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/Scalable.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/Selectable.d.ts +0 -0
- /package/build/{src/interfaces → interfaces}/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/animation/src/animator/Animator.d.ts +0 -0
- /package/build/{src/plugins → plugins}/animation/src/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/animation/src/system/AnimationSystem.d.ts +0 -0
- /package/build/{src/plugins → plugins}/animation/src/types/AnimatorParameters.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/ARSystem.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/arquicklook/ARQuickLook.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/error/ar-errors.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/sceneviewer/SceneViewer.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/webxr/crosshair/WebXRCrosshair.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/webxr/overlay/Overlay.d.ts +0 -0
- /package/build/{src/plugins → plugins}/ar/src/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetcache/src/cache/AssetCache.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetcache/src/chunk/Chunk.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetcache/src/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetconverter/src/AssetConverter.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetexporter/src/AssetExporter.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetloader/src/draco/DracoLoader.d.ts +0 -0
- /package/build/{src/plugins → plugins}/assetloader/src/loader/AssetLoader.d.ts +0 -0
- /package/build/{src/plugins → plugins}/mediacreator/types/MediaGenerationById.d.ts +0 -0
- /package/build/{src/plugins → plugins}/mediacreator/types/MediaGenerationByPosition.d.ts +0 -0
- /package/build/{src/plugins → plugins}/mediacreator/types/MediaGenerationResolution.d.ts +0 -0
- /package/build/{src/plugins → plugins}/mediacreator/types/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/orientationdisplay/src/axes/Axes.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/ActionRegistry.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/action.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/ar/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/ar/launchar.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/computeencompassingview.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/getcameratransform.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/lockcamera.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/movecamera.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/setcameralayer.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/setcameratransform.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/camera/zoomcamera.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/media/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/addobject.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/deleteobject.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/deselectobject.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/dropit.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/getallobjects.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/getobjects.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/modelloaded.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/placeonfloor.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/selectobject.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/setparent.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/object/updateobject.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/renderer/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/renderer/startrender.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/scene/exportscene.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/scene/getallscenedata.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/scene/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/scene/setbackground.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/scene/updatescene.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/toolbox/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/toolbox/setgizmomode.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/toolbox/setgizmoscalelinked.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/toolbox/setgizmovisible.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/src/actions/toolbox/usetool.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/types/StateExportFileType.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/types/StateSceneData.d.ts +0 -0
- /package/build/{src/plugins → plugins}/state/types/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/systeminfo/src/SystemInfo.d.ts +0 -0
- /package/build/{src/plugins → plugins}/systeminfo/types/index.d.ts +0 -0
- /package/build/{src/plugins → plugins}/toolbox/src/BaseTool.d.ts +0 -0
- /package/build/{src/plugins → plugins}/toolbox/src/Toolbox.d.ts +0 -0
- /package/build/{src/plugins → plugins}/toolbox/src/select/SelectTool.d.ts +0 -0
- /package/build/{src/plugins → plugins}/toolbox/src/transform/TransformTool.d.ts +0 -0
- /package/build/{src/plugins → plugins}/toolbox/types/ToolType.d.ts +0 -0
- /package/build/{src/plugins → plugins}/toolbox/types/index.d.ts +0 -0
- /package/build/{src/types → types}/components/DIVELight.d.ts +0 -0
- /package/build/{src/types → types}/components/DIVESceneObject.d.ts +0 -0
- /package/build/{src/types → types}/components/index.d.ts +0 -0
- /package/build/{src/types → types}/file/FileTypes.d.ts +0 -0
- /package/build/{src/types → types}/file/index.d.ts +0 -0
- /package/build/{src/types → types}/index.d.ts +0 -0
- /package/build/{src/types → types}/schema/BaseEntitySchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/EntitySchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/EntityTypeSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/GeometrySchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/GeometryTypeSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/GroupSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/LightSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/MaterialSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/ModelSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/PovSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/PrimitiveSchema.d.ts +0 -0
- /package/build/{src/types → types}/schema/index.d.ts +0 -0
|
@@ -0,0 +1,1884 @@
|
|
|
1
|
+
var $ = Object.defineProperty;
|
|
2
|
+
var j = (r, s, t) => s in r ? $(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
|
+
var i = (r, s, t) => j(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { WebGLRenderer as tt, PCFSoftShadowMap as et, PCFShadowMap as it, BasicShadowMap as st, MathUtils as S, Object3D as w, AmbientLight as at, PointLight as nt, SphereGeometry as I, MeshBasicMaterial as G, FrontSide as F, Mesh as P, HemisphereLight as ot, DirectionalLight as rt, Vector3 as h, Box3 as L, MeshStandardMaterial as k, Raycaster as U, Color as g, CylinderGeometry as ht, BufferGeometry as H, BufferAttribute as A, BoxGeometry as M, ConeGeometry as lt, LineDashedMaterial as dt, Line as ct, PlaneGeometry as ut, GridHelper as pt, Scene as mt, TOUCH as f, MOUSE as m, EventDispatcher as gt, Spherical as C, Vector2 as p, Quaternion as T, AxesHelper as _t, Matrix4 as ft, OrthographicCamera as wt, Vector4 as yt, Box3Helper as bt, Sphere as Dt } from "three";
|
|
5
|
+
import { P as _, U as Et, H as St, C as y, a as Pt, D as O } from "./PerspectiveCamera-8tnOn5YS.mjs";
|
|
6
|
+
import x from "three-spritetext";
|
|
7
|
+
class vt {
|
|
8
|
+
constructor() {
|
|
9
|
+
i(this, "isDIVEClock", !0);
|
|
10
|
+
i(this, "_lastTime", 0);
|
|
11
|
+
i(this, "_isRunning", !1);
|
|
12
|
+
i(this, "_tickers", []);
|
|
13
|
+
}
|
|
14
|
+
start() {
|
|
15
|
+
this._isRunning || (this._isRunning = !0, this._lastTime = performance.now(), requestAnimationFrame(this._tick.bind(this)));
|
|
16
|
+
}
|
|
17
|
+
stop() {
|
|
18
|
+
this._isRunning = !1;
|
|
19
|
+
}
|
|
20
|
+
addTicker(s) {
|
|
21
|
+
this._tickers.find((t) => t.uuid === s.uuid) || this._tickers.push(s);
|
|
22
|
+
}
|
|
23
|
+
hasTicker(s) {
|
|
24
|
+
return this._tickers.find((t) => t.uuid === s.uuid) !== void 0;
|
|
25
|
+
}
|
|
26
|
+
removeTicker(s) {
|
|
27
|
+
const t = this._tickers.findIndex((e) => e.uuid === s.uuid);
|
|
28
|
+
t !== -1 && this._tickers.splice(t, 1);
|
|
29
|
+
}
|
|
30
|
+
dispose() {
|
|
31
|
+
this.stop(), this._tickers = [], this._isRunning = !1, this._lastTime = 0;
|
|
32
|
+
}
|
|
33
|
+
_tick(s) {
|
|
34
|
+
if (!this._isRunning) return;
|
|
35
|
+
const t = (s - this._lastTime) / 1e3;
|
|
36
|
+
this._lastTime = s, this._tickers.forEach((e) => e.tick(t)), requestAnimationFrame(this._tick.bind(this));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const Y = {
|
|
40
|
+
canvas: void 0,
|
|
41
|
+
antialias: !0,
|
|
42
|
+
alpha: !0,
|
|
43
|
+
powerPreference: "high-performance",
|
|
44
|
+
precision: "highp",
|
|
45
|
+
stencil: !1,
|
|
46
|
+
depth: !0,
|
|
47
|
+
logarithmicDepthBuffer: !1,
|
|
48
|
+
shadows: !0,
|
|
49
|
+
shadowQuality: "high"
|
|
50
|
+
};
|
|
51
|
+
class W {
|
|
52
|
+
constructor(s, t, e) {
|
|
53
|
+
i(this, "isDIVERenderer", !0);
|
|
54
|
+
i(this, "_webglrenderer");
|
|
55
|
+
i(this, "_settings");
|
|
56
|
+
this._scene = s, this._camera = t, this._settings = {
|
|
57
|
+
...Y,
|
|
58
|
+
...e ?? {}
|
|
59
|
+
}, this._webglrenderer = this._createWebGLRenderer();
|
|
60
|
+
}
|
|
61
|
+
get webglrenderer() {
|
|
62
|
+
return this._webglrenderer;
|
|
63
|
+
}
|
|
64
|
+
get canvas() {
|
|
65
|
+
return this._webglrenderer.domElement;
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
this._webglrenderer.render(this._scene, this._camera);
|
|
69
|
+
}
|
|
70
|
+
onResize(s, t) {
|
|
71
|
+
this._webglrenderer.setSize(s, t, !1);
|
|
72
|
+
}
|
|
73
|
+
dispose() {
|
|
74
|
+
this._webglrenderer.dispose();
|
|
75
|
+
}
|
|
76
|
+
setCanvas(s) {
|
|
77
|
+
this._webglrenderer.dispose(), this._settings.canvas = s, this._webglrenderer = this._createWebGLRenderer();
|
|
78
|
+
}
|
|
79
|
+
_createWebGLRenderer() {
|
|
80
|
+
const s = new tt(this._settings);
|
|
81
|
+
return s.shadowMap.enabled = this._settings.shadows, s.shadowMap.type = this._settings.shadowQuality === "high" ? et : this._settings.shadowQuality === "medium" ? it : st, s.setPixelRatio(window.devicePixelRatio), s;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const te = W;
|
|
85
|
+
class Mt {
|
|
86
|
+
constructor(s, t) {
|
|
87
|
+
i(this, "isDIVEResizeManager", !0);
|
|
88
|
+
i(this, "_resizeObserver");
|
|
89
|
+
i(this, "_width", 0);
|
|
90
|
+
i(this, "_height", 0);
|
|
91
|
+
this._renderer = s, this._camera = t, this._resizeObserver = new ResizeObserver((e) => {
|
|
92
|
+
const a = e[0], { width: n, height: o } = a.contentRect;
|
|
93
|
+
n === this._width && o === this._height || (this._renderer.onResize(n, o), this._camera.onResize(n, o), this._width = n, this._height = o);
|
|
94
|
+
}), this._observeCanvas(this._renderer.canvas);
|
|
95
|
+
}
|
|
96
|
+
setCanvas(s) {
|
|
97
|
+
this._resizeObserver.disconnect(), this._observeCanvas(s);
|
|
98
|
+
const { width: t, height: e } = s.getBoundingClientRect();
|
|
99
|
+
this._renderer.onResize(t, e), this._camera.onResize(t, e), this._width = t, this._height = e;
|
|
100
|
+
}
|
|
101
|
+
dispose() {
|
|
102
|
+
this._resizeObserver.disconnect();
|
|
103
|
+
}
|
|
104
|
+
_observeCanvas(s) {
|
|
105
|
+
if (s.parentElement)
|
|
106
|
+
this._resizeObserver.observe(s.parentElement);
|
|
107
|
+
else {
|
|
108
|
+
const t = setInterval(() => {
|
|
109
|
+
s.parentElement && (this._resizeObserver.observe(s.parentElement), clearInterval(t));
|
|
110
|
+
}, 16);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
class B {
|
|
115
|
+
constructor(s, t, e) {
|
|
116
|
+
i(this, "isDIVEView", !0);
|
|
117
|
+
i(this, "uuid", S.generateUUID());
|
|
118
|
+
i(this, "_paused", !1);
|
|
119
|
+
i(this, "_renderer");
|
|
120
|
+
i(this, "_resizeManager");
|
|
121
|
+
this._scene = s, this._camera = t, this._settings = e, this._renderer = new W(
|
|
122
|
+
this._scene,
|
|
123
|
+
this._camera,
|
|
124
|
+
this._settings
|
|
125
|
+
), this._resizeManager = new Mt(
|
|
126
|
+
this._renderer,
|
|
127
|
+
this._camera
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
get renderer() {
|
|
131
|
+
return this._renderer;
|
|
132
|
+
}
|
|
133
|
+
get camera() {
|
|
134
|
+
return this._camera;
|
|
135
|
+
}
|
|
136
|
+
get canvas() {
|
|
137
|
+
return this._renderer.canvas;
|
|
138
|
+
}
|
|
139
|
+
tick() {
|
|
140
|
+
this._paused || this._renderer.render();
|
|
141
|
+
}
|
|
142
|
+
dispose() {
|
|
143
|
+
this._resizeManager.dispose(), this._renderer.dispose();
|
|
144
|
+
}
|
|
145
|
+
onResize(s, t) {
|
|
146
|
+
this._renderer.onResize(s, t), this._camera.onResize(s, t);
|
|
147
|
+
}
|
|
148
|
+
setCanvas(s) {
|
|
149
|
+
this._renderer.setCanvas(s), this._resizeManager.setCanvas(s), this.onResize(
|
|
150
|
+
this._renderer.canvas.clientWidth,
|
|
151
|
+
this._renderer.canvas.clientHeight
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
// TODO: add methods to individually pause and resume the view
|
|
155
|
+
pause() {
|
|
156
|
+
this._paused = !0;
|
|
157
|
+
}
|
|
158
|
+
resume() {
|
|
159
|
+
this._paused = !1;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
class xt extends w {
|
|
163
|
+
constructor() {
|
|
164
|
+
super();
|
|
165
|
+
i(this, "isDIVELight", !0);
|
|
166
|
+
i(this, "isDIVEAmbientLight", !0);
|
|
167
|
+
i(this, "isSelectable", !0);
|
|
168
|
+
i(this, "_light");
|
|
169
|
+
this.name = "DIVEAmbientLight", this._light = new at(16777215, 1), this._light.layers.mask = _, this.add(this._light);
|
|
170
|
+
}
|
|
171
|
+
setColor(t) {
|
|
172
|
+
this._light.color = t;
|
|
173
|
+
}
|
|
174
|
+
setIntensity(t) {
|
|
175
|
+
this._light.intensity = t;
|
|
176
|
+
}
|
|
177
|
+
setEnabled(t) {
|
|
178
|
+
this._light.visible = t;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
class Tt extends w {
|
|
182
|
+
constructor() {
|
|
183
|
+
super();
|
|
184
|
+
i(this, "isDIVELight", !0);
|
|
185
|
+
i(this, "isDIVEPointLight", !0);
|
|
186
|
+
i(this, "isMovable", !0);
|
|
187
|
+
i(this, "isSelectable", !0);
|
|
188
|
+
i(this, "gizmo", null);
|
|
189
|
+
i(this, "light");
|
|
190
|
+
i(this, "mesh");
|
|
191
|
+
this.name = "DIVEPointLight", this.light = new nt(16777215, 1), this.light.layers.mask = _, this.light.castShadow = !0, this.light.shadow.mapSize.width = 512, this.light.shadow.mapSize.height = 512, this.add(this.light);
|
|
192
|
+
const t = 0.1, e = new I(
|
|
193
|
+
t,
|
|
194
|
+
t * 320,
|
|
195
|
+
t * 320
|
|
196
|
+
), a = new G({
|
|
197
|
+
color: this.light.color,
|
|
198
|
+
transparent: !0,
|
|
199
|
+
opacity: 0.8,
|
|
200
|
+
side: F
|
|
201
|
+
});
|
|
202
|
+
this.mesh = new P(e, a), this.mesh.layers.mask = Et, this.add(this.mesh);
|
|
203
|
+
}
|
|
204
|
+
setColor(t) {
|
|
205
|
+
this.light.color = t, this.mesh.material.color = t;
|
|
206
|
+
}
|
|
207
|
+
setIntensity(t) {
|
|
208
|
+
this.light.intensity = t, this.mesh.material.opacity = t > 0.8 ? 0.8 : t * 0.8;
|
|
209
|
+
}
|
|
210
|
+
setEnabled(t) {
|
|
211
|
+
this.light.visible = t;
|
|
212
|
+
}
|
|
213
|
+
onMove() {
|
|
214
|
+
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
215
|
+
var e;
|
|
216
|
+
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
217
|
+
id: this.userData.id,
|
|
218
|
+
position: this.position
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
onSelect() {
|
|
223
|
+
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
224
|
+
var e;
|
|
225
|
+
(e = t.get(this.userData.id)) == null || e.performAction("SELECT_OBJECT", {
|
|
226
|
+
id: this.userData.id
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
onDeselect() {
|
|
231
|
+
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
232
|
+
var e;
|
|
233
|
+
(e = t.get(this.userData.id)) == null || e.performAction("DESELECT_OBJECT", {
|
|
234
|
+
id: this.userData.id
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class It extends w {
|
|
240
|
+
constructor() {
|
|
241
|
+
super();
|
|
242
|
+
i(this, "isDIVELight", !0);
|
|
243
|
+
i(this, "isDIVESceneLight", !0);
|
|
244
|
+
i(this, "isSelectable", !0);
|
|
245
|
+
i(this, "_hemiLight");
|
|
246
|
+
i(this, "_dirLight");
|
|
247
|
+
this.name = "DIVESceneLight", this._hemiLight = new ot(16777215, 16777215, 2), this._hemiLight.layers.mask = _, this._hemiLight.position.set(0, 50, 0), this._hemiLight.visible = !0, this.add(this._hemiLight), this._dirLight = new rt(16777215, 3), this._dirLight.layers.mask = _, this._dirLight.position.set(1, 1.75, 1), this._dirLight.position.multiplyScalar(30), this._dirLight.castShadow = !0, this._dirLight.visible = !0, this._dirLight.shadow.mapSize.width = 2048, this._dirLight.shadow.mapSize.height = 2048;
|
|
248
|
+
const t = 5;
|
|
249
|
+
this._dirLight.shadow.camera.left = -5, this._dirLight.shadow.camera.right = t, this._dirLight.shadow.camera.top = t, this._dirLight.shadow.camera.bottom = -5, this._dirLight.shadow.camera.far = 3500, this.add(this._dirLight);
|
|
250
|
+
}
|
|
251
|
+
setColor(t) {
|
|
252
|
+
this._hemiLight.color = t, this._dirLight.color = t;
|
|
253
|
+
}
|
|
254
|
+
setIntensity(t) {
|
|
255
|
+
this._hemiLight.intensity = t * 2, this._dirLight.intensity = t * 3;
|
|
256
|
+
}
|
|
257
|
+
setEnabled(t) {
|
|
258
|
+
this._hemiLight.visible = t, this._dirLight.visible = t;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const V = (r) => r.parent ? V(r.parent) : r;
|
|
262
|
+
class v extends w {
|
|
263
|
+
constructor() {
|
|
264
|
+
super();
|
|
265
|
+
i(this, "isSelectable", !0);
|
|
266
|
+
i(this, "isMovable", !0);
|
|
267
|
+
i(this, "isDIVENode", !0);
|
|
268
|
+
i(this, "gizmo", null);
|
|
269
|
+
i(this, "_positionWorldBuffer");
|
|
270
|
+
i(this, "_boundingBox");
|
|
271
|
+
this.layers.mask = _, this._positionWorldBuffer = new h(), this._boundingBox = new L();
|
|
272
|
+
}
|
|
273
|
+
setPosition(t) {
|
|
274
|
+
if (!this.parent) {
|
|
275
|
+
this.position.set(t.x, t.y, t.z);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const e = new h(t.x, t.y, t.z);
|
|
279
|
+
this.position.copy(this.parent.worldToLocal(e)), "isDIVEGroup" in this.parent && this.parent.updateLineTo(this);
|
|
280
|
+
}
|
|
281
|
+
setRotation(t) {
|
|
282
|
+
this.rotation.set(t.x, t.y, t.z);
|
|
283
|
+
}
|
|
284
|
+
setScale(t) {
|
|
285
|
+
this.scale.set(t.x, t.y, t.z);
|
|
286
|
+
}
|
|
287
|
+
setVisibility(t) {
|
|
288
|
+
this.visible = t;
|
|
289
|
+
}
|
|
290
|
+
setToWorldOrigin() {
|
|
291
|
+
this.position.set(0, 0, 0), import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
292
|
+
var e;
|
|
293
|
+
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
294
|
+
id: this.userData.id,
|
|
295
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
296
|
+
rotation: this.rotation,
|
|
297
|
+
scale: this.scale
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
303
|
+
*/
|
|
304
|
+
onMove() {
|
|
305
|
+
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
306
|
+
var e;
|
|
307
|
+
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
308
|
+
id: this.userData.id,
|
|
309
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
310
|
+
rotation: this.rotation,
|
|
311
|
+
scale: this.scale
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
onSelect() {
|
|
316
|
+
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
317
|
+
var e;
|
|
318
|
+
(e = t.get(this.userData.id)) == null || e.performAction("SELECT_OBJECT", {
|
|
319
|
+
id: this.userData.id
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
onDeselect() {
|
|
324
|
+
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
325
|
+
var e;
|
|
326
|
+
(e = t.get(this.userData.id)) == null || e.performAction("DESELECT_OBJECT", {
|
|
327
|
+
id: this.userData.id
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
class Lt extends v {
|
|
333
|
+
constructor() {
|
|
334
|
+
super();
|
|
335
|
+
i(this, "isDIVEModel", !0);
|
|
336
|
+
i(this, "_mesh", null);
|
|
337
|
+
i(this, "_material", null);
|
|
338
|
+
i(this, "_assetLoader", null);
|
|
339
|
+
this.name = "DIVEModel";
|
|
340
|
+
}
|
|
341
|
+
async _getAssetLoader() {
|
|
342
|
+
return this._assetLoader || (this._assetLoader = new (await import("../plugins/assetloader/index.mjs")).AssetLoader()), this._assetLoader;
|
|
343
|
+
}
|
|
344
|
+
async setFromURL(t) {
|
|
345
|
+
const a = await (await this._getAssetLoader()).load(t);
|
|
346
|
+
return this.setFromGLTF(a), import("../plugins/state/index.mjs").then(({ State: n }) => {
|
|
347
|
+
var o;
|
|
348
|
+
(o = n.get(this.userData.id)) == null || o.performAction("MODEL_LOADED", {
|
|
349
|
+
id: this.userData.id
|
|
350
|
+
});
|
|
351
|
+
}), this;
|
|
352
|
+
}
|
|
353
|
+
setFromGLTF(t) {
|
|
354
|
+
return this.clear(), this._boundingBox.makeEmpty(), t.traverse((e) => {
|
|
355
|
+
e.castShadow = !0, e.receiveShadow = !0, e.layers.mask = this.layers.mask, this._boundingBox.expandByObject(e), !this._mesh && "isMesh" in e && (this._mesh = e, this._material ? this._mesh.material = this._material : this._material = e.material);
|
|
356
|
+
}), this.add(t), this;
|
|
357
|
+
}
|
|
358
|
+
setMaterial(t) {
|
|
359
|
+
this._material || (this._material = new k()), t.vertexColors !== void 0 && (this._material.vertexColors = t.vertexColors), t.color !== void 0 && this._material.color.set(t.color), t.map !== void 0 && (this._material.map = t.map), t.normalMap !== void 0 && (this._material.normalMap = t.normalMap), t.roughness !== void 0 && (this._material.roughness = t.roughness), t.roughnessMap !== void 0 && (this._material.roughnessMap = t.roughnessMap, this._material.roughnessMap && (this._material.roughness = 1)), t.metalness !== void 0 && (this._material.metalness = t.metalness), t.metalnessMap !== void 0 && (this._material.metalnessMap = t.metalnessMap, this._material.metalnessMap && (this._material.metalness = 1)), this._mesh && (this._mesh.material = this._material);
|
|
360
|
+
}
|
|
361
|
+
placeOnFloor() {
|
|
362
|
+
var n, o, l, c;
|
|
363
|
+
const t = this.getWorldPosition(this._positionWorldBuffer), e = t.clone();
|
|
364
|
+
(o = (n = this._mesh) == null ? void 0 : n.geometry) == null || o.computeBoundingBox();
|
|
365
|
+
const a = (c = (l = this._mesh) == null ? void 0 : l.geometry) == null ? void 0 : c.boundingBox;
|
|
366
|
+
!a || !this._mesh || (t.y = t.y - this._mesh.localToWorld(a.min.clone()).y, t.y !== e.y && import("../plugins/state/index.mjs").then(({ State: d }) => {
|
|
367
|
+
var u;
|
|
368
|
+
(u = d.get(this.userData.id)) == null || u.performAction("UPDATE_OBJECT", {
|
|
369
|
+
id: this.userData.id,
|
|
370
|
+
position: t,
|
|
371
|
+
rotation: this.rotation,
|
|
372
|
+
scale: this.scale
|
|
373
|
+
});
|
|
374
|
+
}));
|
|
375
|
+
}
|
|
376
|
+
dropIt() {
|
|
377
|
+
if (!this.parent) {
|
|
378
|
+
console.warn(
|
|
379
|
+
"DIVEModel: dropIt() called on a model that is not in the scene.",
|
|
380
|
+
this
|
|
381
|
+
);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const t = this._boundingBox.min.y * this.scale.y, e = this.localToWorld(
|
|
385
|
+
this._boundingBox.getCenter(new h()).multiply(this.scale)
|
|
386
|
+
);
|
|
387
|
+
e.y = t + this.position.y;
|
|
388
|
+
const a = new U(e, new h(0, -1, 0));
|
|
389
|
+
a.layers.mask = _;
|
|
390
|
+
const n = a.intersectObjects(
|
|
391
|
+
V(this).root.children,
|
|
392
|
+
!0
|
|
393
|
+
);
|
|
394
|
+
if (n.length > 0) {
|
|
395
|
+
const o = n[0].object;
|
|
396
|
+
o.geometry.computeBoundingBox();
|
|
397
|
+
const l = o.geometry.boundingBox, c = o.localToWorld(l.max.clone()), d = this.position.clone(), u = this.position.clone().setY(c.y).sub(new h(0, t, 0));
|
|
398
|
+
if (this.position.copy(u), this.position.y === d.y) return;
|
|
399
|
+
this.onMove();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
class kt extends v {
|
|
404
|
+
constructor() {
|
|
405
|
+
super();
|
|
406
|
+
i(this, "isDIVEPrimitive", !0);
|
|
407
|
+
i(this, "_mesh");
|
|
408
|
+
this._mesh = new P(), this._mesh.layers.mask = _, this._mesh.castShadow = !0, this._mesh.receiveShadow = !0, this._mesh.material = new k(), this.add(this._mesh);
|
|
409
|
+
}
|
|
410
|
+
setGeometry(t) {
|
|
411
|
+
const e = this.assembleGeometry(t);
|
|
412
|
+
e && (this._mesh.geometry = e, this._boundingBox.setFromObject(this._mesh));
|
|
413
|
+
}
|
|
414
|
+
setMaterial(t) {
|
|
415
|
+
const e = this._mesh.material;
|
|
416
|
+
t.vertexColors !== void 0 && (e.vertexColors = t.vertexColors), t.color !== void 0 && (e.color = new g(t.color)), t.map !== void 0 && (e.map = t.map), t.normalMap !== void 0 && (e.normalMap = t.normalMap), t.roughness !== void 0 && (e.roughness = t.roughness), t.roughnessMap !== void 0 && (e.roughnessMap = t.roughnessMap, e.roughnessMap && (e.roughness = 1)), t.metalness !== void 0 && (e.metalness = t.metalness), t.metalnessMap !== void 0 && (e.metalnessMap = t.metalnessMap, e.metalnessMap && (e.metalness = 0)), this._mesh && (this._mesh.material = e);
|
|
417
|
+
}
|
|
418
|
+
placeOnFloor() {
|
|
419
|
+
var n, o, l, c;
|
|
420
|
+
const t = this.getWorldPosition(this._positionWorldBuffer), e = t.clone();
|
|
421
|
+
(o = (n = this._mesh) == null ? void 0 : n.geometry) == null || o.computeBoundingBox();
|
|
422
|
+
const a = (c = (l = this._mesh) == null ? void 0 : l.geometry) == null ? void 0 : c.boundingBox;
|
|
423
|
+
!a || !this._mesh || (t.y = t.y - this._mesh.localToWorld(a.min.clone()).y, t.y !== e.y && import("../plugins/state/index.mjs").then(({ State: d }) => {
|
|
424
|
+
var u;
|
|
425
|
+
(u = d.get(this.userData.id)) == null || u.performAction("UPDATE_OBJECT", {
|
|
426
|
+
id: this.userData.id,
|
|
427
|
+
position: t,
|
|
428
|
+
rotation: this.rotation,
|
|
429
|
+
scale: this.scale
|
|
430
|
+
});
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
dropIt() {
|
|
434
|
+
if (!this.parent) {
|
|
435
|
+
console.warn(
|
|
436
|
+
"DIVEPrimitive: dropIt() called on a model that is not in the scene.",
|
|
437
|
+
this
|
|
438
|
+
);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const t = this._boundingBox.min.y * this.scale.y, e = this.localToWorld(
|
|
442
|
+
this._boundingBox.getCenter(new h()).multiply(this.scale)
|
|
443
|
+
);
|
|
444
|
+
e.y = t + this.position.y;
|
|
445
|
+
const a = new U(e, new h(0, -1, 0));
|
|
446
|
+
a.layers.mask = _;
|
|
447
|
+
const n = a.intersectObjects(
|
|
448
|
+
V(this).root.children,
|
|
449
|
+
!0
|
|
450
|
+
);
|
|
451
|
+
if (n.length > 0) {
|
|
452
|
+
const o = n[0].object;
|
|
453
|
+
o.geometry.computeBoundingBox();
|
|
454
|
+
const l = o.geometry.boundingBox, c = o.localToWorld(l.max.clone()), d = this.position.clone(), u = this.position.clone().setY(c.y).sub(new h(0, t, 0));
|
|
455
|
+
if (this.position.copy(u), this.position.y === d.y) return;
|
|
456
|
+
this.onMove();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
assembleGeometry(t) {
|
|
460
|
+
switch (this._mesh.material.flatShading = !1, t.name.toLowerCase()) {
|
|
461
|
+
case "cylinder":
|
|
462
|
+
return this.createCylinderGeometry(t);
|
|
463
|
+
case "sphere":
|
|
464
|
+
return this.createSphereGeometry(t);
|
|
465
|
+
case "pyramid":
|
|
466
|
+
return this._mesh.material.flatShading = !0, this.createPyramidGeometry(t);
|
|
467
|
+
case "cube":
|
|
468
|
+
case "box":
|
|
469
|
+
return this.createBoxGeometry(t);
|
|
470
|
+
case "cone":
|
|
471
|
+
return this.createConeGeometry(t);
|
|
472
|
+
case "wall":
|
|
473
|
+
return this.createWallGeometry(t);
|
|
474
|
+
case "plane":
|
|
475
|
+
return this.createPlaneGeometry(t);
|
|
476
|
+
default:
|
|
477
|
+
return console.warn(
|
|
478
|
+
"DIVEPrimitive.assembleGeometry: Invalid geometry type:",
|
|
479
|
+
t.name.toLowerCase()
|
|
480
|
+
), null;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
createCylinderGeometry(t) {
|
|
484
|
+
const e = new ht(
|
|
485
|
+
t.width / 2,
|
|
486
|
+
t.width / 2,
|
|
487
|
+
t.height,
|
|
488
|
+
64
|
|
489
|
+
);
|
|
490
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
491
|
+
}
|
|
492
|
+
createSphereGeometry(t) {
|
|
493
|
+
return new I(t.width / 2, 256, 256);
|
|
494
|
+
}
|
|
495
|
+
createPyramidGeometry(t) {
|
|
496
|
+
const e = new Float32Array([
|
|
497
|
+
-t.width / 2,
|
|
498
|
+
0,
|
|
499
|
+
-t.depth / 2,
|
|
500
|
+
// 0
|
|
501
|
+
t.width / 2,
|
|
502
|
+
0,
|
|
503
|
+
-t.depth / 2,
|
|
504
|
+
// 1
|
|
505
|
+
t.width / 2,
|
|
506
|
+
0,
|
|
507
|
+
t.depth / 2,
|
|
508
|
+
// 2
|
|
509
|
+
-t.width / 2,
|
|
510
|
+
0,
|
|
511
|
+
t.depth / 2,
|
|
512
|
+
// 3
|
|
513
|
+
0,
|
|
514
|
+
t.height,
|
|
515
|
+
0
|
|
516
|
+
]), a = new Uint16Array([
|
|
517
|
+
0,
|
|
518
|
+
1,
|
|
519
|
+
2,
|
|
520
|
+
0,
|
|
521
|
+
2,
|
|
522
|
+
3,
|
|
523
|
+
0,
|
|
524
|
+
4,
|
|
525
|
+
1,
|
|
526
|
+
1,
|
|
527
|
+
4,
|
|
528
|
+
2,
|
|
529
|
+
2,
|
|
530
|
+
4,
|
|
531
|
+
3,
|
|
532
|
+
3,
|
|
533
|
+
4,
|
|
534
|
+
0
|
|
535
|
+
]), n = new H();
|
|
536
|
+
return n.setAttribute(
|
|
537
|
+
"position",
|
|
538
|
+
new A(e, 3)
|
|
539
|
+
), n.setIndex(new A(a, 1)), n.computeVertexNormals(), n.computeBoundingBox(), n.computeBoundingSphere(), n;
|
|
540
|
+
}
|
|
541
|
+
createBoxGeometry(t) {
|
|
542
|
+
const e = new M(
|
|
543
|
+
t.width,
|
|
544
|
+
t.height,
|
|
545
|
+
t.depth
|
|
546
|
+
);
|
|
547
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
548
|
+
}
|
|
549
|
+
createConeGeometry(t) {
|
|
550
|
+
const e = new lt(t.width / 2, t.height, 256);
|
|
551
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
552
|
+
}
|
|
553
|
+
createWallGeometry(t) {
|
|
554
|
+
const e = new M(
|
|
555
|
+
t.width,
|
|
556
|
+
t.height,
|
|
557
|
+
t.depth || 0.05,
|
|
558
|
+
16
|
|
559
|
+
);
|
|
560
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
561
|
+
}
|
|
562
|
+
createPlaneGeometry(t) {
|
|
563
|
+
const e = new M(
|
|
564
|
+
t.width,
|
|
565
|
+
t.height,
|
|
566
|
+
t.depth
|
|
567
|
+
);
|
|
568
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
class Vt extends v {
|
|
572
|
+
// lines to children
|
|
573
|
+
constructor() {
|
|
574
|
+
super();
|
|
575
|
+
i(this, "isDIVEGroup", !0);
|
|
576
|
+
i(this, "_members");
|
|
577
|
+
i(this, "_lines");
|
|
578
|
+
this.name = "DIVEGroup", this._members = [], this._lines = [];
|
|
579
|
+
}
|
|
580
|
+
// children objects
|
|
581
|
+
get members() {
|
|
582
|
+
return this._members;
|
|
583
|
+
}
|
|
584
|
+
setPosition(t) {
|
|
585
|
+
super.setPosition(t), this._members.forEach((e) => {
|
|
586
|
+
"isDIVENode" in e && e.onMove();
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
setLinesVisibility(t, e) {
|
|
590
|
+
if (!e) {
|
|
591
|
+
this._lines.forEach((n) => {
|
|
592
|
+
n.visible = t;
|
|
593
|
+
});
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
const a = this._members.indexOf(e);
|
|
597
|
+
a !== -1 && (this._lines[a].visible = t);
|
|
598
|
+
}
|
|
599
|
+
attach(t) {
|
|
600
|
+
if (this._members.includes(t))
|
|
601
|
+
return this;
|
|
602
|
+
const e = this.createLine();
|
|
603
|
+
return this.add(e), this._lines.push(e), super.attach(t), this._members.push(t), this._updateLineTo(e, t), this.setLinesVisibility(!0, t), this;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Removes an object from the group.
|
|
607
|
+
* @param object - The object to remove.
|
|
608
|
+
* @returns The group instance.
|
|
609
|
+
*/
|
|
610
|
+
remove(t) {
|
|
611
|
+
const e = this._members.indexOf(t);
|
|
612
|
+
if (e === -1)
|
|
613
|
+
return this;
|
|
614
|
+
const a = this._lines[e];
|
|
615
|
+
return super.remove(a), this._lines.splice(e, 1), super.remove(t), this._members.splice(e, 1), this;
|
|
616
|
+
}
|
|
617
|
+
updateLineTo(t) {
|
|
618
|
+
const e = this._members.indexOf(t);
|
|
619
|
+
e !== -1 && this._updateLineTo(this._lines[e], t);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Creates a line for visualization.
|
|
623
|
+
*/
|
|
624
|
+
createLine() {
|
|
625
|
+
const t = new H(), e = new dt({
|
|
626
|
+
color: 6710886,
|
|
627
|
+
dashSize: 0.05,
|
|
628
|
+
gapSize: 0.025
|
|
629
|
+
}), a = new ct(t, e);
|
|
630
|
+
return a.visible = !1, a;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Updates a line to the object.
|
|
634
|
+
*/
|
|
635
|
+
_updateLineTo(t, e) {
|
|
636
|
+
const a = [
|
|
637
|
+
new h(0, 0, 0),
|
|
638
|
+
e.position.clone()
|
|
639
|
+
];
|
|
640
|
+
t.geometry.setFromPoints(a), t.computeLineDistances();
|
|
641
|
+
}
|
|
642
|
+
// public setBoundingBoxVisibility(visible: boolean): void {
|
|
643
|
+
// this._boxMesh.visible = visible;
|
|
644
|
+
// }
|
|
645
|
+
// /**
|
|
646
|
+
// * Recalculates the position of the group based on it's bounding box.
|
|
647
|
+
// * Children's world positions are kept.
|
|
648
|
+
// */
|
|
649
|
+
// private recalculatePosition(): void {
|
|
650
|
+
// // store all children's world positions
|
|
651
|
+
// const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
|
|
652
|
+
// // calculate new center and set it as the group's position
|
|
653
|
+
// const bbcenter = this.updateBB();
|
|
654
|
+
// this.position.copy(bbcenter);
|
|
655
|
+
// // set childrens's positions so their world positions are kept
|
|
656
|
+
// this.children.forEach((child, i) => {
|
|
657
|
+
// if (child.uuid === this._boxMesh.uuid) return;
|
|
658
|
+
// child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
659
|
+
// });
|
|
660
|
+
// DIVECommunication.get(this.userData.id)?.performAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
|
|
661
|
+
// }
|
|
662
|
+
// /**
|
|
663
|
+
// * Updates the bounding box of the group.
|
|
664
|
+
// * @returns {Vector3} The new center of the bounding box.
|
|
665
|
+
// */
|
|
666
|
+
// private updateBB(): Vector3 {
|
|
667
|
+
// this._boundingBox.makeEmpty();
|
|
668
|
+
// if (this.children.length === 1) {
|
|
669
|
+
// // because we always have the box mesh as 1 child
|
|
670
|
+
// return this.position.clone();
|
|
671
|
+
// }
|
|
672
|
+
// this.children.forEach((child) => {
|
|
673
|
+
// if (child.uuid === this._boxMesh.uuid) return;
|
|
674
|
+
// this._boundingBox.expandByObject(child);
|
|
675
|
+
// });
|
|
676
|
+
// return this._boundingBox.getCenter(new Vector3());
|
|
677
|
+
// }
|
|
678
|
+
// private updateBoxMesh(): void {
|
|
679
|
+
// if (this.children.length === 1) {
|
|
680
|
+
// // because we always have the box mesh as 1 child
|
|
681
|
+
// this._boxMesh.visible = false;
|
|
682
|
+
// return;
|
|
683
|
+
// }
|
|
684
|
+
// this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
685
|
+
// this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
686
|
+
// this._boxMesh.geometry = new BoxGeometry(this._boundingBox.max.x - this._boundingBox.min.x, this._boundingBox.max.y - this._boundingBox.min.y, this._boundingBox.max.z - this._boundingBox.min.z);
|
|
687
|
+
// this._boxMesh.visible = true;
|
|
688
|
+
// }
|
|
689
|
+
}
|
|
690
|
+
class Rt extends P {
|
|
691
|
+
constructor() {
|
|
692
|
+
const t = new ut(1, 1);
|
|
693
|
+
t.scale(1e3, 1e3, 1), t.rotateX(-Math.PI / 2);
|
|
694
|
+
const e = new k({
|
|
695
|
+
color: new g(16777215),
|
|
696
|
+
side: F
|
|
697
|
+
});
|
|
698
|
+
super(t, e);
|
|
699
|
+
i(this, "isDIVEFloor", !0);
|
|
700
|
+
this.name = "Floor", this.layers.mask = _, this.receiveShadow = !0;
|
|
701
|
+
}
|
|
702
|
+
setVisibility(t) {
|
|
703
|
+
this.visible = t;
|
|
704
|
+
}
|
|
705
|
+
setColor(t) {
|
|
706
|
+
this.material.color = new g(t);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
class At extends w {
|
|
710
|
+
constructor() {
|
|
711
|
+
super();
|
|
712
|
+
i(this, "isDIVERoot", !0);
|
|
713
|
+
i(this, "_floor");
|
|
714
|
+
this.name = "Root", this._floor = new Rt(), this.add(this._floor);
|
|
715
|
+
}
|
|
716
|
+
get floor() {
|
|
717
|
+
return this._floor;
|
|
718
|
+
}
|
|
719
|
+
computeSceneBB() {
|
|
720
|
+
const t = new L();
|
|
721
|
+
return this.children.forEach((e) => {
|
|
722
|
+
"isDIVEFloor" in e || e.traverse((a) => {
|
|
723
|
+
"isObject3D" in a && t.expandByObject(a);
|
|
724
|
+
});
|
|
725
|
+
}), t;
|
|
726
|
+
}
|
|
727
|
+
getSceneObject(t) {
|
|
728
|
+
let e;
|
|
729
|
+
return this.traverse((a) => {
|
|
730
|
+
e || a.userData.id === t.id && (e = a);
|
|
731
|
+
}), e;
|
|
732
|
+
}
|
|
733
|
+
addSceneObject(t) {
|
|
734
|
+
let e = this.getSceneObject(t);
|
|
735
|
+
if (e)
|
|
736
|
+
return console.warn(
|
|
737
|
+
`DIVERoot.addSceneObject: Scene object with id ${t.id} already exists`
|
|
738
|
+
), e;
|
|
739
|
+
switch (t.entityType) {
|
|
740
|
+
case "pov":
|
|
741
|
+
break;
|
|
742
|
+
case "light": {
|
|
743
|
+
switch (t.type) {
|
|
744
|
+
case "scene": {
|
|
745
|
+
e = new It();
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
case "ambient": {
|
|
749
|
+
e = new xt();
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
case "point": {
|
|
753
|
+
e = new Tt();
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
default:
|
|
757
|
+
throw new Error(
|
|
758
|
+
`DIVERoot.addSceneObject: Unknown light type: ${t.type}`
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
e.name = t.name, e.userData.id = t.id, this.add(e), this._updateLight(e, t);
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
case "model": {
|
|
765
|
+
e = new Lt(), e.name = t.name, e.userData.id = t.id, e.userData.uri = t.uri, this.add(e), this._updateModel(e, t);
|
|
766
|
+
break;
|
|
767
|
+
}
|
|
768
|
+
case "primitive": {
|
|
769
|
+
e = new kt(), e.name = t.name, e.userData.id = t.id, this.add(e), this._updatePrimitive(e, t);
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
case "group": {
|
|
773
|
+
e = new Vt(), e.name = t.name, e.userData.id = t.id, this.add(e), this._updateGroup(e, t);
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
default:
|
|
777
|
+
throw new Error(
|
|
778
|
+
`DIVERoot.addSceneObject: Unknown entity type: ${t.entityType}`
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
return e;
|
|
782
|
+
}
|
|
783
|
+
updateSceneObject(t) {
|
|
784
|
+
const e = this.getSceneObject(t);
|
|
785
|
+
if (!e) {
|
|
786
|
+
console.warn(
|
|
787
|
+
`DIVERoot.updateSceneObject: Scene object with id ${t.id} does not exist`
|
|
788
|
+
);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
switch (t.entityType) {
|
|
792
|
+
case "pov":
|
|
793
|
+
break;
|
|
794
|
+
case "light": {
|
|
795
|
+
this._updateLight(e, t);
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
case "model": {
|
|
799
|
+
this._updateModel(e, t);
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
case "primitive": {
|
|
803
|
+
this._updatePrimitive(e, t);
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
case "group": {
|
|
807
|
+
this._updateGroup(e, t);
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
default:
|
|
811
|
+
throw new Error(
|
|
812
|
+
`DIVERoot.updateSceneObject: Unknown entity type: ${t.entityType}`
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
deleteSceneObject(t) {
|
|
817
|
+
const e = this.getSceneObject(t);
|
|
818
|
+
if (!e) {
|
|
819
|
+
console.warn(
|
|
820
|
+
`DIVERoot.deleteSceneObject: Object with id ${t.id} not found`
|
|
821
|
+
);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
switch (t.entityType) {
|
|
825
|
+
case "pov":
|
|
826
|
+
break;
|
|
827
|
+
case "light": {
|
|
828
|
+
this._deleteLight(e);
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
case "model": {
|
|
832
|
+
this._deleteModel(e);
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
case "primitive": {
|
|
836
|
+
this._deletePrimitive(e);
|
|
837
|
+
break;
|
|
838
|
+
}
|
|
839
|
+
case "group": {
|
|
840
|
+
this._deleteGroup(e);
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
default:
|
|
844
|
+
throw new Error(
|
|
845
|
+
`DIVERoot.deleteSceneObject: Unknown entity type: ${t.entityType}`
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
_updateLight(t, e) {
|
|
850
|
+
e.name !== void 0 && e.name !== null && (t.name = e.name), e.position !== void 0 && e.position !== null && t.position.set(
|
|
851
|
+
e.position.x,
|
|
852
|
+
e.position.y,
|
|
853
|
+
e.position.z
|
|
854
|
+
), e.intensity !== void 0 && e.intensity !== null && t.setIntensity(e.intensity), e.enabled !== void 0 && e.enabled !== null && t.setEnabled(e.enabled), e.color !== void 0 && e.color !== null && t.setColor(new g(e.color)), e.visible !== void 0 && e.visible !== null && (t.visible = e.visible), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
855
|
+
}
|
|
856
|
+
_updateModel(t, e) {
|
|
857
|
+
e.uri !== void 0 && t.setFromURL(e.uri), e.name !== void 0 && (t.name = e.name), e.position !== void 0 && t.setPosition(e.position), e.rotation !== void 0 && t.setRotation(e.rotation), e.scale !== void 0 && t.setScale(e.scale), e.visible !== void 0 && t.setVisibility(e.visible), e.material !== void 0 && t.setMaterial(e.material), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
858
|
+
}
|
|
859
|
+
_updatePrimitive(t, e) {
|
|
860
|
+
e.name !== void 0 && (t.name = e.name), e.geometry !== void 0 && t.setGeometry(e.geometry), e.position !== void 0 && t.setPosition(e.position), e.rotation !== void 0 && t.setRotation(e.rotation), e.scale !== void 0 && t.setScale(e.scale), e.visible !== void 0 && t.setVisibility(e.visible), e.material !== void 0 && t.setMaterial(e.material), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
861
|
+
}
|
|
862
|
+
_updateGroup(t, e) {
|
|
863
|
+
e.name !== void 0 && (t.name = e.name), e.position !== void 0 && t.setPosition(e.position), e.rotation !== void 0 && t.setRotation(e.rotation), e.scale !== void 0 && t.setScale(e.scale), e.visible !== void 0 && t.setVisibility(e.visible), e.bbVisible !== void 0 && t.setLinesVisibility(e.bbVisible), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
864
|
+
}
|
|
865
|
+
_deleteLight(t) {
|
|
866
|
+
this._detachTransformControls(t), t.parent.remove(t);
|
|
867
|
+
}
|
|
868
|
+
_deleteModel(t) {
|
|
869
|
+
this._detachTransformControls(t), t.parent.remove(t);
|
|
870
|
+
}
|
|
871
|
+
_deletePrimitive(t) {
|
|
872
|
+
this._detachTransformControls(t), t.parent.remove(t);
|
|
873
|
+
}
|
|
874
|
+
_deleteGroup(t) {
|
|
875
|
+
this._detachTransformControls(t);
|
|
876
|
+
for (let e = t.members.length - 1; e >= 0; e--)
|
|
877
|
+
this.attach(t.members[e]);
|
|
878
|
+
t.parent.remove(t);
|
|
879
|
+
}
|
|
880
|
+
_setParent(t) {
|
|
881
|
+
const e = this.getSceneObject(t);
|
|
882
|
+
if (t.parentId !== null) {
|
|
883
|
+
const a = this.getSceneObject({
|
|
884
|
+
id: t.parentId,
|
|
885
|
+
entityType: t.entityType
|
|
886
|
+
});
|
|
887
|
+
if (!a) return;
|
|
888
|
+
a.attach(e);
|
|
889
|
+
} else
|
|
890
|
+
this.attach(e);
|
|
891
|
+
}
|
|
892
|
+
_detachTransformControls(t) {
|
|
893
|
+
this._findScene(t).children.find((e) => {
|
|
894
|
+
"isTransformControls" in e && e.detach();
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
_findScene(t) {
|
|
898
|
+
return t.parent !== null ? this._findScene(t.parent) : t;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const Ct = "#888888", Ot = "#dddddd";
|
|
902
|
+
class Bt extends w {
|
|
903
|
+
constructor() {
|
|
904
|
+
super(), this.name = "Grid";
|
|
905
|
+
const s = new pt(
|
|
906
|
+
100,
|
|
907
|
+
100,
|
|
908
|
+
Ct,
|
|
909
|
+
Ot
|
|
910
|
+
);
|
|
911
|
+
s.material.depthTest = !1, s.layers.mask = St, this.add(s);
|
|
912
|
+
}
|
|
913
|
+
setVisibility(s) {
|
|
914
|
+
this.visible = s;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
const E = {
|
|
918
|
+
displayFloor: !1,
|
|
919
|
+
displayGrid: !1,
|
|
920
|
+
backgroundColor: "#ffffff"
|
|
921
|
+
};
|
|
922
|
+
class zt extends mt {
|
|
923
|
+
constructor(t) {
|
|
924
|
+
super();
|
|
925
|
+
i(this, "isDIVEScene", !0);
|
|
926
|
+
i(this, "_root");
|
|
927
|
+
i(this, "_grid");
|
|
928
|
+
this.background = new g(
|
|
929
|
+
(t == null ? void 0 : t.backgroundColor) ?? E.backgroundColor
|
|
930
|
+
), this._root = new At(), this._root.floor.setVisibility(
|
|
931
|
+
(t == null ? void 0 : t.displayFloor) ?? E.displayFloor
|
|
932
|
+
), this.add(this._root), this._grid = new Bt(), this._grid.setVisibility(
|
|
933
|
+
(t == null ? void 0 : t.displayGrid) ?? E.displayGrid
|
|
934
|
+
), this.add(this._grid);
|
|
935
|
+
}
|
|
936
|
+
get root() {
|
|
937
|
+
return this._root;
|
|
938
|
+
}
|
|
939
|
+
get grid() {
|
|
940
|
+
return this._grid;
|
|
941
|
+
}
|
|
942
|
+
setBackground(t) {
|
|
943
|
+
this.background = new g(t);
|
|
944
|
+
}
|
|
945
|
+
computeSceneBB() {
|
|
946
|
+
return this._root.computeSceneBB();
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
const Gt = {
|
|
950
|
+
enableDamping: !0,
|
|
951
|
+
dampingFactor: 0.05,
|
|
952
|
+
enabled: !0,
|
|
953
|
+
target: new h(),
|
|
954
|
+
minDistance: 0,
|
|
955
|
+
maxDistance: 1 / 0,
|
|
956
|
+
minZoom: 0,
|
|
957
|
+
maxZoom: 1 / 0,
|
|
958
|
+
minPolarAngle: 0,
|
|
959
|
+
maxPolarAngle: Math.PI,
|
|
960
|
+
minAzimuthAngle: -1 / 0,
|
|
961
|
+
maxAzimuthAngle: 1 / 0,
|
|
962
|
+
enableZoom: !0,
|
|
963
|
+
zoomSpeed: 1,
|
|
964
|
+
enableRotate: !0,
|
|
965
|
+
rotateSpeed: 1,
|
|
966
|
+
enablePan: !0,
|
|
967
|
+
panSpeed: 1,
|
|
968
|
+
screenSpacePanning: !0,
|
|
969
|
+
keyPanSpeed: 7,
|
|
970
|
+
autoRotate: !1,
|
|
971
|
+
autoRotateSpeed: 2,
|
|
972
|
+
keys: {
|
|
973
|
+
LEFT: "ArrowLeft",
|
|
974
|
+
UP: "ArrowUp",
|
|
975
|
+
RIGHT: "ArrowRight",
|
|
976
|
+
BOTTOM: "ArrowDown"
|
|
977
|
+
},
|
|
978
|
+
mouseButtons: {
|
|
979
|
+
LEFT: m.ROTATE,
|
|
980
|
+
MIDDLE: m.DOLLY,
|
|
981
|
+
RIGHT: m.PAN
|
|
982
|
+
},
|
|
983
|
+
touches: {
|
|
984
|
+
ONE: f.ROTATE,
|
|
985
|
+
TWO: f.DOLLY_PAN
|
|
986
|
+
}
|
|
987
|
+
}, b = class b extends gt {
|
|
988
|
+
constructor(t, e, a) {
|
|
989
|
+
super();
|
|
990
|
+
// public API
|
|
991
|
+
i(this, "object");
|
|
992
|
+
i(this, "domElements");
|
|
993
|
+
i(this, "enabled", !0);
|
|
994
|
+
i(this, "target", new h());
|
|
995
|
+
i(this, "minDistance", 0);
|
|
996
|
+
i(this, "maxDistance", 1 / 0);
|
|
997
|
+
i(this, "minZoom", 0);
|
|
998
|
+
i(this, "maxZoom", 1 / 0);
|
|
999
|
+
i(this, "minPolarAngle", 0);
|
|
1000
|
+
// radians
|
|
1001
|
+
i(this, "maxPolarAngle", Math.PI);
|
|
1002
|
+
// radians
|
|
1003
|
+
i(this, "minAzimuthAngle", -1 / 0);
|
|
1004
|
+
// radians
|
|
1005
|
+
i(this, "maxAzimuthAngle", 1 / 0);
|
|
1006
|
+
// radians
|
|
1007
|
+
i(this, "enableDamping", !0);
|
|
1008
|
+
i(this, "dampingFactor", 0.05);
|
|
1009
|
+
i(this, "enableZoom", !0);
|
|
1010
|
+
i(this, "zoomSpeed", 1);
|
|
1011
|
+
i(this, "enableRotate", !0);
|
|
1012
|
+
i(this, "rotateSpeed", 1);
|
|
1013
|
+
i(this, "enablePan", !0);
|
|
1014
|
+
i(this, "panSpeed", 1);
|
|
1015
|
+
i(this, "screenSpacePanning", !0);
|
|
1016
|
+
i(this, "keyPanSpeed", 7);
|
|
1017
|
+
i(this, "autoRotate", !1);
|
|
1018
|
+
i(this, "autoRotateSpeed", 2);
|
|
1019
|
+
i(this, "keys", {
|
|
1020
|
+
LEFT: "ArrowLeft",
|
|
1021
|
+
UP: "ArrowUp",
|
|
1022
|
+
RIGHT: "ArrowRight",
|
|
1023
|
+
BOTTOM: "ArrowDown"
|
|
1024
|
+
});
|
|
1025
|
+
i(this, "mouseButtons", {
|
|
1026
|
+
LEFT: m.ROTATE,
|
|
1027
|
+
MIDDLE: m.DOLLY,
|
|
1028
|
+
RIGHT: m.PAN
|
|
1029
|
+
});
|
|
1030
|
+
i(this, "touches", { ONE: f.ROTATE, TWO: f.DOLLY_PAN });
|
|
1031
|
+
i(this, "target0");
|
|
1032
|
+
i(this, "position0");
|
|
1033
|
+
i(this, "zoom0");
|
|
1034
|
+
i(this, "uuid", S.generateUUID());
|
|
1035
|
+
// private state
|
|
1036
|
+
i(this, "state", -1);
|
|
1037
|
+
i(this, "EPS", 1e-6);
|
|
1038
|
+
i(this, "spherical", new C());
|
|
1039
|
+
i(this, "sphericalDelta", new C());
|
|
1040
|
+
i(this, "scale", 1);
|
|
1041
|
+
i(this, "panOffset", new h());
|
|
1042
|
+
i(this, "zoomChanged", !1);
|
|
1043
|
+
i(this, "rotateStart", new p());
|
|
1044
|
+
i(this, "rotateEnd", new p());
|
|
1045
|
+
i(this, "rotateDelta", new p());
|
|
1046
|
+
i(this, "panStart", new p());
|
|
1047
|
+
i(this, "panEnd", new p());
|
|
1048
|
+
i(this, "panDelta", new p());
|
|
1049
|
+
i(this, "dollyStart", new p());
|
|
1050
|
+
i(this, "dollyEnd", new p());
|
|
1051
|
+
i(this, "dollyDelta", new p());
|
|
1052
|
+
i(this, "pointers", []);
|
|
1053
|
+
i(this, "pointerPositions", {});
|
|
1054
|
+
// for update() function
|
|
1055
|
+
i(this, "offset", new h());
|
|
1056
|
+
i(this, "quat");
|
|
1057
|
+
i(this, "quatInverse");
|
|
1058
|
+
i(this, "lastPosition", new h());
|
|
1059
|
+
i(this, "lastQuaternion", new T());
|
|
1060
|
+
i(this, "lastTarget", new h());
|
|
1061
|
+
i(this, "panLeft", (() => {
|
|
1062
|
+
const t = new h();
|
|
1063
|
+
return (e, a) => {
|
|
1064
|
+
t.setFromMatrixColumn(a, 0), t.multiplyScalar(-e), this.panOffset.add(t);
|
|
1065
|
+
};
|
|
1066
|
+
})());
|
|
1067
|
+
i(this, "panUp", (() => {
|
|
1068
|
+
const t = new h();
|
|
1069
|
+
return (e, a) => {
|
|
1070
|
+
this.screenSpacePanning === !0 ? t.setFromMatrixColumn(a, 1) : (t.setFromMatrixColumn(a, 0), t.crossVectors(this.object.up, t)), t.multiplyScalar(e), this.panOffset.add(t);
|
|
1071
|
+
};
|
|
1072
|
+
})());
|
|
1073
|
+
i(this, "onMouseDown", (t) => {
|
|
1074
|
+
let e;
|
|
1075
|
+
switch (t.button) {
|
|
1076
|
+
case 0:
|
|
1077
|
+
e = this.mouseButtons.LEFT;
|
|
1078
|
+
break;
|
|
1079
|
+
case 1:
|
|
1080
|
+
e = this.mouseButtons.MIDDLE;
|
|
1081
|
+
break;
|
|
1082
|
+
case 2:
|
|
1083
|
+
e = this.mouseButtons.RIGHT;
|
|
1084
|
+
break;
|
|
1085
|
+
default:
|
|
1086
|
+
e = -1;
|
|
1087
|
+
}
|
|
1088
|
+
switch (e) {
|
|
1089
|
+
case m.DOLLY:
|
|
1090
|
+
if (this.enableZoom === !1) return;
|
|
1091
|
+
this.handleMouseDownDolly(t), this.state = 1;
|
|
1092
|
+
break;
|
|
1093
|
+
case m.ROTATE:
|
|
1094
|
+
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
1095
|
+
if (this.enablePan === !1) return;
|
|
1096
|
+
this.handleMouseDownPan(t), this.state = 2;
|
|
1097
|
+
} else {
|
|
1098
|
+
if (this.enableRotate === !1) return;
|
|
1099
|
+
this.handleMouseDownRotate(t), this.state = 0;
|
|
1100
|
+
}
|
|
1101
|
+
break;
|
|
1102
|
+
case m.PAN:
|
|
1103
|
+
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
1104
|
+
if (this.enableRotate === !1) return;
|
|
1105
|
+
this.handleMouseDownRotate(t), this.state = 0;
|
|
1106
|
+
} else {
|
|
1107
|
+
if (this.enablePan === !1) return;
|
|
1108
|
+
this.handleMouseDownPan(t), this.state = 2;
|
|
1109
|
+
}
|
|
1110
|
+
break;
|
|
1111
|
+
default:
|
|
1112
|
+
this.state = -1;
|
|
1113
|
+
}
|
|
1114
|
+
this.state !== -1 && this.dispatchEvent({ type: "start" });
|
|
1115
|
+
});
|
|
1116
|
+
i(this, "onMouseMove", (t) => {
|
|
1117
|
+
if (this.enabled !== !1)
|
|
1118
|
+
switch (this.state) {
|
|
1119
|
+
case 0:
|
|
1120
|
+
if (this.enableRotate === !1) return;
|
|
1121
|
+
this.handleMouseMoveRotate(t);
|
|
1122
|
+
break;
|
|
1123
|
+
case 1:
|
|
1124
|
+
if (this.enableZoom === !1) return;
|
|
1125
|
+
this.handleMouseMoveDolly(t);
|
|
1126
|
+
break;
|
|
1127
|
+
case 2:
|
|
1128
|
+
if (this.enablePan === !1) return;
|
|
1129
|
+
this.handleMouseMovePan(t);
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
i(this, "onMouseWheel", (t) => {
|
|
1134
|
+
this.enabled === !1 || this.enableZoom === !1 || this.state !== -1 || (t.preventDefault(), this.dispatchEvent({ type: "start" }), this.handleMouseWheel(t), this.dispatchEvent({ type: "end" }));
|
|
1135
|
+
});
|
|
1136
|
+
i(this, "onKeyDown", (t) => {
|
|
1137
|
+
this.enabled === !1 || this.enablePan === !1 || this.handleKeyDown(t);
|
|
1138
|
+
});
|
|
1139
|
+
i(this, "onTouchStart", (t) => {
|
|
1140
|
+
switch (this.trackPointer(t), this.pointers.length) {
|
|
1141
|
+
case 1:
|
|
1142
|
+
switch (this.touches.ONE) {
|
|
1143
|
+
case f.ROTATE:
|
|
1144
|
+
if (this.enableRotate === !1) return;
|
|
1145
|
+
this.handleTouchStartRotate(t), this.state = 3;
|
|
1146
|
+
break;
|
|
1147
|
+
case f.PAN:
|
|
1148
|
+
if (this.enablePan === !1) return;
|
|
1149
|
+
this.handleTouchStartPan(t), this.state = 4;
|
|
1150
|
+
break;
|
|
1151
|
+
default:
|
|
1152
|
+
this.state = -1;
|
|
1153
|
+
}
|
|
1154
|
+
break;
|
|
1155
|
+
case 2:
|
|
1156
|
+
switch (this.touches.TWO) {
|
|
1157
|
+
case f.DOLLY_PAN:
|
|
1158
|
+
if (this.enableZoom === !1 && this.enablePan === !1)
|
|
1159
|
+
return;
|
|
1160
|
+
this.handleTouchStartDollyPan(t), this.state = 5;
|
|
1161
|
+
break;
|
|
1162
|
+
case f.DOLLY_ROTATE:
|
|
1163
|
+
if (this.enableZoom === !1 && this.enableRotate === !1)
|
|
1164
|
+
return;
|
|
1165
|
+
this.handleTouchStartDollyRotate(t), this.state = 6;
|
|
1166
|
+
break;
|
|
1167
|
+
default:
|
|
1168
|
+
this.state = -1;
|
|
1169
|
+
}
|
|
1170
|
+
break;
|
|
1171
|
+
default:
|
|
1172
|
+
this.state = -1;
|
|
1173
|
+
}
|
|
1174
|
+
this.state !== -1 && this.dispatchEvent({ type: "start" });
|
|
1175
|
+
});
|
|
1176
|
+
i(this, "onTouchMove", (t) => {
|
|
1177
|
+
switch (this.trackPointer(t), this.state) {
|
|
1178
|
+
case 3:
|
|
1179
|
+
if (this.enableRotate === !1) return;
|
|
1180
|
+
this.handleTouchMoveRotate(t), this.update();
|
|
1181
|
+
break;
|
|
1182
|
+
case 4:
|
|
1183
|
+
if (this.enablePan === !1) return;
|
|
1184
|
+
this.handleTouchMovePan(t), this.update();
|
|
1185
|
+
break;
|
|
1186
|
+
case 5:
|
|
1187
|
+
if (this.enableZoom === !1 && this.enablePan === !1)
|
|
1188
|
+
return;
|
|
1189
|
+
this.handleTouchMoveDollyPan(t), this.update();
|
|
1190
|
+
break;
|
|
1191
|
+
case 6:
|
|
1192
|
+
if (this.enableZoom === !1 && this.enableRotate === !1)
|
|
1193
|
+
return;
|
|
1194
|
+
this.handleTouchMoveDollyRotate(t), this.update();
|
|
1195
|
+
break;
|
|
1196
|
+
default:
|
|
1197
|
+
this.state = -1;
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
i(this, "onPointerDown", (t) => {
|
|
1201
|
+
if (this.enabled !== !1) {
|
|
1202
|
+
if (this.pointers.length === 0) {
|
|
1203
|
+
const e = t.currentTarget;
|
|
1204
|
+
e.setPointerCapture(t.pointerId), e.addEventListener("pointermove", this.onPointerMove), e.addEventListener("pointerup", this.onPointerUp);
|
|
1205
|
+
}
|
|
1206
|
+
this.isTrackingPointer(t) || (this.addPointer(t), t.pointerType === "touch" ? this.onTouchStart(t) : this.onMouseDown(t));
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
i(this, "onPointerMove", (t) => {
|
|
1210
|
+
this.enabled !== !1 && (t.pointerType === "touch" ? this.onTouchMove(t) : this.onMouseMove(t));
|
|
1211
|
+
});
|
|
1212
|
+
i(this, "onPointerUp", (t) => {
|
|
1213
|
+
if (this.removePointer(t), this.pointers.length === 0) {
|
|
1214
|
+
const e = t.currentTarget;
|
|
1215
|
+
e.releasePointerCapture(t.pointerId), e.removeEventListener("pointermove", this.onPointerMove), e.removeEventListener("pointerup", this.onPointerUp), this.dispatchEvent({ type: "end" }), this.state = -1;
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
i(this, "onPointerCancel", (t) => {
|
|
1219
|
+
this.removePointer(t);
|
|
1220
|
+
});
|
|
1221
|
+
i(this, "onContextMenu", (t) => {
|
|
1222
|
+
this.enabled !== !1 && t.preventDefault();
|
|
1223
|
+
});
|
|
1224
|
+
this.object = t, this.domElements = Array.isArray(e) ? e : [e], Object.assign(this, a), this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this.quat = new T().setFromUnitVectors(
|
|
1225
|
+
t.up,
|
|
1226
|
+
new h(0, 1, 0)
|
|
1227
|
+
), this.quatInverse = this.quat.clone().invert(), this.domElements.forEach((n) => this.addEventListeners(n)), this.update();
|
|
1228
|
+
}
|
|
1229
|
+
get domElement() {
|
|
1230
|
+
return this.domElements[0];
|
|
1231
|
+
}
|
|
1232
|
+
tick() {
|
|
1233
|
+
this.enabled && this.update();
|
|
1234
|
+
}
|
|
1235
|
+
getPolarAngle() {
|
|
1236
|
+
return this.spherical.phi;
|
|
1237
|
+
}
|
|
1238
|
+
getAzimuthalAngle() {
|
|
1239
|
+
return this.spherical.theta;
|
|
1240
|
+
}
|
|
1241
|
+
getDistance() {
|
|
1242
|
+
return this.object.position.distanceTo(this.target);
|
|
1243
|
+
}
|
|
1244
|
+
saveState() {
|
|
1245
|
+
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
|
|
1246
|
+
}
|
|
1247
|
+
reset() {
|
|
1248
|
+
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent({ type: "change" }), this.update(), this.state = -1;
|
|
1249
|
+
}
|
|
1250
|
+
update() {
|
|
1251
|
+
return this.offset.copy(this.object.position).sub(this.target), this.offset.applyQuaternion(this.quat), this.spherical.setFromVector3(this.offset), this.autoRotate && this.state === -1 && this.rotateLeft(this.getAutoRotationAngle()), this.enableDamping ? (this.spherical.theta += this.sphericalDelta.theta * this.dampingFactor, this.spherical.phi += this.sphericalDelta.phi * this.dampingFactor) : (this.spherical.theta += this.sphericalDelta.theta, this.spherical.phi += this.sphericalDelta.phi), this.spherical.theta = Math.max(
|
|
1252
|
+
this.minAzimuthAngle,
|
|
1253
|
+
Math.min(this.maxAzimuthAngle, this.spherical.theta)
|
|
1254
|
+
), this.spherical.phi = Math.max(
|
|
1255
|
+
this.minPolarAngle,
|
|
1256
|
+
Math.min(this.maxPolarAngle, this.spherical.phi)
|
|
1257
|
+
), this.spherical.makeSafe(), this.spherical.radius *= this.scale, this.spherical.radius = Math.max(
|
|
1258
|
+
this.minDistance,
|
|
1259
|
+
Math.min(this.maxDistance, this.spherical.radius)
|
|
1260
|
+
), this.enableDamping === !0 ? this.target.addScaledVector(this.panOffset, this.dampingFactor) : this.target.add(this.panOffset), this.offset.setFromSpherical(this.spherical), this.offset.applyQuaternion(this.quatInverse), this.object.position.copy(this.target).add(this.offset), this.object.lookAt(this.target), this.enableDamping === !0 ? (this.sphericalDelta.theta *= 1 - this.dampingFactor, this.sphericalDelta.phi *= 1 - this.dampingFactor, this.panOffset.multiplyScalar(1 - this.dampingFactor)) : (this.sphericalDelta.set(0, 0, 0), this.panOffset.set(0, 0, 0)), this.scale = 1, this.zoomChanged || this.lastPosition.distanceToSquared(this.object.position) > this.EPS || 8 * (1 - this.lastQuaternion.dot(this.object.quaternion)) > this.EPS || this.lastTarget.distanceToSquared(this.target) > this.EPS ? (this.dispatchEvent({ type: "change" }), this.lastPosition.copy(this.object.position), this.lastQuaternion.copy(this.object.quaternion), this.lastTarget.copy(this.target), this.zoomChanged = !1, !0) : !1;
|
|
1261
|
+
}
|
|
1262
|
+
dispose() {
|
|
1263
|
+
this.domElements.forEach(
|
|
1264
|
+
(t) => this.removeEventListeners(t)
|
|
1265
|
+
), this.dispatchEvent({ type: "dispose" });
|
|
1266
|
+
}
|
|
1267
|
+
addDomElements(...t) {
|
|
1268
|
+
t.forEach((e) => {
|
|
1269
|
+
this.domElements.includes(e) || (this.domElements.push(e), this.addEventListeners(e));
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
removeDomElements(...t) {
|
|
1273
|
+
t.forEach((e) => {
|
|
1274
|
+
const a = this.domElements.indexOf(e);
|
|
1275
|
+
a > -1 && (this.removeEventListeners(e), this.domElements.splice(a, 1));
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
setDomElements(...t) {
|
|
1279
|
+
this.removeDomElements(...this.domElements), this.domElements = [], this.addDomElements(...t);
|
|
1280
|
+
}
|
|
1281
|
+
computeEncompassingView(t, e = 0) {
|
|
1282
|
+
const a = t.center, o = t.sphere.radius, l = this.object.fov * (Math.PI / 180), c = this.object.aspect, d = l / 2, u = Math.atan(Math.tan(d) * c), q = o / Math.sin(d), K = o / Math.sin(u), Q = Math.max(q, K) * (1 + e), R = this.object.position.clone().sub(this.target).normalize(), J = R.length() > 1e-3 ? R : new h(0, 0, 1);
|
|
1283
|
+
return {
|
|
1284
|
+
position: a.clone().add(J.multiplyScalar(Q)),
|
|
1285
|
+
target: a
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
focusObject(t, e = 0) {
|
|
1289
|
+
const a = new Xt(t), n = this.computeEncompassingView(a, e);
|
|
1290
|
+
this.object.position.copy(n.position), this.target.copy(n.target), this.update();
|
|
1291
|
+
}
|
|
1292
|
+
zoomIn(t) {
|
|
1293
|
+
this.dollyIn(Math.pow(0.95, t ?? b.DEFAULT_ZOOM_FACTOR)), this.update();
|
|
1294
|
+
}
|
|
1295
|
+
zoomOut(t) {
|
|
1296
|
+
this.dollyOut(
|
|
1297
|
+
Math.pow(0.95, t ?? b.DEFAULT_ZOOM_FACTOR)
|
|
1298
|
+
), this.update();
|
|
1299
|
+
}
|
|
1300
|
+
getState() {
|
|
1301
|
+
return {
|
|
1302
|
+
target: this.target.clone(),
|
|
1303
|
+
azimuthalAngle: this.getAzimuthalAngle(),
|
|
1304
|
+
polarAngle: this.getPolarAngle(),
|
|
1305
|
+
distance: this.getDistance(),
|
|
1306
|
+
position: this.object.position.clone(),
|
|
1307
|
+
quaternion: this.object.quaternion.clone()
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
setState(t) {
|
|
1311
|
+
this.target.copy(t.target), this.object.position.copy(t.position), this.object.quaternion.copy(t.quaternion), this.update();
|
|
1312
|
+
}
|
|
1313
|
+
//
|
|
1314
|
+
// Private methods
|
|
1315
|
+
//
|
|
1316
|
+
addEventListeners(t) {
|
|
1317
|
+
t.style.touchAction = "none", t.addEventListener("contextmenu", this.onContextMenu), t.addEventListener("pointerdown", this.onPointerDown), t.addEventListener("pointercancel", this.onPointerCancel), t.addEventListener("wheel", this.onMouseWheel, {
|
|
1318
|
+
passive: !1
|
|
1319
|
+
}), t.addEventListener("keydown", this.onKeyDown);
|
|
1320
|
+
}
|
|
1321
|
+
removeEventListeners(t) {
|
|
1322
|
+
t.removeEventListener("contextmenu", this.onContextMenu), t.removeEventListener("pointerdown", this.onPointerDown), t.removeEventListener("pointercancel", this.onPointerCancel), t.removeEventListener("wheel", this.onMouseWheel), t.removeEventListener("keydown", this.onKeyDown), t.removeEventListener("pointermove", this.onPointerMove), t.removeEventListener("pointerup", this.onPointerUp);
|
|
1323
|
+
}
|
|
1324
|
+
getAutoRotationAngle() {
|
|
1325
|
+
return 2 * Math.PI / 60 / 60 * this.autoRotateSpeed;
|
|
1326
|
+
}
|
|
1327
|
+
getZoomScale() {
|
|
1328
|
+
return Math.pow(0.95, this.zoomSpeed);
|
|
1329
|
+
}
|
|
1330
|
+
rotateLeft(t) {
|
|
1331
|
+
this.sphericalDelta.theta -= t;
|
|
1332
|
+
}
|
|
1333
|
+
rotateUp(t) {
|
|
1334
|
+
this.sphericalDelta.phi -= t;
|
|
1335
|
+
}
|
|
1336
|
+
pan(t, e, a) {
|
|
1337
|
+
const n = new h();
|
|
1338
|
+
if ("isPerspectiveCamera" in this.object) {
|
|
1339
|
+
const o = this.object.position;
|
|
1340
|
+
n.copy(o).sub(this.target);
|
|
1341
|
+
let l = n.length();
|
|
1342
|
+
l *= Math.tan(
|
|
1343
|
+
this.object.fov / 2 * Math.PI / 180
|
|
1344
|
+
), this.panLeft(
|
|
1345
|
+
2 * t * l / a.clientHeight,
|
|
1346
|
+
this.object.matrix
|
|
1347
|
+
), this.panUp(
|
|
1348
|
+
2 * e * l / a.clientHeight,
|
|
1349
|
+
this.object.matrix
|
|
1350
|
+
);
|
|
1351
|
+
} else "isOrthographicCamera" in this.object ? (this.panLeft(
|
|
1352
|
+
t * (this.object.right - this.object.left) / this.object.zoom / a.clientWidth,
|
|
1353
|
+
this.object.matrix
|
|
1354
|
+
), this.panUp(
|
|
1355
|
+
e * (this.object.top - this.object.bottom) / this.object.zoom / a.clientHeight,
|
|
1356
|
+
this.object.matrix
|
|
1357
|
+
)) : (console.warn(
|
|
1358
|
+
"WARNING: OrbitController encountered an unknown camera type - pan disabled."
|
|
1359
|
+
), this.enablePan = !1);
|
|
1360
|
+
}
|
|
1361
|
+
dollyIn(t) {
|
|
1362
|
+
"isPerspectiveCamera" in this.object || "isOrthographicCamera" in this.object ? this.scale *= t : (console.warn(
|
|
1363
|
+
"WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."
|
|
1364
|
+
), this.enableZoom = !1);
|
|
1365
|
+
}
|
|
1366
|
+
dollyOut(t) {
|
|
1367
|
+
"isPerspectiveCamera" in this.object || "isOrthographicCamera" in this.object ? this.scale /= t : (console.warn(
|
|
1368
|
+
"WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."
|
|
1369
|
+
), this.enableZoom = !1);
|
|
1370
|
+
}
|
|
1371
|
+
// event callbacks
|
|
1372
|
+
handleMouseDownRotate(t) {
|
|
1373
|
+
this.rotateStart.set(t.clientX, t.clientY);
|
|
1374
|
+
}
|
|
1375
|
+
handleMouseDownDolly(t) {
|
|
1376
|
+
this.dollyStart.set(t.clientX, t.clientY);
|
|
1377
|
+
}
|
|
1378
|
+
handleMouseDownPan(t) {
|
|
1379
|
+
this.panStart.set(t.clientX, t.clientY);
|
|
1380
|
+
}
|
|
1381
|
+
handleMouseMoveRotate(t) {
|
|
1382
|
+
this.rotateEnd.set(t.clientX, t.clientY), this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
|
|
1383
|
+
const e = t.currentTarget;
|
|
1384
|
+
this.rotateLeft(
|
|
1385
|
+
2 * Math.PI * this.rotateDelta.x / e.clientHeight
|
|
1386
|
+
), this.rotateUp(
|
|
1387
|
+
2 * Math.PI * this.rotateDelta.y / e.clientHeight
|
|
1388
|
+
), this.rotateStart.copy(this.rotateEnd), this.update();
|
|
1389
|
+
}
|
|
1390
|
+
handleMouseMoveDolly(t) {
|
|
1391
|
+
this.dollyEnd.set(t.clientX, t.clientY), this.dollyDelta.subVectors(this.dollyEnd, this.dollyStart), this.dollyDelta.y > 0 ? this.dollyIn(this.getZoomScale()) : this.dollyDelta.y < 0 && this.dollyOut(this.getZoomScale()), this.dollyStart.copy(this.dollyEnd), this.update();
|
|
1392
|
+
}
|
|
1393
|
+
handleMouseMovePan(t) {
|
|
1394
|
+
const e = t.currentTarget;
|
|
1395
|
+
this.panEnd.set(t.clientX, t.clientY), this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y, e), this.panStart.copy(this.panEnd), this.update();
|
|
1396
|
+
}
|
|
1397
|
+
handleMouseWheel(t) {
|
|
1398
|
+
t.deltaY < 0 ? this.dollyIn(this.getZoomScale()) : t.deltaY > 0 && this.dollyOut(this.getZoomScale()), this.update();
|
|
1399
|
+
}
|
|
1400
|
+
handleKeyDown(t) {
|
|
1401
|
+
let e = !1;
|
|
1402
|
+
const a = t.currentTarget;
|
|
1403
|
+
switch (t.code) {
|
|
1404
|
+
case this.keys.UP:
|
|
1405
|
+
this.pan(0, this.keyPanSpeed, a), e = !0;
|
|
1406
|
+
break;
|
|
1407
|
+
case this.keys.BOTTOM:
|
|
1408
|
+
this.pan(0, -this.keyPanSpeed, a), e = !0;
|
|
1409
|
+
break;
|
|
1410
|
+
case this.keys.LEFT:
|
|
1411
|
+
this.pan(this.keyPanSpeed, 0, a), e = !0;
|
|
1412
|
+
break;
|
|
1413
|
+
case this.keys.RIGHT:
|
|
1414
|
+
this.pan(-this.keyPanSpeed, 0, a), e = !0;
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1417
|
+
e && (t.preventDefault(), this.update());
|
|
1418
|
+
}
|
|
1419
|
+
handleTouchStartRotate(t) {
|
|
1420
|
+
if (this.pointers.length === 1)
|
|
1421
|
+
this.rotateStart.set(t.pageX, t.pageY);
|
|
1422
|
+
else {
|
|
1423
|
+
const e = this.getSecondPointer(t), a = 0.5 * (t.pageX + e.pageX), n = 0.5 * (t.pageY + e.pageY);
|
|
1424
|
+
this.rotateStart.set(a, n);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
handleTouchStartPan(t) {
|
|
1428
|
+
if (this.pointers.length === 1)
|
|
1429
|
+
this.panStart.set(t.pageX, t.pageY);
|
|
1430
|
+
else {
|
|
1431
|
+
const e = this.getSecondPointer(t), a = 0.5 * (t.pageX + e.pageX), n = 0.5 * (t.pageY + e.pageY);
|
|
1432
|
+
this.panStart.set(a, n);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
handleTouchStartDolly(t) {
|
|
1436
|
+
const e = this.getSecondPointer(t), a = t.pageX - e.pageX, n = t.pageY - e.pageY, o = Math.sqrt(a * a + n * n);
|
|
1437
|
+
this.dollyStart.set(0, o);
|
|
1438
|
+
}
|
|
1439
|
+
handleTouchStartDollyPan(t) {
|
|
1440
|
+
this.enableZoom && this.handleTouchStartDolly(t), this.enablePan && this.handleTouchStartPan(t);
|
|
1441
|
+
}
|
|
1442
|
+
handleTouchStartDollyRotate(t) {
|
|
1443
|
+
this.enableZoom && this.handleTouchStartDolly(t), this.enableRotate && this.handleTouchStartRotate(t);
|
|
1444
|
+
}
|
|
1445
|
+
handleTouchMoveRotate(t) {
|
|
1446
|
+
if (this.pointers.length === 1)
|
|
1447
|
+
this.rotateEnd.set(t.pageX, t.pageY);
|
|
1448
|
+
else {
|
|
1449
|
+
const a = this.getSecondPointer(t), n = 0.5 * (t.pageX + a.pageX), o = 0.5 * (t.pageY + a.pageY);
|
|
1450
|
+
this.rotateEnd.set(n, o);
|
|
1451
|
+
}
|
|
1452
|
+
const e = t.currentTarget;
|
|
1453
|
+
this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed), this.rotateLeft(
|
|
1454
|
+
2 * Math.PI * this.rotateDelta.x / e.clientHeight
|
|
1455
|
+
), this.rotateUp(
|
|
1456
|
+
2 * Math.PI * this.rotateDelta.y / e.clientHeight
|
|
1457
|
+
), this.rotateStart.copy(this.rotateEnd);
|
|
1458
|
+
}
|
|
1459
|
+
handleTouchMovePan(t) {
|
|
1460
|
+
if (this.pointers.length === 1)
|
|
1461
|
+
this.panEnd.set(t.pageX, t.pageY);
|
|
1462
|
+
else {
|
|
1463
|
+
const a = this.getSecondPointer(t), n = 0.5 * (t.pageX + a.pageX), o = 0.5 * (t.pageY + a.pageY);
|
|
1464
|
+
this.panEnd.set(n, o);
|
|
1465
|
+
}
|
|
1466
|
+
const e = t.currentTarget;
|
|
1467
|
+
this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y, e), this.panStart.copy(this.panEnd);
|
|
1468
|
+
}
|
|
1469
|
+
handleTouchMoveDolly(t) {
|
|
1470
|
+
const e = this.getSecondPointer(t), a = t.pageX - e.pageX, n = t.pageY - e.pageY, o = Math.sqrt(a * a + n * n);
|
|
1471
|
+
this.dollyEnd.set(0, o), this.dollyDelta.set(
|
|
1472
|
+
0,
|
|
1473
|
+
Math.pow(this.dollyEnd.y / this.dollyStart.y, this.zoomSpeed)
|
|
1474
|
+
), this.dollyOut(this.dollyDelta.y), this.dollyStart.copy(this.dollyEnd);
|
|
1475
|
+
}
|
|
1476
|
+
handleTouchMoveDollyPan(t) {
|
|
1477
|
+
this.enableZoom && this.handleTouchMoveDolly(t), this.enablePan && this.handleTouchMovePan(t);
|
|
1478
|
+
}
|
|
1479
|
+
handleTouchMoveDollyRotate(t) {
|
|
1480
|
+
this.enableZoom && this.handleTouchMoveDolly(t), this.enableRotate && this.handleTouchMoveRotate(t);
|
|
1481
|
+
}
|
|
1482
|
+
addPointer(t) {
|
|
1483
|
+
this.pointers.push(t);
|
|
1484
|
+
}
|
|
1485
|
+
removePointer(t) {
|
|
1486
|
+
delete this.pointerPositions[t.pointerId];
|
|
1487
|
+
for (let e = 0; e < this.pointers.length; e++)
|
|
1488
|
+
if (this.pointers[e].pointerId == t.pointerId) {
|
|
1489
|
+
this.pointers.splice(e, 1);
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
trackPointer(t) {
|
|
1494
|
+
let e = this.pointerPositions[t.pointerId];
|
|
1495
|
+
e === void 0 && (e = new p(), this.pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
|
|
1496
|
+
}
|
|
1497
|
+
getSecondPointer(t) {
|
|
1498
|
+
return this.pointers[0].pointerId === t.pointerId ? this.pointers[1] : this.pointers[0];
|
|
1499
|
+
}
|
|
1500
|
+
isTrackingPointer(t) {
|
|
1501
|
+
return this.pointers.some(
|
|
1502
|
+
(e) => e.pointerId === t.pointerId
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
i(b, "DEFAULT_ZOOM_FACTOR", 1);
|
|
1507
|
+
let z = b;
|
|
1508
|
+
class Ft extends w {
|
|
1509
|
+
constructor() {
|
|
1510
|
+
super();
|
|
1511
|
+
i(this, "_axesHelper");
|
|
1512
|
+
this._axesHelper = new _t(0.5), this._axesHelper.layers.mask = y, this._axesHelper.material.depthTest = !1, this._axesHelper.position.set(0, 0, -1), this._axesHelper.setColors(
|
|
1513
|
+
new g(Wt),
|
|
1514
|
+
new g(Zt),
|
|
1515
|
+
new g(Nt)
|
|
1516
|
+
);
|
|
1517
|
+
const t = new x("X", 0.2, Z), e = new x("Y", 0.2, N), a = new x("Z", 0.2, X);
|
|
1518
|
+
t.layers.mask = y, e.layers.mask = y, a.layers.mask = y, t.position.set(0.7, 0, 0), e.position.set(0, 0.7, 0), a.position.set(0, 0, 0.7), this._axesHelper.add(t), this._axesHelper.add(e), this._axesHelper.add(a);
|
|
1519
|
+
}
|
|
1520
|
+
setFromCameraMatrix(t) {
|
|
1521
|
+
this._axesHelper.rotation.setFromRotationMatrix(
|
|
1522
|
+
new ft().extractRotation(t).invert()
|
|
1523
|
+
);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
class Ut {
|
|
1527
|
+
constructor(s, t, e) {
|
|
1528
|
+
i(this, "uuid", S.generateUUID());
|
|
1529
|
+
i(this, "_axes");
|
|
1530
|
+
i(this, "_orthographicCamera");
|
|
1531
|
+
i(this, "_restoreViewport", new yt());
|
|
1532
|
+
this._renderer = s, this._scene = t, this._camera = e, this._orthographicCamera = new wt(
|
|
1533
|
+
-1,
|
|
1534
|
+
1,
|
|
1535
|
+
1,
|
|
1536
|
+
-1,
|
|
1537
|
+
0.1,
|
|
1538
|
+
100
|
|
1539
|
+
), this._orthographicCamera.layers.mask = y, this._scene.add(this._orthographicCamera), this._axes = new Ft(), this._scene.add(this._axes);
|
|
1540
|
+
}
|
|
1541
|
+
tick() {
|
|
1542
|
+
const s = this._scene.background;
|
|
1543
|
+
this._scene.background = null, this._renderer.webglrenderer.getViewport(this._restoreViewport), this._renderer.webglrenderer.setViewport(0, 0, 150, 150), this._renderer.webglrenderer.autoClear = !1, this._axes.setFromCameraMatrix(this._camera.matrix), this._renderer.webglrenderer.render(
|
|
1544
|
+
this._scene,
|
|
1545
|
+
this._orthographicCamera
|
|
1546
|
+
), this._renderer.webglrenderer.setViewport(this._restoreViewport), this._renderer.webglrenderer.autoClear = !0, this._scene.background = s;
|
|
1547
|
+
}
|
|
1548
|
+
dispose() {
|
|
1549
|
+
this._scene.remove(this._axes), this._scene.remove(this._orthographicCamera);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
const Ht = `
|
|
1553
|
+
@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
|
|
1554
|
+
@@@@+-:::::::---------------------==------------------------------=#@@@@
|
|
1555
|
+
@@%=::::.......::---------------------------------------------------------+@@
|
|
1556
|
+
@@+:::...........::-----------------------------------------------------------#@@
|
|
1557
|
+
@@=:::.........::::::-------------------------------------------------------------%@
|
|
1558
|
+
@%:::.......:::::::-----------------------------------------------------------------#@
|
|
1559
|
+
@*:::.....:::::-----------------------------------------------------------------------*@
|
|
1560
|
+
@%::::::.::::---------------------------------------------------------------------------@@
|
|
1561
|
+
@@-:::::::::-----------------------------------------------------------------------------=@
|
|
1562
|
+
@%::::::::--------------------------------------------------------------------------------%@
|
|
1563
|
+
@+::::::::--------------------------------=@@@@@%-----------------------------------------%@
|
|
1564
|
+
@=:::::::--------------------------------*@@ @@+---------------------------------------#@
|
|
1565
|
+
@+:::::::-------------------------------*@ @*--------------------------------------%@
|
|
1566
|
+
@#::::::::-----------------------------=@@ @@=-------------------------------------%@
|
|
1567
|
+
@@-::::::::----------------------------@@ @@------------------------------------=@
|
|
1568
|
+
@%:::::::::--------------------------*@ @*-----------------------------------@@
|
|
1569
|
+
@*:::::::::-------------------------@@ @@----------------------------------%@
|
|
1570
|
+
@#::::::::::----------------------%@ @%--------------------------------%@
|
|
1571
|
+
@#:::::::::::-------------------=@@ @@=------------------------------%@
|
|
1572
|
+
@@-::::::::::::----------------%@ @%----------------------------=@@
|
|
1573
|
+
@@#::::::::::::::------------*@ @*--------------------------#@@
|
|
1574
|
+
@@+::::::::::::::::--------@@ @@------------------------+@@
|
|
1575
|
+
@@*:::::::::::::::::----@@ @@---------------------+@@
|
|
1576
|
+
@@@-:::::::::::::::--#@ @#-----------------=%@@
|
|
1577
|
+
@@%-::::::::::::-%@ @%-------------=%@@
|
|
1578
|
+
@@@@+:::::::#@@ @@*-------*@@@@
|
|
1579
|
+
@@@@@@@ @@@@@@
|
|
1580
|
+
`;
|
|
1581
|
+
window.DIVE = {
|
|
1582
|
+
instances: [],
|
|
1583
|
+
get instance() {
|
|
1584
|
+
return window.DIVE.instances[0];
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
const D = {
|
|
1588
|
+
autoStart: !0,
|
|
1589
|
+
displayAxes: !1,
|
|
1590
|
+
...E,
|
|
1591
|
+
...Pt,
|
|
1592
|
+
...Y,
|
|
1593
|
+
...Gt
|
|
1594
|
+
};
|
|
1595
|
+
class Yt {
|
|
1596
|
+
constructor(s) {
|
|
1597
|
+
// descriptive members
|
|
1598
|
+
i(this, "_instanceId", S.generateUUID());
|
|
1599
|
+
i(this, "_settings");
|
|
1600
|
+
i(this, "_views");
|
|
1601
|
+
i(this, "_mainView");
|
|
1602
|
+
i(this, "_scene");
|
|
1603
|
+
i(this, "_clock");
|
|
1604
|
+
i(this, "orientationDisplay");
|
|
1605
|
+
this._settings = {
|
|
1606
|
+
...D,
|
|
1607
|
+
...s ?? {}
|
|
1608
|
+
}, this._clock = new vt(), this._scene = new zt(), this.scene.setBackground(
|
|
1609
|
+
(s == null ? void 0 : s.backgroundColor) ?? D.backgroundColor
|
|
1610
|
+
), this.scene.grid.setVisibility(
|
|
1611
|
+
(s == null ? void 0 : s.displayGrid) ?? D.displayGrid
|
|
1612
|
+
), this.scene.root.floor.setVisibility(
|
|
1613
|
+
(s == null ? void 0 : s.displayFloor) ?? D.displayFloor
|
|
1614
|
+
);
|
|
1615
|
+
const t = new B(
|
|
1616
|
+
this._scene,
|
|
1617
|
+
new O(),
|
|
1618
|
+
this._settings
|
|
1619
|
+
);
|
|
1620
|
+
this._clock.addTicker(t), this._views = [t], this._mainView = t, this._settings.autoStart && this.start(), this._settings.displayAxes ? (console.log("displayAxes", this._settings.displayAxes), this.orientationDisplay = new Ut(
|
|
1621
|
+
this.mainView.renderer,
|
|
1622
|
+
this.scene,
|
|
1623
|
+
this.mainView.camera
|
|
1624
|
+
), this.clock.addTicker(this.orientationDisplay)) : this.orientationDisplay = null, console.log("DIVE 2.1.1 initialized successfully!"), console.log(Ht), window.DIVE.instances.push(this);
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* @deprecated This static method will be removed in a future version. Please use `import { QuickView, QuickViewSettings, QuickViewDefaultSettings } from '@shopware-ag/dive/quickview'` instead.
|
|
1628
|
+
*/
|
|
1629
|
+
static async QuickView(s, t) {
|
|
1630
|
+
return import("../plugins/quickview/index.mjs").then(
|
|
1631
|
+
({ QuickView: e }) => e(s, t)
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* @deprecated This property will be removed in a future version. Please use properties on the DIVE instance and mainView directly.
|
|
1636
|
+
*/
|
|
1637
|
+
get engine() {
|
|
1638
|
+
return Object.assign(this, {
|
|
1639
|
+
camera: this.mainView.camera,
|
|
1640
|
+
renderer: this.mainView.renderer,
|
|
1641
|
+
setCanvas: (s) => {
|
|
1642
|
+
this.mainView.setCanvas(s);
|
|
1643
|
+
},
|
|
1644
|
+
start: () => {
|
|
1645
|
+
this.start();
|
|
1646
|
+
},
|
|
1647
|
+
stop: () => {
|
|
1648
|
+
this.stop();
|
|
1649
|
+
},
|
|
1650
|
+
dispose: () => {
|
|
1651
|
+
this.dispose();
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
get views() {
|
|
1656
|
+
return this._views;
|
|
1657
|
+
}
|
|
1658
|
+
get mainView() {
|
|
1659
|
+
return this._mainView;
|
|
1660
|
+
}
|
|
1661
|
+
get canvas() {
|
|
1662
|
+
return this.mainView.canvas;
|
|
1663
|
+
}
|
|
1664
|
+
get scene() {
|
|
1665
|
+
return this._scene;
|
|
1666
|
+
}
|
|
1667
|
+
get clock() {
|
|
1668
|
+
return this._clock;
|
|
1669
|
+
}
|
|
1670
|
+
start() {
|
|
1671
|
+
this._clock.start();
|
|
1672
|
+
}
|
|
1673
|
+
stop() {
|
|
1674
|
+
this._clock.stop();
|
|
1675
|
+
}
|
|
1676
|
+
async dispose() {
|
|
1677
|
+
return new Promise((s) => {
|
|
1678
|
+
this._views.forEach((t) => {
|
|
1679
|
+
t.dispose();
|
|
1680
|
+
}), this._views = [], this.orientationDisplay && (this._clock.removeTicker(this.orientationDisplay), this.orientationDisplay.dispose()), window.DIVE.instances = window.DIVE.instances.filter(
|
|
1681
|
+
(t) => t._instanceId !== this._instanceId
|
|
1682
|
+
), s();
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
createView(s) {
|
|
1686
|
+
const t = new B(
|
|
1687
|
+
this._scene,
|
|
1688
|
+
s ?? new O(),
|
|
1689
|
+
{
|
|
1690
|
+
...this._settings,
|
|
1691
|
+
canvas: void 0
|
|
1692
|
+
// instantiate new canvas for created view
|
|
1693
|
+
}
|
|
1694
|
+
);
|
|
1695
|
+
return this._views.push(t), this._clock.addTicker(t), this._views.length === 1 && (this._mainView = t), t;
|
|
1696
|
+
}
|
|
1697
|
+
disposeView(s) {
|
|
1698
|
+
this._views = this._views.filter((t) => t !== s), this._clock.removeTicker(s), this._mainView === s && (this._mainView = this._views[0]), s.dispose();
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
const ee = Yt, Z = "#c20017", N = "#00ab26", X = "#0081d4", Wt = Z, Zt = N, Nt = X;
|
|
1702
|
+
class Xt extends v {
|
|
1703
|
+
/**
|
|
1704
|
+
* Creates a new BoundingBox instance for the specified 3D object.
|
|
1705
|
+
*
|
|
1706
|
+
* The constructor computes both a bounding box and bounding sphere for the given object.
|
|
1707
|
+
* It handles complex objects with multiple meshes and nested transformations.
|
|
1708
|
+
*
|
|
1709
|
+
* @param object - The 3D object to compute bounding volumes for
|
|
1710
|
+
* @param axisAligned - Whether to create an axis-aligned bounding box (true) or oriented bounding box (false). Defaults to false.
|
|
1711
|
+
* @param wireframeColor - The color for the wireframe helpers. Can be a hex number or ColorRepresentation. Defaults to green (0x00ff00).
|
|
1712
|
+
*
|
|
1713
|
+
* @example
|
|
1714
|
+
* ```typescript
|
|
1715
|
+
* // Create an oriented bounding box (aligned with object's rotation)
|
|
1716
|
+
* const obb = new BoundingBox(mesh, false, 0x00ff00);
|
|
1717
|
+
*
|
|
1718
|
+
* // Create an axis-aligned bounding box (aligned with world coordinates)
|
|
1719
|
+
* const aabb = new BoundingBox(mesh, true, 0xff0000);
|
|
1720
|
+
*
|
|
1721
|
+
* // Use default green color
|
|
1722
|
+
* const defaultBox = new BoundingBox(mesh);
|
|
1723
|
+
* ```
|
|
1724
|
+
*/
|
|
1725
|
+
constructor(t, e = !1, a = 65280) {
|
|
1726
|
+
super();
|
|
1727
|
+
/** The computed bounding box (Box3) */
|
|
1728
|
+
i(this, "_box");
|
|
1729
|
+
/** The computed bounding sphere (Sphere) */
|
|
1730
|
+
i(this, "_sphere");
|
|
1731
|
+
/** The center point of the bounding box */
|
|
1732
|
+
i(this, "_center");
|
|
1733
|
+
/** The radius of the bounding sphere */
|
|
1734
|
+
i(this, "_radius");
|
|
1735
|
+
/** Visual helper for the bounding box wireframe */
|
|
1736
|
+
i(this, "_boxHelper");
|
|
1737
|
+
/** Visual helper for the bounding sphere wireframe */
|
|
1738
|
+
i(this, "_sphereHelper");
|
|
1739
|
+
/** The dimensions (width, height, depth) of the bounding box */
|
|
1740
|
+
i(this, "_size");
|
|
1741
|
+
const n = new L();
|
|
1742
|
+
e ? n.setFromObject(t) : (t.updateWorldMatrix(!0, !0), t.traverse((l) => {
|
|
1743
|
+
if (l.isMesh) {
|
|
1744
|
+
const c = l, d = c.geometry.clone();
|
|
1745
|
+
d.applyMatrix4(c.matrixWorld);
|
|
1746
|
+
const u = c.getWorldQuaternion(new T()).invert();
|
|
1747
|
+
d.applyQuaternion(u), d.computeBoundingBox(), d.boundingBox && n.union(d.boundingBox);
|
|
1748
|
+
}
|
|
1749
|
+
})), this.rotation.copy(t.rotation), this._box = n, this._size = n.getSize(new h()), this._center = n.getCenter(new h()), this._boxHelper = new bt(this._box, a), this._boxHelper.visible = !1, this.add(this._boxHelper), this._sphere = n.getBoundingSphere(new Dt()), this._radius = this._sphere.radius;
|
|
1750
|
+
const o = new I(this._radius, 32, 32);
|
|
1751
|
+
o.translate(this._center.x, this._center.y, this._center.z), this._sphereHelper = new P(
|
|
1752
|
+
o,
|
|
1753
|
+
new G({ color: a, wireframe: !0 })
|
|
1754
|
+
), this._sphereHelper.visible = !1, this.add(this._sphereHelper);
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Gets the computed bounding box.
|
|
1758
|
+
* @returns The Box3 instance representing the bounding box
|
|
1759
|
+
*/
|
|
1760
|
+
get box() {
|
|
1761
|
+
return this._box;
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Gets the computed bounding sphere.
|
|
1765
|
+
* @returns The Sphere instance representing the bounding sphere
|
|
1766
|
+
*/
|
|
1767
|
+
get sphere() {
|
|
1768
|
+
return this._sphere;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Gets the center point of the bounding box.
|
|
1772
|
+
* @returns A Vector3 representing the center coordinates
|
|
1773
|
+
*/
|
|
1774
|
+
get center() {
|
|
1775
|
+
return this._center;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Gets the radius of the bounding sphere.
|
|
1779
|
+
* @returns The radius as a number
|
|
1780
|
+
*/
|
|
1781
|
+
get radius() {
|
|
1782
|
+
return this._radius;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Gets the dimensions of the bounding box.
|
|
1786
|
+
* @returns A Vector3 representing width, height, and depth
|
|
1787
|
+
*/
|
|
1788
|
+
get size() {
|
|
1789
|
+
return this._size;
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Sets the visibility of the bounding box wireframe helper.
|
|
1793
|
+
*
|
|
1794
|
+
* @param visible - Whether the box helper should be visible
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* ```typescript
|
|
1798
|
+
* const boundingBox = new BoundingBox(mesh);
|
|
1799
|
+
*
|
|
1800
|
+
* // Show the bounding box wireframe
|
|
1801
|
+
* boundingBox.setBoxHelperVisible(true);
|
|
1802
|
+
*
|
|
1803
|
+
* // Hide the bounding box wireframe
|
|
1804
|
+
* boundingBox.setBoxHelperVisible(false);
|
|
1805
|
+
* ```
|
|
1806
|
+
*/
|
|
1807
|
+
setBoxHelperVisible(t) {
|
|
1808
|
+
this._boxHelper.visible = t;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Sets the visibility of the bounding sphere wireframe helper.
|
|
1812
|
+
*
|
|
1813
|
+
* @param visible - Whether the sphere helper should be visible
|
|
1814
|
+
*
|
|
1815
|
+
* @example
|
|
1816
|
+
* ```typescript
|
|
1817
|
+
* const boundingBox = new BoundingBox(mesh);
|
|
1818
|
+
*
|
|
1819
|
+
* // Show the bounding sphere wireframe
|
|
1820
|
+
* boundingBox.setSphereHelperVisible(true);
|
|
1821
|
+
*
|
|
1822
|
+
* // Hide the bounding sphere wireframe
|
|
1823
|
+
* boundingBox.setSphereHelperVisible(false);
|
|
1824
|
+
* ```
|
|
1825
|
+
*/
|
|
1826
|
+
setSphereHelperVisible(t) {
|
|
1827
|
+
this._sphereHelper.visible = t;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
const qt = {
|
|
1831
|
+
glb: {
|
|
1832
|
+
key: "glb",
|
|
1833
|
+
extension: "glb"
|
|
1834
|
+
},
|
|
1835
|
+
gltf: {
|
|
1836
|
+
key: "gltf",
|
|
1837
|
+
extension: "gltf"
|
|
1838
|
+
},
|
|
1839
|
+
usdz: {
|
|
1840
|
+
key: "usdz",
|
|
1841
|
+
extension: "usdz"
|
|
1842
|
+
}
|
|
1843
|
+
}, ie = Object.values(qt).map(
|
|
1844
|
+
(r) => r.extension
|
|
1845
|
+
);
|
|
1846
|
+
export {
|
|
1847
|
+
Wt as A,
|
|
1848
|
+
v as B,
|
|
1849
|
+
kt as C,
|
|
1850
|
+
D,
|
|
1851
|
+
At as E,
|
|
1852
|
+
Xt as F,
|
|
1853
|
+
Ct as G,
|
|
1854
|
+
V as H,
|
|
1855
|
+
qt as I,
|
|
1856
|
+
Gt as O,
|
|
1857
|
+
ie as S,
|
|
1858
|
+
z as a,
|
|
1859
|
+
Ut as b,
|
|
1860
|
+
Ft as c,
|
|
1861
|
+
Yt as d,
|
|
1862
|
+
It as e,
|
|
1863
|
+
Lt as f,
|
|
1864
|
+
Zt as g,
|
|
1865
|
+
Nt as h,
|
|
1866
|
+
ee as i,
|
|
1867
|
+
vt as j,
|
|
1868
|
+
Y as k,
|
|
1869
|
+
W as l,
|
|
1870
|
+
te as m,
|
|
1871
|
+
Mt as n,
|
|
1872
|
+
E as o,
|
|
1873
|
+
zt as p,
|
|
1874
|
+
B as q,
|
|
1875
|
+
Z as r,
|
|
1876
|
+
N as s,
|
|
1877
|
+
X as t,
|
|
1878
|
+
Ot as u,
|
|
1879
|
+
Rt as v,
|
|
1880
|
+
Bt as w,
|
|
1881
|
+
Vt as x,
|
|
1882
|
+
xt as y,
|
|
1883
|
+
Tt as z
|
|
1884
|
+
};
|