@shopware-ag/dive 1.19.1-beta.9 → 2.0.1-beta.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/build/chunks/FileTypes-BjZ0rrIV.cjs +1 -0
- package/build/chunks/FileTypes-qgYnI0Jg.mjs +30 -0
- package/build/chunks/ModuleRegistry-NyNtjHb2.cjs +1 -0
- package/build/chunks/ModuleRegistry-RSub8W0G.mjs +13 -0
- package/build/chunks/PerspectiveCamera-BByyG5R4.cjs +1 -0
- package/build/chunks/PerspectiveCamera-sm4_81KJ.mjs +34 -0
- package/build/chunks/SelectTool-BAXTVyWs.cjs +1 -0
- package/build/chunks/SelectTool-Bd8cC9nb.mjs +712 -0
- package/build/chunks/{SystemInfo-DYq9x4Ch.mjs → SystemInfo-DPAQG-S5.mjs} +37 -40
- package/build/chunks/SystemInfo-oX-NNneO.cjs +1 -0
- package/build/chunks/VisibilityLayerMask-BI7jPKdx.cjs +1 -0
- package/build/chunks/VisibilityLayerMask-CXgt1fJc.mjs +8 -0
- package/build/chunks/findInterface-BEdL2iUQ.cjs +1 -0
- package/build/chunks/findInterface-OrXgmwxj.mjs +18 -0
- package/build/chunks/index-C_uFFwT2.mjs +5 -0
- package/build/chunks/index-DAwIH9xh.cjs +1 -0
- package/build/chunks/package-BHjZWYD6.mjs +39 -0
- package/build/chunks/package-JHvTSNgQ.cjs +1 -0
- package/build/chunks/{fflate.module-Chbb_O8w.cjs → parse-error-2f5qpXP5.cjs} +2 -3
- package/build/chunks/{fflate.module-BQhIETD7.mjs → parse-error-DRBVHL9E.mjs} +16 -17
- package/build/dive.cjs +30 -0
- package/build/dive.mjs +1663 -0
- package/build/src/components/floor/Floor.d.ts +2 -2
- package/build/src/components/gizmo/Gizmo.d.ts +4 -4
- package/build/src/components/gizmo/handles/AxisHandle.d.ts +4 -4
- package/build/src/components/gizmo/handles/RadialHandle.d.ts +4 -4
- package/build/src/components/gizmo/handles/ScaleHandle.d.ts +4 -4
- package/build/src/components/gizmo/plane/GizmoPlane.d.ts +1 -1
- package/build/src/components/gizmo/rotate/RotateGizmo.d.ts +4 -4
- package/build/src/components/gizmo/scale/ScaleGizmo.d.ts +5 -5
- package/build/src/components/gizmo/translate/TranslateGizmo.d.ts +4 -4
- package/build/src/components/grid/Grid.d.ts +1 -1
- package/build/src/components/light/AmbientLight.d.ts +3 -3
- package/build/src/components/light/PointLight.d.ts +6 -6
- package/build/src/components/light/SceneLight.d.ts +3 -3
- package/build/src/components/model/Model.d.ts +9 -6
- package/build/src/components/node/Node.d.ts +4 -4
- package/build/src/components/primitive/Primitive.d.ts +4 -4
- package/build/src/components/root/Root.d.ts +20 -29
- package/build/src/core/Dive.d.ts +26 -14
- package/build/src/engine/Engine.d.ts +7 -11
- package/build/src/engine/clock/Clock.d.ts +4 -0
- package/build/src/engine/renderer/Renderer.d.ts +12 -8
- package/build/src/engine/resize/ResizeManager.d.ts +4 -2
- package/build/src/engine/scene/Scene.d.ts +6 -24
- package/build/src/engine/scene/xrroot/XRRoot.d.ts +5 -5
- package/build/src/engine/scene/xrroot/xrlightroot/XRLightRoot.d.ts +3 -3
- package/build/src/helpers/findSceneRecursive/findSceneRecursive.d.ts +1 -1
- package/build/src/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +1 -1
- package/build/src/index.d.ts +6 -9
- package/build/src/interfaces/Draggable.d.ts +1 -1
- package/build/src/modules/ModuleRegistry.d.ts +19 -0
- package/build/src/modules/animation/AnimationSystem.cjs +1 -0
- package/build/src/modules/animation/AnimationSystem.d.ts +28 -4
- package/build/src/modules/animation/AnimationSystem.mjs +95 -0
- package/build/src/modules/animation/animator/Animator.d.ts +26 -0
- package/build/src/modules/animation/types/AnimatorParameters.d.ts +7 -0
- package/build/src/modules/ar/ARSystem.cjs +1 -2
- package/build/src/modules/ar/ARSystem.mjs +5 -5
- package/build/src/modules/ar/arquicklook/ARQuickLook.d.ts +1 -1
- package/build/src/modules/ar/sceneviewer/SceneViewer.d.ts +1 -1
- package/build/src/modules/ar/webxr/WebXR.d.ts +3 -3
- package/build/src/modules/ar/webxr/controller/WebXRController.d.ts +3 -3
- package/build/src/modules/ar/webxr/origin/WebXROrigin.d.ts +2 -2
- package/build/src/modules/ar/webxr/raycaster/WebXRRaycaster.d.ts +4 -4
- package/build/src/modules/ar/webxr/raycaster/ar/WebXRRaycasterAR.d.ts +3 -3
- package/build/src/modules/ar/webxr/raycaster/three/WebXRRaycasterTHREE.d.ts +4 -4
- package/build/src/modules/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +1 -1
- package/build/src/modules/asset/converter/AssetConverter.cjs +0 -1
- package/build/src/modules/asset/converter/AssetConverter.d.ts +3 -3
- package/build/src/modules/asset/converter/AssetConverter.mjs +0 -1
- package/build/src/modules/asset/draco/README.md +32 -0
- package/build/src/modules/asset/draco/draco_decoder.js +33 -0
- package/build/src/modules/asset/draco/draco_decoder.wasm +0 -0
- package/build/src/modules/asset/draco/draco_encoder.js +33 -0
- package/build/src/modules/asset/draco/draco_wasm_wrapper.js +116 -0
- package/build/src/modules/asset/draco/gltf/draco_decoder.js +33 -0
- package/build/src/modules/asset/draco/gltf/draco_decoder.wasm +0 -0
- package/build/src/modules/asset/draco/gltf/draco_encoder.js +33 -0
- package/build/src/modules/asset/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/build/src/modules/asset/exporter/AssetExporter.cjs +1 -2
- package/build/src/modules/asset/exporter/AssetExporter.d.ts +3 -3
- package/build/src/modules/asset/exporter/AssetExporter.mjs +1 -2
- package/build/src/modules/asset/loader/AssetLoader.cjs +3 -2
- package/build/src/modules/asset/loader/AssetLoader.mjs +2152 -5
- package/build/src/modules/axiscamera/AxisCamera.d.ts +8 -9
- package/build/src/modules/controller/orbit/OrbitController.d.ts +13 -24
- package/build/src/modules/mediacreator/MediaCreator.cjs +1 -2
- package/build/src/modules/mediacreator/MediaCreator.d.ts +4 -4
- package/build/src/modules/mediacreator/MediaCreator.mjs +28 -3
- package/build/src/modules/state/ActionRegistry.d.ts +26 -0
- package/build/src/modules/state/State.cjs +27 -0
- package/build/src/modules/state/State.d.ts +58 -0
- package/build/src/modules/state/State.mjs +4296 -0
- package/build/src/modules/state/actions/action.d.ts +36 -0
- package/build/src/modules/state/actions/ar/index.d.ts +1 -0
- package/build/src/modules/state/actions/ar/launchar.d.ts +15 -0
- package/build/src/modules/state/actions/camera/computeencompassingview.d.ts +12 -0
- package/build/src/modules/state/actions/camera/getcameratransform.d.ts +12 -0
- package/build/src/modules/state/actions/camera/index.d.ts +6 -0
- package/build/src/modules/state/actions/camera/lockcamera.d.ts +8 -0
- package/build/src/modules/state/actions/camera/movecamera.d.ts +29 -0
- package/build/src/modules/state/actions/camera/setcameralayer.d.ts +12 -0
- package/build/src/modules/state/actions/camera/setcameratransform.d.ts +15 -0
- package/build/src/modules/state/actions/camera/zoomcamera.d.ts +14 -0
- package/build/src/modules/state/actions/index.d.ts +7 -0
- package/build/src/modules/state/actions/media/generatemedia.d.ts +25 -0
- package/build/src/modules/state/actions/media/index.d.ts +1 -0
- package/build/src/modules/state/actions/object/addobject.d.ts +8 -0
- package/build/src/modules/state/actions/object/deleteobject.d.ts +12 -0
- package/build/src/modules/state/actions/object/deselectobject.d.ts +12 -0
- package/build/src/modules/state/actions/object/dropit.d.ts +12 -0
- package/build/src/modules/state/actions/object/getallobjects.d.ts +8 -0
- package/build/src/modules/state/actions/object/getobjects.d.ts +12 -0
- package/build/src/modules/state/actions/object/index.d.ts +11 -0
- package/build/src/modules/state/actions/object/modelloaded.d.ts +12 -0
- package/build/src/modules/state/actions/object/placeonfloor.d.ts +12 -0
- package/build/src/modules/state/actions/object/selectobject.d.ts +12 -0
- package/build/src/modules/state/actions/object/setparent.d.ts +22 -0
- package/build/src/modules/state/actions/object/updateobject.d.ts +12 -0
- package/build/src/modules/state/actions/renderer/index.d.ts +1 -0
- package/build/src/modules/state/actions/renderer/startrender.d.ts +8 -0
- package/build/src/modules/state/actions/scene/exportscene.d.ts +13 -0
- package/build/src/modules/state/actions/scene/getallscenedata.d.ts +9 -0
- package/build/src/modules/state/actions/scene/index.d.ts +4 -0
- package/build/src/modules/state/actions/scene/setbackground.d.ts +12 -0
- package/build/src/modules/state/actions/scene/updatescene.d.ts +20 -0
- package/build/src/modules/state/actions/toolbox/index.d.ts +4 -0
- package/build/src/modules/state/actions/toolbox/setgizmomode.d.ts +12 -0
- package/build/src/modules/state/actions/toolbox/setgizmoscalelinked.d.ts +8 -0
- package/build/src/modules/state/actions/toolbox/setgizmovisible.d.ts +8 -0
- package/build/src/modules/state/actions/toolbox/usetool.d.ts +13 -0
- package/build/src/modules/state/types/ActionTypes.d.ts +18 -0
- package/build/src/modules/{com → state}/types/COMBaseEntity.d.ts +1 -1
- package/build/src/modules/state/types/COMEntity.d.ts +11 -0
- package/build/src/modules/{com → state}/types/COMGeometry.d.ts +1 -1
- package/build/src/modules/state/types/COMGroup.d.ts +11 -0
- package/build/src/modules/state/types/COMLight.d.ts +28 -0
- package/build/src/modules/state/types/COMModel.d.ts +14 -0
- package/build/src/modules/state/types/COMPov.d.ts +10 -0
- package/build/src/modules/state/types/COMPrimitive.d.ts +14 -0
- package/build/src/modules/state/types/index.d.ts +11 -0
- package/build/src/modules/systeminfo/SystemInfo.cjs +1 -2
- package/build/src/modules/systeminfo/SystemInfo.d.ts +1 -1
- package/build/src/modules/systeminfo/SystemInfo.mjs +3 -3
- package/build/src/modules/toolbox/BaseTool.d.ts +6 -6
- package/build/src/modules/toolbox/Toolbox.cjs +1 -0
- package/build/src/modules/toolbox/Toolbox.d.ts +12 -8
- package/build/src/modules/toolbox/Toolbox.mjs +99 -0
- package/build/src/modules/toolbox/select/SelectTool.d.ts +6 -6
- package/build/src/modules/toolbox/transform/TransformTool.d.ts +6 -6
- package/build/src/types/SceneData.d.ts +1 -1
- package/build/src/types/SceneObjects.d.ts +9 -7
- package/build/src/types/SceneType.d.ts +1 -1
- package/build/src/types/UUID.d.ts +1 -0
- package/build/src/types/file/index.d.ts +1 -1
- package/build/src/types/index.d.ts +6 -6
- package/package.json +34 -23
- package/build/chunks/AssetLoader-BYhwzCxs.cjs +0 -3
- package/build/chunks/AssetLoader-BYhwzCxs.cjs.map +0 -1
- package/build/chunks/AssetLoader-Bmcx40wo.mjs +0 -1948
- package/build/chunks/AssetLoader-Bmcx40wo.mjs.map +0 -1
- package/build/chunks/MediaCreator-CAXBbn15.mjs +0 -59
- package/build/chunks/MediaCreator-CAXBbn15.mjs.map +0 -1
- package/build/chunks/MediaCreator-DDXQIlRv.cjs +0 -2
- package/build/chunks/MediaCreator-DDXQIlRv.cjs.map +0 -1
- package/build/chunks/SystemInfo--669uW1p.cjs +0 -2
- package/build/chunks/SystemInfo--669uW1p.cjs.map +0 -1
- package/build/chunks/SystemInfo-DYq9x4Ch.mjs.map +0 -1
- package/build/chunks/fflate.module-BQhIETD7.mjs.map +0 -1
- package/build/chunks/fflate.module-Chbb_O8w.cjs.map +0 -1
- package/build/index.cjs +0 -57
- package/build/index.cjs.map +0 -1
- package/build/index.mjs +0 -6793
- package/build/index.mjs.map +0 -1
- package/build/src/engine/index.d.ts +0 -1
- package/build/src/engine/pipeline/RenderPipeline.d.ts +0 -26
- package/build/src/error/index.d.ts +0 -4
- package/build/src/modules/_system/ModuleImporter.d.ts +0 -43
- package/build/src/modules/ar/ARSystem.cjs.map +0 -1
- package/build/src/modules/ar/ARSystem.mjs.map +0 -1
- package/build/src/modules/asset/converter/AssetConverter.cjs.map +0 -1
- package/build/src/modules/asset/converter/AssetConverter.mjs.map +0 -1
- package/build/src/modules/asset/exporter/AssetExporter.cjs.map +0 -1
- package/build/src/modules/asset/exporter/AssetExporter.mjs.map +0 -1
- package/build/src/modules/asset/loader/AssetLoader.cjs.map +0 -1
- package/build/src/modules/asset/loader/AssetLoader.mjs.map +0 -1
- package/build/src/modules/com/Communication.d.ts +0 -72
- package/build/src/modules/com/actions/camera/computeencompassingview.d.ts +0 -9
- package/build/src/modules/com/actions/camera/getcameratransform.d.ts +0 -9
- package/build/src/modules/com/actions/camera/movecamera.d.ts +0 -15
- package/build/src/modules/com/actions/camera/resetcamera.d.ts +0 -7
- package/build/src/modules/com/actions/camera/setcameralayer.d.ts +0 -7
- package/build/src/modules/com/actions/camera/setcameratransform.d.ts +0 -9
- package/build/src/modules/com/actions/camera/zoomcamera.d.ts +0 -8
- package/build/src/modules/com/actions/index.d.ts +0 -60
- package/build/src/modules/com/actions/media/generatemedia.d.ts +0 -14
- package/build/src/modules/com/actions/object/addobject.d.ts +0 -6
- package/build/src/modules/com/actions/object/deleteobject.d.ts +0 -8
- package/build/src/modules/com/actions/object/deselectobject.d.ts +0 -8
- package/build/src/modules/com/actions/object/getallobjects.d.ts +0 -6
- package/build/src/modules/com/actions/object/getobjects.d.ts +0 -8
- package/build/src/modules/com/actions/object/model/dropit.d.ts +0 -7
- package/build/src/modules/com/actions/object/model/modelloaded.d.ts +0 -7
- package/build/src/modules/com/actions/object/model/placeonfloor.d.ts +0 -7
- package/build/src/modules/com/actions/object/selectobject.d.ts +0 -8
- package/build/src/modules/com/actions/object/setparent.d.ts +0 -13
- package/build/src/modules/com/actions/object/updateobject.d.ts +0 -8
- package/build/src/modules/com/actions/renderer/startrender.d.ts +0 -5
- package/build/src/modules/com/actions/scene/exportscene.d.ts +0 -8
- package/build/src/modules/com/actions/scene/getallscenedata.d.ts +0 -6
- package/build/src/modules/com/actions/scene/launchar.d.ts +0 -9
- package/build/src/modules/com/actions/scene/setbackground.d.ts +0 -7
- package/build/src/modules/com/actions/scene/updatescene.d.ts +0 -11
- package/build/src/modules/com/actions/toolbox/select/setgizmomode.d.ts +0 -7
- package/build/src/modules/com/actions/toolbox/transform/setgizmoscalelinked.d.ts +0 -5
- package/build/src/modules/com/actions/toolbox/transform/setgizmovisible.d.ts +0 -5
- package/build/src/modules/com/actions/toolbox/usetool.d.ts +0 -8
- package/build/src/modules/com/types/COMEntity.d.ts +0 -6
- package/build/src/modules/com/types/COMGroup.d.ts +0 -8
- package/build/src/modules/com/types/COMLight.d.ts +0 -10
- package/build/src/modules/com/types/COMModel.d.ts +0 -11
- package/build/src/modules/com/types/COMPov.d.ts +0 -7
- package/build/src/modules/com/types/COMPrimitive.d.ts +0 -11
- package/build/src/modules/com/types/index.d.ts +0 -11
- package/build/src/modules/index.d.ts +0 -2
- package/build/src/modules/mediacreator/MediaCreator.cjs.map +0 -1
- package/build/src/modules/mediacreator/MediaCreator.mjs.map +0 -1
- package/build/src/modules/systeminfo/SystemInfo.cjs.map +0 -1
- package/build/src/modules/systeminfo/SystemInfo.mjs.map +0 -1
- /package/build/{index.d.ts → dive.d.ts} +0 -0
- /package/build/src/modules/{com → state}/types/COMEntityType.d.ts +0 -0
- /package/build/src/modules/{com → state}/types/COMGeometryType.d.ts +0 -0
- /package/build/src/modules/{com → state}/types/COMMaterial.d.ts +0 -0
package/build/dive.mjs
ADDED
|
@@ -0,0 +1,1663 @@
|
|
|
1
|
+
var Dt = Object.defineProperty;
|
|
2
|
+
var xt = (h, s, t) => s in h ? Dt(h, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[s] = t;
|
|
3
|
+
var a = (h, s, t) => xt(h, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { Ray as St, Plane as Tt, MathUtils as C, EventDispatcher as Lt, Vector3 as m, MOUSE as U, TOUCH as G, Spherical as Ne, Quaternion as Fe, Vector2 as E, OrthographicCamera as Pt, Vector4 as Mt, AxesHelper as It, Color as D, Matrix4 as Ct, Object3D as j, AmbientLight as vt, PointLight as Ot, SphereGeometry as Ke, MeshBasicMaterial as At, FrontSide as kt, Mesh as pe, HemisphereLight as Rt, DirectionalLight as Vt, Box3 as Ze, MeshStandardMaterial as fe, Raycaster as Xe, CylinderGeometry as Bt, BufferGeometry as qe, BufferAttribute as Ye, BoxGeometry as de, ConeGeometry as zt, LineDashedMaterial as Nt, Line as Ft, PlaneGeometry as Yt, GridHelper as Ut, Scene as Gt, WebGLRenderer as Ue } from "three";
|
|
5
|
+
import ue from "three-spritetext";
|
|
6
|
+
import { C as q, P, U as jt, H as Ht } from "./chunks/VisibilityLayerMask-CXgt1fJc.mjs";
|
|
7
|
+
import { A as Wt, a as Kt, b as Zt, c as Xt, d as qt, e as Jt } from "./chunks/findInterface-OrXgmwxj.mjs";
|
|
8
|
+
import { f as Fi, i as Yi } from "./chunks/findInterface-OrXgmwxj.mjs";
|
|
9
|
+
import { g as w } from "./chunks/ModuleRegistry-RSub8W0G.mjs";
|
|
10
|
+
import { D as $t, a as Qt } from "./chunks/PerspectiveCamera-sm4_81KJ.mjs";
|
|
11
|
+
import { F as Gi, S as ji, g as Hi, i as Wi } from "./chunks/FileTypes-qgYnI0Jg.mjs";
|
|
12
|
+
import { E as Zi, a as Xi } from "./chunks/index-C_uFFwT2.mjs";
|
|
13
|
+
const Ge = { type: "change" }, me = { type: "start" }, je = { type: "end" }, ie = new St(), He = new Tt(), ei = Math.cos(70 * C.DEG2RAD);
|
|
14
|
+
class ti extends Lt {
|
|
15
|
+
constructor(s, t) {
|
|
16
|
+
super(), this.object = s, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new m(), this.cursor = new m(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: U.ROTATE, MIDDLE: U.DOLLY, RIGHT: U.PAN }, this.touches = { ONE: G.ROTATE, TWO: G.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this.getPolarAngle = function() {
|
|
17
|
+
return l.phi;
|
|
18
|
+
}, this.getAzimuthalAngle = function() {
|
|
19
|
+
return l.theta;
|
|
20
|
+
}, this.getDistance = function() {
|
|
21
|
+
return this.object.position.distanceTo(this.target);
|
|
22
|
+
}, this.listenToKeyEvents = function(i) {
|
|
23
|
+
i.addEventListener("keydown", ce), this._domElementKeyEvents = i;
|
|
24
|
+
}, this.stopListenToKeyEvents = function() {
|
|
25
|
+
this._domElementKeyEvents.removeEventListener("keydown", ce), this._domElementKeyEvents = null;
|
|
26
|
+
}, this.saveState = function() {
|
|
27
|
+
e.target0.copy(e.target), e.position0.copy(e.object.position), e.zoom0 = e.object.zoom;
|
|
28
|
+
}, this.reset = function() {
|
|
29
|
+
e.target.copy(e.target0), e.object.position.copy(e.position0), e.object.zoom = e.zoom0, e.object.updateProjectionMatrix(), e.dispatchEvent(Ge), e.update(), o = n.NONE;
|
|
30
|
+
}, this.update = function() {
|
|
31
|
+
const i = new m(), r = new Fe().setFromUnitVectors(s.up, new m(0, 1, 0)), d = r.clone().invert(), u = new m(), y = new Fe(), I = new m(), b = 2 * Math.PI;
|
|
32
|
+
return function(Et = null) {
|
|
33
|
+
const Be = e.object.position;
|
|
34
|
+
i.copy(Be).sub(e.target), i.applyQuaternion(r), l.setFromVector3(i), e.autoRotate && o === n.NONE && W(st(Et)), e.enableDamping ? (l.theta += p.theta * e.dampingFactor, l.phi += p.phi * e.dampingFactor) : (l.theta += p.theta, l.phi += p.phi);
|
|
35
|
+
let S = e.minAzimuthAngle, T = e.maxAzimuthAngle;
|
|
36
|
+
isFinite(S) && isFinite(T) && (S < -Math.PI ? S += b : S > Math.PI && (S -= b), T < -Math.PI ? T += b : T > Math.PI && (T -= b), S <= T ? l.theta = Math.max(S, Math.min(T, l.theta)) : l.theta = l.theta > (S + T) / 2 ? Math.max(S, l.theta) : Math.min(T, l.theta)), l.phi = Math.max(e.minPolarAngle, Math.min(e.maxPolarAngle, l.phi)), l.makeSafe(), e.enableDamping === !0 ? e.target.addScaledVector(_, e.dampingFactor) : e.target.add(_), e.target.sub(e.cursor), e.target.clampLength(e.minTargetRadius, e.maxTargetRadius), e.target.add(e.cursor);
|
|
37
|
+
let Z = !1;
|
|
38
|
+
if (e.zoomToCursor && $ || e.object.isOrthographicCamera)
|
|
39
|
+
l.radius = he(l.radius);
|
|
40
|
+
else {
|
|
41
|
+
const L = l.radius;
|
|
42
|
+
l.radius = he(l.radius * f), Z = L != l.radius;
|
|
43
|
+
}
|
|
44
|
+
if (i.setFromSpherical(l), i.applyQuaternion(d), Be.copy(e.target).add(i), e.object.lookAt(e.target), e.enableDamping === !0 ? (p.theta *= 1 - e.dampingFactor, p.phi *= 1 - e.dampingFactor, _.multiplyScalar(1 - e.dampingFactor)) : (p.set(0, 0, 0), _.set(0, 0, 0)), e.zoomToCursor && $) {
|
|
45
|
+
let L = null;
|
|
46
|
+
if (e.object.isPerspectiveCamera) {
|
|
47
|
+
const X = i.length();
|
|
48
|
+
L = he(X * f);
|
|
49
|
+
const te = X - L;
|
|
50
|
+
e.object.position.addScaledVector(ye, te), e.object.updateMatrixWorld(), Z = !!te;
|
|
51
|
+
} else if (e.object.isOrthographicCamera) {
|
|
52
|
+
const X = new m(M.x, M.y, 0);
|
|
53
|
+
X.unproject(e.object);
|
|
54
|
+
const te = e.object.zoom;
|
|
55
|
+
e.object.zoom = Math.max(e.minZoom, Math.min(e.maxZoom, e.object.zoom / f)), e.object.updateProjectionMatrix(), Z = te !== e.object.zoom;
|
|
56
|
+
const ze = new m(M.x, M.y, 0);
|
|
57
|
+
ze.unproject(e.object), e.object.position.sub(ze).add(X), e.object.updateMatrixWorld(), L = i.length();
|
|
58
|
+
} else
|
|
59
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), e.zoomToCursor = !1;
|
|
60
|
+
L !== null && (this.screenSpacePanning ? e.target.set(0, 0, -1).transformDirection(e.object.matrix).multiplyScalar(L).add(e.object.position) : (ie.origin.copy(e.object.position), ie.direction.set(0, 0, -1).transformDirection(e.object.matrix), Math.abs(e.object.up.dot(ie.direction)) < ei ? s.lookAt(e.target) : (He.setFromNormalAndCoplanarPoint(e.object.up, e.target), ie.intersectPlane(He, e.target))));
|
|
61
|
+
} else if (e.object.isOrthographicCamera) {
|
|
62
|
+
const L = e.object.zoom;
|
|
63
|
+
e.object.zoom = Math.max(e.minZoom, Math.min(e.maxZoom, e.object.zoom / f)), L !== e.object.zoom && (e.object.updateProjectionMatrix(), Z = !0);
|
|
64
|
+
}
|
|
65
|
+
return f = 1, $ = !1, Z || u.distanceToSquared(e.object.position) > c || 8 * (1 - y.dot(e.object.quaternion)) > c || I.distanceToSquared(e.target) > c ? (e.dispatchEvent(Ge), u.copy(e.object.position), y.copy(e.object.quaternion), I.copy(e.target), !0) : !1;
|
|
66
|
+
};
|
|
67
|
+
}(), this.dispose = function() {
|
|
68
|
+
e.domElement.removeEventListener("contextmenu", Re), e.domElement.removeEventListener("pointerdown", Ce), e.domElement.removeEventListener("pointercancel", K), e.domElement.removeEventListener("wheel", ve), e.domElement.removeEventListener("pointermove", le), e.domElement.removeEventListener("pointerup", K), e.domElement.getRootNode().removeEventListener("keydown", Oe, { capture: !0 }), e._domElementKeyEvents !== null && (e._domElementKeyEvents.removeEventListener("keydown", ce), e._domElementKeyEvents = null);
|
|
69
|
+
};
|
|
70
|
+
const e = this, n = {
|
|
71
|
+
NONE: -1,
|
|
72
|
+
ROTATE: 0,
|
|
73
|
+
DOLLY: 1,
|
|
74
|
+
PAN: 2,
|
|
75
|
+
TOUCH_ROTATE: 3,
|
|
76
|
+
TOUCH_PAN: 4,
|
|
77
|
+
TOUCH_DOLLY_PAN: 5,
|
|
78
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
79
|
+
};
|
|
80
|
+
let o = n.NONE;
|
|
81
|
+
const c = 1e-6, l = new Ne(), p = new Ne();
|
|
82
|
+
let f = 1;
|
|
83
|
+
const _ = new m(), v = new E(), O = new E(), V = new E(), A = new E(), k = new E(), B = new E(), z = new E(), N = new E(), R = new E(), ye = new m(), M = new E();
|
|
84
|
+
let $ = !1;
|
|
85
|
+
const g = [], H = {};
|
|
86
|
+
let oe = !1;
|
|
87
|
+
function st(i) {
|
|
88
|
+
return i !== null ? 2 * Math.PI / 60 * e.autoRotateSpeed * i : 2 * Math.PI / 60 / 60 * e.autoRotateSpeed;
|
|
89
|
+
}
|
|
90
|
+
function Q(i) {
|
|
91
|
+
const r = Math.abs(i * 0.01);
|
|
92
|
+
return Math.pow(0.95, e.zoomSpeed * r);
|
|
93
|
+
}
|
|
94
|
+
function W(i) {
|
|
95
|
+
p.theta -= i;
|
|
96
|
+
}
|
|
97
|
+
function ee(i) {
|
|
98
|
+
p.phi -= i;
|
|
99
|
+
}
|
|
100
|
+
const be = function() {
|
|
101
|
+
const i = new m();
|
|
102
|
+
return function(d, u) {
|
|
103
|
+
i.setFromMatrixColumn(u, 0), i.multiplyScalar(-d), _.add(i);
|
|
104
|
+
};
|
|
105
|
+
}(), we = function() {
|
|
106
|
+
const i = new m();
|
|
107
|
+
return function(d, u) {
|
|
108
|
+
e.screenSpacePanning === !0 ? i.setFromMatrixColumn(u, 1) : (i.setFromMatrixColumn(u, 0), i.crossVectors(e.object.up, i)), i.multiplyScalar(d), _.add(i);
|
|
109
|
+
};
|
|
110
|
+
}(), F = function() {
|
|
111
|
+
const i = new m();
|
|
112
|
+
return function(d, u) {
|
|
113
|
+
const y = e.domElement;
|
|
114
|
+
if (e.object.isPerspectiveCamera) {
|
|
115
|
+
const I = e.object.position;
|
|
116
|
+
i.copy(I).sub(e.target);
|
|
117
|
+
let b = i.length();
|
|
118
|
+
b *= Math.tan(e.object.fov / 2 * Math.PI / 180), be(2 * d * b / y.clientHeight, e.object.matrix), we(2 * u * b / y.clientHeight, e.object.matrix);
|
|
119
|
+
} else e.object.isOrthographicCamera ? (be(d * (e.object.right - e.object.left) / e.object.zoom / y.clientWidth, e.object.matrix), we(u * (e.object.top - e.object.bottom) / e.object.zoom / y.clientHeight, e.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), e.enablePan = !1);
|
|
120
|
+
};
|
|
121
|
+
}();
|
|
122
|
+
function re(i) {
|
|
123
|
+
e.object.isPerspectiveCamera || e.object.isOrthographicCamera ? f /= i : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), e.enableZoom = !1);
|
|
124
|
+
}
|
|
125
|
+
function Ee(i) {
|
|
126
|
+
e.object.isPerspectiveCamera || e.object.isOrthographicCamera ? f *= i : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), e.enableZoom = !1);
|
|
127
|
+
}
|
|
128
|
+
function ae(i, r) {
|
|
129
|
+
if (!e.zoomToCursor)
|
|
130
|
+
return;
|
|
131
|
+
$ = !0;
|
|
132
|
+
const d = e.domElement.getBoundingClientRect(), u = i - d.left, y = r - d.top, I = d.width, b = d.height;
|
|
133
|
+
M.x = u / I * 2 - 1, M.y = -(y / b) * 2 + 1, ye.set(M.x, M.y, 1).unproject(e.object).sub(e.object.position).normalize();
|
|
134
|
+
}
|
|
135
|
+
function he(i) {
|
|
136
|
+
return Math.max(e.minDistance, Math.min(e.maxDistance, i));
|
|
137
|
+
}
|
|
138
|
+
function De(i) {
|
|
139
|
+
v.set(i.clientX, i.clientY);
|
|
140
|
+
}
|
|
141
|
+
function nt(i) {
|
|
142
|
+
ae(i.clientX, i.clientX), z.set(i.clientX, i.clientY);
|
|
143
|
+
}
|
|
144
|
+
function xe(i) {
|
|
145
|
+
A.set(i.clientX, i.clientY);
|
|
146
|
+
}
|
|
147
|
+
function ot(i) {
|
|
148
|
+
O.set(i.clientX, i.clientY), V.subVectors(O, v).multiplyScalar(e.rotateSpeed);
|
|
149
|
+
const r = e.domElement;
|
|
150
|
+
W(2 * Math.PI * V.x / r.clientHeight), ee(2 * Math.PI * V.y / r.clientHeight), v.copy(O), e.update();
|
|
151
|
+
}
|
|
152
|
+
function rt(i) {
|
|
153
|
+
N.set(i.clientX, i.clientY), R.subVectors(N, z), R.y > 0 ? re(Q(R.y)) : R.y < 0 && Ee(Q(R.y)), z.copy(N), e.update();
|
|
154
|
+
}
|
|
155
|
+
function at(i) {
|
|
156
|
+
k.set(i.clientX, i.clientY), B.subVectors(k, A).multiplyScalar(e.panSpeed), F(B.x, B.y), A.copy(k), e.update();
|
|
157
|
+
}
|
|
158
|
+
function ht(i) {
|
|
159
|
+
ae(i.clientX, i.clientY), i.deltaY < 0 ? Ee(Q(i.deltaY)) : i.deltaY > 0 && re(Q(i.deltaY)), e.update();
|
|
160
|
+
}
|
|
161
|
+
function lt(i) {
|
|
162
|
+
let r = !1;
|
|
163
|
+
switch (i.code) {
|
|
164
|
+
case e.keys.UP:
|
|
165
|
+
i.ctrlKey || i.metaKey || i.shiftKey ? ee(2 * Math.PI * e.rotateSpeed / e.domElement.clientHeight) : F(0, e.keyPanSpeed), r = !0;
|
|
166
|
+
break;
|
|
167
|
+
case e.keys.BOTTOM:
|
|
168
|
+
i.ctrlKey || i.metaKey || i.shiftKey ? ee(-2 * Math.PI * e.rotateSpeed / e.domElement.clientHeight) : F(0, -e.keyPanSpeed), r = !0;
|
|
169
|
+
break;
|
|
170
|
+
case e.keys.LEFT:
|
|
171
|
+
i.ctrlKey || i.metaKey || i.shiftKey ? W(2 * Math.PI * e.rotateSpeed / e.domElement.clientHeight) : F(e.keyPanSpeed, 0), r = !0;
|
|
172
|
+
break;
|
|
173
|
+
case e.keys.RIGHT:
|
|
174
|
+
i.ctrlKey || i.metaKey || i.shiftKey ? W(-2 * Math.PI * e.rotateSpeed / e.domElement.clientHeight) : F(-e.keyPanSpeed, 0), r = !0;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
r && (i.preventDefault(), e.update());
|
|
178
|
+
}
|
|
179
|
+
function Se(i) {
|
|
180
|
+
if (g.length === 1)
|
|
181
|
+
v.set(i.pageX, i.pageY);
|
|
182
|
+
else {
|
|
183
|
+
const r = Y(i), d = 0.5 * (i.pageX + r.x), u = 0.5 * (i.pageY + r.y);
|
|
184
|
+
v.set(d, u);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function Te(i) {
|
|
188
|
+
if (g.length === 1)
|
|
189
|
+
A.set(i.pageX, i.pageY);
|
|
190
|
+
else {
|
|
191
|
+
const r = Y(i), d = 0.5 * (i.pageX + r.x), u = 0.5 * (i.pageY + r.y);
|
|
192
|
+
A.set(d, u);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function Le(i) {
|
|
196
|
+
const r = Y(i), d = i.pageX - r.x, u = i.pageY - r.y, y = Math.sqrt(d * d + u * u);
|
|
197
|
+
z.set(0, y);
|
|
198
|
+
}
|
|
199
|
+
function ct(i) {
|
|
200
|
+
e.enableZoom && Le(i), e.enablePan && Te(i);
|
|
201
|
+
}
|
|
202
|
+
function dt(i) {
|
|
203
|
+
e.enableZoom && Le(i), e.enableRotate && Se(i);
|
|
204
|
+
}
|
|
205
|
+
function Pe(i) {
|
|
206
|
+
if (g.length == 1)
|
|
207
|
+
O.set(i.pageX, i.pageY);
|
|
208
|
+
else {
|
|
209
|
+
const d = Y(i), u = 0.5 * (i.pageX + d.x), y = 0.5 * (i.pageY + d.y);
|
|
210
|
+
O.set(u, y);
|
|
211
|
+
}
|
|
212
|
+
V.subVectors(O, v).multiplyScalar(e.rotateSpeed);
|
|
213
|
+
const r = e.domElement;
|
|
214
|
+
W(2 * Math.PI * V.x / r.clientHeight), ee(2 * Math.PI * V.y / r.clientHeight), v.copy(O);
|
|
215
|
+
}
|
|
216
|
+
function Me(i) {
|
|
217
|
+
if (g.length === 1)
|
|
218
|
+
k.set(i.pageX, i.pageY);
|
|
219
|
+
else {
|
|
220
|
+
const r = Y(i), d = 0.5 * (i.pageX + r.x), u = 0.5 * (i.pageY + r.y);
|
|
221
|
+
k.set(d, u);
|
|
222
|
+
}
|
|
223
|
+
B.subVectors(k, A).multiplyScalar(e.panSpeed), F(B.x, B.y), A.copy(k);
|
|
224
|
+
}
|
|
225
|
+
function Ie(i) {
|
|
226
|
+
const r = Y(i), d = i.pageX - r.x, u = i.pageY - r.y, y = Math.sqrt(d * d + u * u);
|
|
227
|
+
N.set(0, y), R.set(0, Math.pow(N.y / z.y, e.zoomSpeed)), re(R.y), z.copy(N);
|
|
228
|
+
const I = (i.pageX + r.x) * 0.5, b = (i.pageY + r.y) * 0.5;
|
|
229
|
+
ae(I, b);
|
|
230
|
+
}
|
|
231
|
+
function ut(i) {
|
|
232
|
+
e.enableZoom && Ie(i), e.enablePan && Me(i);
|
|
233
|
+
}
|
|
234
|
+
function mt(i) {
|
|
235
|
+
e.enableZoom && Ie(i), e.enableRotate && Pe(i);
|
|
236
|
+
}
|
|
237
|
+
function Ce(i) {
|
|
238
|
+
e.enabled !== !1 && (g.length === 0 && (e.domElement.setPointerCapture(i.pointerId), e.domElement.addEventListener("pointermove", le), e.domElement.addEventListener("pointerup", K)), !wt(i) && (yt(i), i.pointerType === "touch" ? ke(i) : pt(i)));
|
|
239
|
+
}
|
|
240
|
+
function le(i) {
|
|
241
|
+
e.enabled !== !1 && (i.pointerType === "touch" ? _t(i) : ft(i));
|
|
242
|
+
}
|
|
243
|
+
function K(i) {
|
|
244
|
+
switch (bt(i), g.length) {
|
|
245
|
+
case 0:
|
|
246
|
+
e.domElement.releasePointerCapture(i.pointerId), e.domElement.removeEventListener("pointermove", le), e.domElement.removeEventListener("pointerup", K), e.dispatchEvent(je), o = n.NONE;
|
|
247
|
+
break;
|
|
248
|
+
case 1:
|
|
249
|
+
const r = g[0], d = H[r];
|
|
250
|
+
ke({ pointerId: r, pageX: d.x, pageY: d.y });
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function pt(i) {
|
|
255
|
+
let r;
|
|
256
|
+
switch (i.button) {
|
|
257
|
+
case 0:
|
|
258
|
+
r = e.mouseButtons.LEFT;
|
|
259
|
+
break;
|
|
260
|
+
case 1:
|
|
261
|
+
r = e.mouseButtons.MIDDLE;
|
|
262
|
+
break;
|
|
263
|
+
case 2:
|
|
264
|
+
r = e.mouseButtons.RIGHT;
|
|
265
|
+
break;
|
|
266
|
+
default:
|
|
267
|
+
r = -1;
|
|
268
|
+
}
|
|
269
|
+
switch (r) {
|
|
270
|
+
case U.DOLLY:
|
|
271
|
+
if (e.enableZoom === !1) return;
|
|
272
|
+
nt(i), o = n.DOLLY;
|
|
273
|
+
break;
|
|
274
|
+
case U.ROTATE:
|
|
275
|
+
if (i.ctrlKey || i.metaKey || i.shiftKey) {
|
|
276
|
+
if (e.enablePan === !1) return;
|
|
277
|
+
xe(i), o = n.PAN;
|
|
278
|
+
} else {
|
|
279
|
+
if (e.enableRotate === !1) return;
|
|
280
|
+
De(i), o = n.ROTATE;
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case U.PAN:
|
|
284
|
+
if (i.ctrlKey || i.metaKey || i.shiftKey) {
|
|
285
|
+
if (e.enableRotate === !1) return;
|
|
286
|
+
De(i), o = n.ROTATE;
|
|
287
|
+
} else {
|
|
288
|
+
if (e.enablePan === !1) return;
|
|
289
|
+
xe(i), o = n.PAN;
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
default:
|
|
293
|
+
o = n.NONE;
|
|
294
|
+
}
|
|
295
|
+
o !== n.NONE && e.dispatchEvent(me);
|
|
296
|
+
}
|
|
297
|
+
function ft(i) {
|
|
298
|
+
switch (o) {
|
|
299
|
+
case n.ROTATE:
|
|
300
|
+
if (e.enableRotate === !1) return;
|
|
301
|
+
ot(i);
|
|
302
|
+
break;
|
|
303
|
+
case n.DOLLY:
|
|
304
|
+
if (e.enableZoom === !1) return;
|
|
305
|
+
rt(i);
|
|
306
|
+
break;
|
|
307
|
+
case n.PAN:
|
|
308
|
+
if (e.enablePan === !1) return;
|
|
309
|
+
at(i);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function ve(i) {
|
|
314
|
+
e.enabled === !1 || e.enableZoom === !1 || o !== n.NONE || (i.preventDefault(), e.dispatchEvent(me), ht(gt(i)), e.dispatchEvent(je));
|
|
315
|
+
}
|
|
316
|
+
function gt(i) {
|
|
317
|
+
const r = i.deltaMode, d = {
|
|
318
|
+
clientX: i.clientX,
|
|
319
|
+
clientY: i.clientY,
|
|
320
|
+
deltaY: i.deltaY
|
|
321
|
+
};
|
|
322
|
+
switch (r) {
|
|
323
|
+
case 1:
|
|
324
|
+
d.deltaY *= 16;
|
|
325
|
+
break;
|
|
326
|
+
case 2:
|
|
327
|
+
d.deltaY *= 100;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
return i.ctrlKey && !oe && (d.deltaY *= 10), d;
|
|
331
|
+
}
|
|
332
|
+
function Oe(i) {
|
|
333
|
+
i.key === "Control" && (oe = !0, e.domElement.getRootNode().addEventListener("keyup", Ae, { passive: !0, capture: !0 }));
|
|
334
|
+
}
|
|
335
|
+
function Ae(i) {
|
|
336
|
+
i.key === "Control" && (oe = !1, e.domElement.getRootNode().removeEventListener("keyup", Ae, { passive: !0, capture: !0 }));
|
|
337
|
+
}
|
|
338
|
+
function ce(i) {
|
|
339
|
+
e.enabled === !1 || e.enablePan === !1 || lt(i);
|
|
340
|
+
}
|
|
341
|
+
function ke(i) {
|
|
342
|
+
switch (Ve(i), g.length) {
|
|
343
|
+
case 1:
|
|
344
|
+
switch (e.touches.ONE) {
|
|
345
|
+
case G.ROTATE:
|
|
346
|
+
if (e.enableRotate === !1) return;
|
|
347
|
+
Se(i), o = n.TOUCH_ROTATE;
|
|
348
|
+
break;
|
|
349
|
+
case G.PAN:
|
|
350
|
+
if (e.enablePan === !1) return;
|
|
351
|
+
Te(i), o = n.TOUCH_PAN;
|
|
352
|
+
break;
|
|
353
|
+
default:
|
|
354
|
+
o = n.NONE;
|
|
355
|
+
}
|
|
356
|
+
break;
|
|
357
|
+
case 2:
|
|
358
|
+
switch (e.touches.TWO) {
|
|
359
|
+
case G.DOLLY_PAN:
|
|
360
|
+
if (e.enableZoom === !1 && e.enablePan === !1) return;
|
|
361
|
+
ct(i), o = n.TOUCH_DOLLY_PAN;
|
|
362
|
+
break;
|
|
363
|
+
case G.DOLLY_ROTATE:
|
|
364
|
+
if (e.enableZoom === !1 && e.enableRotate === !1) return;
|
|
365
|
+
dt(i), o = n.TOUCH_DOLLY_ROTATE;
|
|
366
|
+
break;
|
|
367
|
+
default:
|
|
368
|
+
o = n.NONE;
|
|
369
|
+
}
|
|
370
|
+
break;
|
|
371
|
+
default:
|
|
372
|
+
o = n.NONE;
|
|
373
|
+
}
|
|
374
|
+
o !== n.NONE && e.dispatchEvent(me);
|
|
375
|
+
}
|
|
376
|
+
function _t(i) {
|
|
377
|
+
switch (Ve(i), o) {
|
|
378
|
+
case n.TOUCH_ROTATE:
|
|
379
|
+
if (e.enableRotate === !1) return;
|
|
380
|
+
Pe(i), e.update();
|
|
381
|
+
break;
|
|
382
|
+
case n.TOUCH_PAN:
|
|
383
|
+
if (e.enablePan === !1) return;
|
|
384
|
+
Me(i), e.update();
|
|
385
|
+
break;
|
|
386
|
+
case n.TOUCH_DOLLY_PAN:
|
|
387
|
+
if (e.enableZoom === !1 && e.enablePan === !1) return;
|
|
388
|
+
ut(i), e.update();
|
|
389
|
+
break;
|
|
390
|
+
case n.TOUCH_DOLLY_ROTATE:
|
|
391
|
+
if (e.enableZoom === !1 && e.enableRotate === !1) return;
|
|
392
|
+
mt(i), e.update();
|
|
393
|
+
break;
|
|
394
|
+
default:
|
|
395
|
+
o = n.NONE;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function Re(i) {
|
|
399
|
+
e.enabled !== !1 && i.preventDefault();
|
|
400
|
+
}
|
|
401
|
+
function yt(i) {
|
|
402
|
+
g.push(i.pointerId);
|
|
403
|
+
}
|
|
404
|
+
function bt(i) {
|
|
405
|
+
delete H[i.pointerId];
|
|
406
|
+
for (let r = 0; r < g.length; r++)
|
|
407
|
+
if (g[r] == i.pointerId) {
|
|
408
|
+
g.splice(r, 1);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function wt(i) {
|
|
413
|
+
for (let r = 0; r < g.length; r++)
|
|
414
|
+
if (g[r] == i.pointerId) return !0;
|
|
415
|
+
return !1;
|
|
416
|
+
}
|
|
417
|
+
function Ve(i) {
|
|
418
|
+
let r = H[i.pointerId];
|
|
419
|
+
r === void 0 && (r = new E(), H[i.pointerId] = r), r.set(i.pageX, i.pageY);
|
|
420
|
+
}
|
|
421
|
+
function Y(i) {
|
|
422
|
+
const r = i.pointerId === g[0] ? g[1] : g[0];
|
|
423
|
+
return H[r];
|
|
424
|
+
}
|
|
425
|
+
e.domElement.addEventListener("contextmenu", Re), e.domElement.addEventListener("pointerdown", Ce), e.domElement.addEventListener("pointercancel", K), e.domElement.addEventListener("wheel", ve, { passive: !1 }), e.domElement.getRootNode().addEventListener("keydown", Oe, { passive: !0, capture: !0 }), this.update();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
const se = {
|
|
429
|
+
enableDamping: !0,
|
|
430
|
+
dampingFactor: 0.05
|
|
431
|
+
}, J = class J extends ti {
|
|
432
|
+
constructor(t, e, n = se) {
|
|
433
|
+
super(t, e);
|
|
434
|
+
a(this, "uuid", C.generateUUID());
|
|
435
|
+
a(this, "object");
|
|
436
|
+
this.domElement = e, this.domElement = e, this.object = t, this.enableDamping = n.enableDamping ?? se.enableDamping, this.dampingFactor = n.dampingFactor ?? se.dampingFactor, this.object.position.set(0, 2, 2), this.target.copy({ x: 0, y: 0.5, z: 0 }), this.update();
|
|
437
|
+
}
|
|
438
|
+
tick() {
|
|
439
|
+
this.enabled && this.update();
|
|
440
|
+
}
|
|
441
|
+
computeEncompassingView(t) {
|
|
442
|
+
const e = t.getCenter(new m()), n = t.getSize(new m()), o = Math.max(n.x, n.y, n.z) * 1.25;
|
|
443
|
+
return {
|
|
444
|
+
position: this.object.position.clone().normalize().clone().multiplyScalar(o),
|
|
445
|
+
target: e.clone()
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
zoomIn(t) {
|
|
449
|
+
const e = t || J.DEFAULT_ZOOM_FACTOR, { minDistance: n, maxDistance: o } = this;
|
|
450
|
+
this.minDistance = this.maxDistance = C.clamp(
|
|
451
|
+
this.getDistance() - e,
|
|
452
|
+
n + e,
|
|
453
|
+
o - e
|
|
454
|
+
), this.update(), this.minDistance = n, this.maxDistance = o;
|
|
455
|
+
}
|
|
456
|
+
zoomOut(t) {
|
|
457
|
+
const e = t || J.DEFAULT_ZOOM_FACTOR, { minDistance: n, maxDistance: o } = this;
|
|
458
|
+
this.minDistance = this.maxDistance = C.clamp(
|
|
459
|
+
this.getDistance() + e,
|
|
460
|
+
n + e,
|
|
461
|
+
o - e
|
|
462
|
+
), this.update(), this.minDistance = n, this.maxDistance = o;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
a(J, "DEFAULT_ZOOM_FACTOR", 1);
|
|
466
|
+
let ne = J;
|
|
467
|
+
class ii extends Pt {
|
|
468
|
+
constructor(t, e, n) {
|
|
469
|
+
super(-1, 1, 1, -1, 0.1, 100);
|
|
470
|
+
a(this, "axesHelper");
|
|
471
|
+
a(this, "_renderer");
|
|
472
|
+
a(this, "_scene");
|
|
473
|
+
a(this, "_camera");
|
|
474
|
+
a(this, "_restoreViewport", new Mt());
|
|
475
|
+
this.layers.mask = q, this.axesHelper = new It(0.5), this.axesHelper.layers.mask = q, this.axesHelper.material.depthTest = !1, this.axesHelper.position.set(0, 0, -1), this.axesHelper.setColors(
|
|
476
|
+
new D(Wt),
|
|
477
|
+
new D(Kt),
|
|
478
|
+
new D(Zt)
|
|
479
|
+
);
|
|
480
|
+
const o = new ue("X", 0.2, Xt), c = new ue("Y", 0.2, qt), l = new ue("Z", 0.2, Jt);
|
|
481
|
+
o.layers.mask = q, c.layers.mask = q, l.layers.mask = q, o.position.set(0.7, 0, 0), c.position.set(0, 0.7, 0), l.position.set(0, 0, 0.7), this.axesHelper.add(o), this.axesHelper.add(c), this.axesHelper.add(l), this.add(this.axesHelper), this._renderer = t, this._scene = e, this._camera = n, this._scene.add(this);
|
|
482
|
+
}
|
|
483
|
+
tick() {
|
|
484
|
+
const t = this._scene.background;
|
|
485
|
+
this._scene.background = null, this._renderer.webglrenderer.getViewport(this._restoreViewport), this._renderer.webglrenderer.setViewport(0, 0, 150, 150), this._renderer.webglrenderer.autoClear = !1, this.SetFromCameraMatrix(this._camera.matrix), this._renderer.webglrenderer.render(this._scene, this), this._renderer.webglrenderer.setViewport(this._restoreViewport), this._renderer.webglrenderer.autoClear = !0, this._scene.background = t;
|
|
486
|
+
}
|
|
487
|
+
Dispose() {
|
|
488
|
+
this._scene.remove(this);
|
|
489
|
+
}
|
|
490
|
+
SetFromCameraMatrix(t) {
|
|
491
|
+
this.axesHelper.rotation.setFromRotationMatrix(
|
|
492
|
+
new Ct().extractRotation(t).invert()
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
class si extends j {
|
|
497
|
+
constructor() {
|
|
498
|
+
super();
|
|
499
|
+
a(this, "isDIVELight", !0);
|
|
500
|
+
a(this, "isDIVEAmbientLight", !0);
|
|
501
|
+
a(this, "_light");
|
|
502
|
+
this.name = "DIVEAmbientLight", this._light = new vt(16777215, 1), this._light.layers.mask = P, this.add(this._light);
|
|
503
|
+
}
|
|
504
|
+
setColor(t) {
|
|
505
|
+
this._light.color = t;
|
|
506
|
+
}
|
|
507
|
+
setIntensity(t) {
|
|
508
|
+
this._light.intensity = t;
|
|
509
|
+
}
|
|
510
|
+
setEnabled(t) {
|
|
511
|
+
this._light.visible = t;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
class ni extends j {
|
|
515
|
+
constructor() {
|
|
516
|
+
super();
|
|
517
|
+
a(this, "isDIVELight", !0);
|
|
518
|
+
a(this, "isDIVEPointLight", !0);
|
|
519
|
+
a(this, "isMovable", !0);
|
|
520
|
+
a(this, "isSelectable", !0);
|
|
521
|
+
a(this, "gizmo", null);
|
|
522
|
+
a(this, "light");
|
|
523
|
+
a(this, "mesh");
|
|
524
|
+
this.name = "DIVEPointLight", this.light = new Ot(16777215, 1), this.light.layers.mask = P, this.light.castShadow = !0, this.light.shadow.mapSize.width = 512, this.light.shadow.mapSize.height = 512, this.add(this.light);
|
|
525
|
+
const t = 0.1, e = new Ke(
|
|
526
|
+
t,
|
|
527
|
+
t * 320,
|
|
528
|
+
t * 320
|
|
529
|
+
), n = new At({
|
|
530
|
+
color: this.light.color,
|
|
531
|
+
transparent: !0,
|
|
532
|
+
opacity: 0.8,
|
|
533
|
+
side: kt
|
|
534
|
+
});
|
|
535
|
+
this.mesh = new pe(e, n), this.mesh.layers.mask = jt, this.add(this.mesh);
|
|
536
|
+
}
|
|
537
|
+
setColor(t) {
|
|
538
|
+
this.light.color = t, this.mesh.material.color = t;
|
|
539
|
+
}
|
|
540
|
+
setIntensity(t) {
|
|
541
|
+
this.light.intensity = t, this.mesh.material.opacity = t > 0.8 ? 0.8 : t * 0.8;
|
|
542
|
+
}
|
|
543
|
+
setEnabled(t) {
|
|
544
|
+
this.light.visible = t;
|
|
545
|
+
}
|
|
546
|
+
onMove() {
|
|
547
|
+
w("State").then((t) => {
|
|
548
|
+
var e;
|
|
549
|
+
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
550
|
+
id: this.userData.id,
|
|
551
|
+
position: this.position
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
onSelect() {
|
|
556
|
+
w("State").then((t) => {
|
|
557
|
+
var e;
|
|
558
|
+
(e = t.get(this.userData.id)) == null || e.performAction("SELECT_OBJECT", {
|
|
559
|
+
id: this.userData.id
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
onDeselect() {
|
|
564
|
+
w("State").then((t) => {
|
|
565
|
+
var e;
|
|
566
|
+
(e = t.get(this.userData.id)) == null || e.performAction("DESELECT_OBJECT", {
|
|
567
|
+
id: this.userData.id
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
class Je extends j {
|
|
573
|
+
constructor() {
|
|
574
|
+
super();
|
|
575
|
+
a(this, "isDIVELight", !0);
|
|
576
|
+
a(this, "isDIVESceneLight", !0);
|
|
577
|
+
a(this, "_hemiLight");
|
|
578
|
+
a(this, "_dirLight");
|
|
579
|
+
this.name = "DIVESceneLight", this._hemiLight = new Rt(16777215, 16777215, 2), this._hemiLight.layers.mask = P, this._hemiLight.position.set(0, 50, 0), this.add(this._hemiLight), this._dirLight = new Vt(16777215, 3), this._dirLight.layers.mask = P, this._dirLight.position.set(1, 1.75, 1), this._dirLight.position.multiplyScalar(30), this._dirLight.castShadow = !0, this._dirLight.shadow.mapSize.width = 2048, this._dirLight.shadow.mapSize.height = 2048;
|
|
580
|
+
const t = 5;
|
|
581
|
+
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);
|
|
582
|
+
}
|
|
583
|
+
setColor(t) {
|
|
584
|
+
this._hemiLight.color = t, this._dirLight.color = t;
|
|
585
|
+
}
|
|
586
|
+
setIntensity(t) {
|
|
587
|
+
this._hemiLight.intensity = t * 2, this._dirLight.intensity = t * 3;
|
|
588
|
+
}
|
|
589
|
+
setEnabled(t) {
|
|
590
|
+
this._hemiLight.visible = t, this._dirLight.visible = t;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const ge = (h) => h.parent ? ge(h.parent) : h;
|
|
594
|
+
class oi {
|
|
595
|
+
constructor() {
|
|
596
|
+
a(this, "isMovable", !0);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
class ri {
|
|
600
|
+
constructor() {
|
|
601
|
+
a(this, "isSelectable", !0);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
function ai(h, s) {
|
|
605
|
+
return s.forEach((t) => {
|
|
606
|
+
Object.getOwnPropertyNames(t.prototype).forEach((e) => {
|
|
607
|
+
Object.defineProperty(
|
|
608
|
+
h.prototype,
|
|
609
|
+
e,
|
|
610
|
+
Object.getOwnPropertyDescriptor(t.prototype, e)
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
}), h;
|
|
614
|
+
}
|
|
615
|
+
class _e extends ai(j, [
|
|
616
|
+
ri,
|
|
617
|
+
oi
|
|
618
|
+
]) {
|
|
619
|
+
constructor() {
|
|
620
|
+
super();
|
|
621
|
+
a(this, "isDIVENode", !0);
|
|
622
|
+
a(this, "gizmo", null);
|
|
623
|
+
a(this, "_positionWorldBuffer");
|
|
624
|
+
a(this, "_boundingBox");
|
|
625
|
+
this.layers.mask = P, this._positionWorldBuffer = new m(), this._boundingBox = new Ze();
|
|
626
|
+
}
|
|
627
|
+
SetPosition(t) {
|
|
628
|
+
if (!this.parent) {
|
|
629
|
+
this.position.set(t.x, t.y, t.z);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
const e = new m(t.x, t.y, t.z);
|
|
633
|
+
this.position.copy(this.parent.worldToLocal(e)), "isDIVEGroup" in this.parent && this.parent.UpdateLineTo(this);
|
|
634
|
+
}
|
|
635
|
+
SetRotation(t) {
|
|
636
|
+
this.rotation.set(t.x, t.y, t.z);
|
|
637
|
+
}
|
|
638
|
+
SetScale(t) {
|
|
639
|
+
this.scale.set(t.x, t.y, t.z);
|
|
640
|
+
}
|
|
641
|
+
setVisibility(t) {
|
|
642
|
+
this.visible = t;
|
|
643
|
+
}
|
|
644
|
+
SetToWorldOrigin() {
|
|
645
|
+
this.position.set(0, 0, 0), w("State").then((t) => {
|
|
646
|
+
var e;
|
|
647
|
+
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
648
|
+
id: this.userData.id,
|
|
649
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
650
|
+
rotation: this.rotation,
|
|
651
|
+
scale: this.scale
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
657
|
+
*/
|
|
658
|
+
onMove() {
|
|
659
|
+
w("State").then((t) => {
|
|
660
|
+
var e;
|
|
661
|
+
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
662
|
+
id: this.userData.id,
|
|
663
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
664
|
+
rotation: this.rotation,
|
|
665
|
+
scale: this.scale
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
onSelect() {
|
|
670
|
+
w("State").then((t) => {
|
|
671
|
+
var e;
|
|
672
|
+
(e = t.get(this.userData.id)) == null || e.performAction("SELECT_OBJECT", {
|
|
673
|
+
id: this.userData.id
|
|
674
|
+
});
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
onDeselect() {
|
|
678
|
+
w("State").then((t) => {
|
|
679
|
+
var e;
|
|
680
|
+
(e = t.get(this.userData.id)) == null || e.performAction("DESELECT_OBJECT", {
|
|
681
|
+
id: this.userData.id
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
class $e extends _e {
|
|
687
|
+
constructor() {
|
|
688
|
+
super(...arguments);
|
|
689
|
+
a(this, "isDIVEModel", !0);
|
|
690
|
+
a(this, "_mesh", null);
|
|
691
|
+
a(this, "_material", null);
|
|
692
|
+
a(this, "_assetLoader", null);
|
|
693
|
+
}
|
|
694
|
+
async _getAssetLoader() {
|
|
695
|
+
return this._assetLoader || (this._assetLoader = new (await w("AssetLoader"))()), this._assetLoader;
|
|
696
|
+
}
|
|
697
|
+
async setFromURL(t) {
|
|
698
|
+
const n = await (await this._getAssetLoader()).load(t);
|
|
699
|
+
this.setFromGLTF(n), w("State").then((o) => {
|
|
700
|
+
var c;
|
|
701
|
+
(c = o.get(this.userData.id)) == null || c.performAction("MODEL_LOADED", {
|
|
702
|
+
id: this.userData.id
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
setFromGLTF(t) {
|
|
707
|
+
this.clear(), this._boundingBox.makeEmpty(), t.traverse((e) => {
|
|
708
|
+
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);
|
|
709
|
+
}), this.add(t);
|
|
710
|
+
}
|
|
711
|
+
setMaterial(t) {
|
|
712
|
+
this._material || (this._material = new fe()), 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);
|
|
713
|
+
}
|
|
714
|
+
placeOnFloor() {
|
|
715
|
+
var o, c, l, p;
|
|
716
|
+
const t = this.getWorldPosition(this._positionWorldBuffer), e = t.clone();
|
|
717
|
+
(c = (o = this._mesh) == null ? void 0 : o.geometry) == null || c.computeBoundingBox();
|
|
718
|
+
const n = (p = (l = this._mesh) == null ? void 0 : l.geometry) == null ? void 0 : p.boundingBox;
|
|
719
|
+
!n || !this._mesh || (t.y = t.y - this._mesh.localToWorld(n.min.clone()).y, t.y !== e.y && w("State").then((f) => {
|
|
720
|
+
var _;
|
|
721
|
+
(_ = f.get(this.userData.id)) == null || _.performAction("UPDATE_OBJECT", {
|
|
722
|
+
id: this.userData.id,
|
|
723
|
+
position: t,
|
|
724
|
+
rotation: this.rotation,
|
|
725
|
+
scale: this.scale
|
|
726
|
+
});
|
|
727
|
+
}));
|
|
728
|
+
}
|
|
729
|
+
dropIt() {
|
|
730
|
+
if (!this.parent) {
|
|
731
|
+
console.warn(
|
|
732
|
+
"DIVEModel: dropIt() called on a model that is not in the scene.",
|
|
733
|
+
this
|
|
734
|
+
);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const t = this._boundingBox.min.y * this.scale.y, e = this.localToWorld(
|
|
738
|
+
this._boundingBox.getCenter(new m()).multiply(this.scale)
|
|
739
|
+
);
|
|
740
|
+
e.y = t + this.position.y;
|
|
741
|
+
const n = new Xe(e, new m(0, -1, 0));
|
|
742
|
+
n.layers.mask = P;
|
|
743
|
+
const o = n.intersectObjects(
|
|
744
|
+
ge(this).root.children,
|
|
745
|
+
!0
|
|
746
|
+
);
|
|
747
|
+
if (o.length > 0) {
|
|
748
|
+
const c = o[0].object;
|
|
749
|
+
c.geometry.computeBoundingBox();
|
|
750
|
+
const l = c.geometry.boundingBox, p = c.localToWorld(l.max.clone()), f = this.position.clone(), _ = this.position.clone().setY(p.y).sub(new m(0, t, 0));
|
|
751
|
+
if (this.position.copy(_), this.position.y === f.y) return;
|
|
752
|
+
this.onMove();
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
class hi extends _e {
|
|
757
|
+
constructor() {
|
|
758
|
+
super();
|
|
759
|
+
a(this, "isDIVEPrimitive", !0);
|
|
760
|
+
a(this, "_mesh");
|
|
761
|
+
this._mesh = new pe(), this._mesh.layers.mask = P, this._mesh.castShadow = !0, this._mesh.receiveShadow = !0, this._mesh.material = new fe(), this.add(this._mesh);
|
|
762
|
+
}
|
|
763
|
+
SetGeometry(t) {
|
|
764
|
+
const e = this.assembleGeometry(t);
|
|
765
|
+
e && (this._mesh.geometry = e, this._boundingBox.setFromObject(this._mesh));
|
|
766
|
+
}
|
|
767
|
+
setMaterial(t) {
|
|
768
|
+
const e = this._mesh.material;
|
|
769
|
+
t.vertexColors !== void 0 && (e.vertexColors = t.vertexColors), t.color !== void 0 && (e.color = new D(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);
|
|
770
|
+
}
|
|
771
|
+
placeOnFloor() {
|
|
772
|
+
var o, c, l, p;
|
|
773
|
+
const t = this.getWorldPosition(this._positionWorldBuffer), e = t.clone();
|
|
774
|
+
(c = (o = this._mesh) == null ? void 0 : o.geometry) == null || c.computeBoundingBox();
|
|
775
|
+
const n = (p = (l = this._mesh) == null ? void 0 : l.geometry) == null ? void 0 : p.boundingBox;
|
|
776
|
+
!n || !this._mesh || (t.y = t.y - this._mesh.localToWorld(n.min.clone()).y, t.y !== e.y && w("State").then((f) => {
|
|
777
|
+
var _;
|
|
778
|
+
(_ = f.get(this.userData.id)) == null || _.performAction("UPDATE_OBJECT", {
|
|
779
|
+
id: this.userData.id,
|
|
780
|
+
position: t,
|
|
781
|
+
rotation: this.rotation,
|
|
782
|
+
scale: this.scale
|
|
783
|
+
});
|
|
784
|
+
}));
|
|
785
|
+
}
|
|
786
|
+
dropIt() {
|
|
787
|
+
if (!this.parent) {
|
|
788
|
+
console.warn(
|
|
789
|
+
"DIVEPrimitive: dropIt() called on a model that is not in the scene.",
|
|
790
|
+
this
|
|
791
|
+
);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
const t = this._boundingBox.min.y * this.scale.y, e = this.localToWorld(
|
|
795
|
+
this._boundingBox.getCenter(new m()).multiply(this.scale)
|
|
796
|
+
);
|
|
797
|
+
e.y = t + this.position.y;
|
|
798
|
+
const n = new Xe(e, new m(0, -1, 0));
|
|
799
|
+
n.layers.mask = P;
|
|
800
|
+
const o = n.intersectObjects(
|
|
801
|
+
ge(this).root.children,
|
|
802
|
+
!0
|
|
803
|
+
);
|
|
804
|
+
if (o.length > 0) {
|
|
805
|
+
const c = o[0].object;
|
|
806
|
+
c.geometry.computeBoundingBox();
|
|
807
|
+
const l = c.geometry.boundingBox, p = c.localToWorld(l.max.clone()), f = this.position.clone(), _ = this.position.clone().setY(p.y).sub(new m(0, t, 0));
|
|
808
|
+
if (this.position.copy(_), this.position.y === f.y) return;
|
|
809
|
+
this.onMove();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
assembleGeometry(t) {
|
|
813
|
+
switch (this._mesh.material.flatShading = !1, t.name.toLowerCase()) {
|
|
814
|
+
case "cylinder":
|
|
815
|
+
return this.createCylinderGeometry(t);
|
|
816
|
+
case "sphere":
|
|
817
|
+
return this.createSphereGeometry(t);
|
|
818
|
+
case "pyramid":
|
|
819
|
+
return this._mesh.material.flatShading = !0, this.createPyramidGeometry(t);
|
|
820
|
+
case "cube":
|
|
821
|
+
case "box":
|
|
822
|
+
return this.createBoxGeometry(t);
|
|
823
|
+
case "cone":
|
|
824
|
+
return this.createConeGeometry(t);
|
|
825
|
+
case "wall":
|
|
826
|
+
return this.createWallGeometry(t);
|
|
827
|
+
case "plane":
|
|
828
|
+
return this.createPlaneGeometry(t);
|
|
829
|
+
default:
|
|
830
|
+
return console.warn(
|
|
831
|
+
"DIVEPrimitive.assembleGeometry: Invalid geometry type:",
|
|
832
|
+
t.name.toLowerCase()
|
|
833
|
+
), null;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
createCylinderGeometry(t) {
|
|
837
|
+
const e = new Bt(
|
|
838
|
+
t.width / 2,
|
|
839
|
+
t.width / 2,
|
|
840
|
+
t.height,
|
|
841
|
+
64
|
|
842
|
+
);
|
|
843
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
844
|
+
}
|
|
845
|
+
createSphereGeometry(t) {
|
|
846
|
+
return new Ke(t.width / 2, 256, 256);
|
|
847
|
+
}
|
|
848
|
+
createPyramidGeometry(t) {
|
|
849
|
+
const e = new Float32Array([
|
|
850
|
+
-t.width / 2,
|
|
851
|
+
0,
|
|
852
|
+
-t.depth / 2,
|
|
853
|
+
// 0
|
|
854
|
+
t.width / 2,
|
|
855
|
+
0,
|
|
856
|
+
-t.depth / 2,
|
|
857
|
+
// 1
|
|
858
|
+
t.width / 2,
|
|
859
|
+
0,
|
|
860
|
+
t.depth / 2,
|
|
861
|
+
// 2
|
|
862
|
+
-t.width / 2,
|
|
863
|
+
0,
|
|
864
|
+
t.depth / 2,
|
|
865
|
+
// 3
|
|
866
|
+
0,
|
|
867
|
+
t.height,
|
|
868
|
+
0
|
|
869
|
+
]), n = new Uint16Array([
|
|
870
|
+
0,
|
|
871
|
+
1,
|
|
872
|
+
2,
|
|
873
|
+
0,
|
|
874
|
+
2,
|
|
875
|
+
3,
|
|
876
|
+
0,
|
|
877
|
+
4,
|
|
878
|
+
1,
|
|
879
|
+
1,
|
|
880
|
+
4,
|
|
881
|
+
2,
|
|
882
|
+
2,
|
|
883
|
+
4,
|
|
884
|
+
3,
|
|
885
|
+
3,
|
|
886
|
+
4,
|
|
887
|
+
0
|
|
888
|
+
]), o = new qe();
|
|
889
|
+
return o.setAttribute(
|
|
890
|
+
"position",
|
|
891
|
+
new Ye(e, 3)
|
|
892
|
+
), o.setIndex(new Ye(n, 1)), o.computeVertexNormals(), o.computeBoundingBox(), o.computeBoundingSphere(), o;
|
|
893
|
+
}
|
|
894
|
+
createBoxGeometry(t) {
|
|
895
|
+
const e = new de(
|
|
896
|
+
t.width,
|
|
897
|
+
t.height,
|
|
898
|
+
t.depth
|
|
899
|
+
);
|
|
900
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
901
|
+
}
|
|
902
|
+
createConeGeometry(t) {
|
|
903
|
+
const e = new zt(t.width / 2, t.height, 256);
|
|
904
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
905
|
+
}
|
|
906
|
+
createWallGeometry(t) {
|
|
907
|
+
const e = new de(
|
|
908
|
+
t.width,
|
|
909
|
+
t.height,
|
|
910
|
+
t.depth || 0.05,
|
|
911
|
+
16
|
|
912
|
+
);
|
|
913
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
914
|
+
}
|
|
915
|
+
createPlaneGeometry(t) {
|
|
916
|
+
const e = new de(
|
|
917
|
+
t.width,
|
|
918
|
+
t.height,
|
|
919
|
+
t.depth
|
|
920
|
+
);
|
|
921
|
+
return e.translate(0, t.height / 2, 0), e;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
class li extends _e {
|
|
925
|
+
// lines to children
|
|
926
|
+
constructor() {
|
|
927
|
+
super();
|
|
928
|
+
a(this, "isDIVEGroup", !0);
|
|
929
|
+
a(this, "_members");
|
|
930
|
+
a(this, "_lines");
|
|
931
|
+
this.name = "DIVEGroup", this._members = [], this._lines = [];
|
|
932
|
+
}
|
|
933
|
+
// children objects
|
|
934
|
+
get members() {
|
|
935
|
+
return this._members;
|
|
936
|
+
}
|
|
937
|
+
SetPosition(t) {
|
|
938
|
+
super.SetPosition(t), this._members.forEach((e) => {
|
|
939
|
+
"isDIVENode" in e && e.onMove();
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
SetLinesVisibility(t, e) {
|
|
943
|
+
if (!e) {
|
|
944
|
+
this._lines.forEach((o) => {
|
|
945
|
+
o.visible = t;
|
|
946
|
+
});
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
const n = this._members.indexOf(e);
|
|
950
|
+
n !== -1 && (this._lines[n].visible = t);
|
|
951
|
+
}
|
|
952
|
+
attach(t) {
|
|
953
|
+
if (this._members.includes(t))
|
|
954
|
+
return this;
|
|
955
|
+
const e = this.createLine();
|
|
956
|
+
return this.add(e), this._lines.push(e), super.attach(t), this._members.push(t), this.updateLineTo(e, t), this.SetLinesVisibility(!0, t), this;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Removes an object from the group.
|
|
960
|
+
* @param object - The object to remove.
|
|
961
|
+
* @returns The group instance.
|
|
962
|
+
*/
|
|
963
|
+
remove(t) {
|
|
964
|
+
const e = this._members.indexOf(t);
|
|
965
|
+
if (e === -1)
|
|
966
|
+
return this;
|
|
967
|
+
const n = this._lines[e];
|
|
968
|
+
return super.remove(n), this._lines.splice(e, 1), super.remove(t), this._members.splice(e, 1), this;
|
|
969
|
+
}
|
|
970
|
+
UpdateLineTo(t) {
|
|
971
|
+
const e = this._members.indexOf(t);
|
|
972
|
+
e !== -1 && this.updateLineTo(this._lines[e], t);
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Creates a line for visualization.
|
|
976
|
+
*/
|
|
977
|
+
createLine() {
|
|
978
|
+
const t = new qe(), e = new Nt({
|
|
979
|
+
color: 6710886,
|
|
980
|
+
dashSize: 0.05,
|
|
981
|
+
gapSize: 0.025
|
|
982
|
+
}), n = new Ft(t, e);
|
|
983
|
+
return n.visible = !1, n;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Updates a line to the object.
|
|
987
|
+
*/
|
|
988
|
+
updateLineTo(t, e) {
|
|
989
|
+
const n = [
|
|
990
|
+
new m(0, 0, 0),
|
|
991
|
+
e.position.clone()
|
|
992
|
+
];
|
|
993
|
+
t.geometry.setFromPoints(n), t.computeLineDistances();
|
|
994
|
+
}
|
|
995
|
+
// public SetBoundingBoxVisibility(visible: boolean): void {
|
|
996
|
+
// this._boxMesh.visible = visible;
|
|
997
|
+
// }
|
|
998
|
+
// /**
|
|
999
|
+
// * Recalculates the position of the group based on it's bounding box.
|
|
1000
|
+
// * Children's world positions are kept.
|
|
1001
|
+
// */
|
|
1002
|
+
// private recalculatePosition(): void {
|
|
1003
|
+
// // store all children's world positions
|
|
1004
|
+
// const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
|
|
1005
|
+
// // calculate new center and set it as the group's position
|
|
1006
|
+
// const bbcenter = this.updateBB();
|
|
1007
|
+
// this.position.copy(bbcenter);
|
|
1008
|
+
// // set childrens's positions so their world positions are kept
|
|
1009
|
+
// this.children.forEach((child, i) => {
|
|
1010
|
+
// if (child.uuid === this._boxMesh.uuid) return;
|
|
1011
|
+
// child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1012
|
+
// });
|
|
1013
|
+
// DIVECommunication.get(this.userData.id)?.performAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
|
|
1014
|
+
// }
|
|
1015
|
+
// /**
|
|
1016
|
+
// * Updates the bounding box of the group.
|
|
1017
|
+
// * @returns {Vector3} The new center of the bounding box.
|
|
1018
|
+
// */
|
|
1019
|
+
// private updateBB(): Vector3 {
|
|
1020
|
+
// this._boundingBox.makeEmpty();
|
|
1021
|
+
// if (this.children.length === 1) {
|
|
1022
|
+
// // because we always have the box mesh as 1 child
|
|
1023
|
+
// return this.position.clone();
|
|
1024
|
+
// }
|
|
1025
|
+
// this.children.forEach((child) => {
|
|
1026
|
+
// if (child.uuid === this._boxMesh.uuid) return;
|
|
1027
|
+
// this._boundingBox.expandByObject(child);
|
|
1028
|
+
// });
|
|
1029
|
+
// return this._boundingBox.getCenter(new Vector3());
|
|
1030
|
+
// }
|
|
1031
|
+
// private updateBoxMesh(): void {
|
|
1032
|
+
// if (this.children.length === 1) {
|
|
1033
|
+
// // because we always have the box mesh as 1 child
|
|
1034
|
+
// this._boxMesh.visible = false;
|
|
1035
|
+
// return;
|
|
1036
|
+
// }
|
|
1037
|
+
// this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
1038
|
+
// this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
1039
|
+
// 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);
|
|
1040
|
+
// this._boxMesh.visible = true;
|
|
1041
|
+
// }
|
|
1042
|
+
}
|
|
1043
|
+
class ci extends pe {
|
|
1044
|
+
constructor() {
|
|
1045
|
+
super(
|
|
1046
|
+
new Yt(1e4, 1e4),
|
|
1047
|
+
new fe({
|
|
1048
|
+
color: new D(150 / 255, 150 / 255, 150 / 255)
|
|
1049
|
+
})
|
|
1050
|
+
);
|
|
1051
|
+
a(this, "isDIVEFloor", !0);
|
|
1052
|
+
this.name = "Floor", this.layers.mask = P, this.receiveShadow = !0, this.rotateX(-Math.PI / 2);
|
|
1053
|
+
}
|
|
1054
|
+
setVisibility(t) {
|
|
1055
|
+
this.visible = t;
|
|
1056
|
+
}
|
|
1057
|
+
setColor(t) {
|
|
1058
|
+
this.material.color = new D(t);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
class di extends j {
|
|
1062
|
+
constructor() {
|
|
1063
|
+
super();
|
|
1064
|
+
a(this, "isDIVERoot", !0);
|
|
1065
|
+
a(this, "_floor");
|
|
1066
|
+
a(this, "_assetLoader", null);
|
|
1067
|
+
this.name = "Root", this._floor = new ci(), this.add(this._floor);
|
|
1068
|
+
}
|
|
1069
|
+
get floor() {
|
|
1070
|
+
return this._floor;
|
|
1071
|
+
}
|
|
1072
|
+
async _getAssetLoader() {
|
|
1073
|
+
return this._assetLoader || (this._assetLoader = new (await w("AssetLoader"))()), this._assetLoader;
|
|
1074
|
+
}
|
|
1075
|
+
computeSceneBB() {
|
|
1076
|
+
const t = new Ze();
|
|
1077
|
+
return this.children.forEach((e) => {
|
|
1078
|
+
"isDIVEFloor" in e || e.traverse((n) => {
|
|
1079
|
+
"isObject3D" in n && t.expandByObject(n);
|
|
1080
|
+
});
|
|
1081
|
+
}), t;
|
|
1082
|
+
}
|
|
1083
|
+
getSceneObject(t) {
|
|
1084
|
+
let e;
|
|
1085
|
+
return this.traverse((n) => {
|
|
1086
|
+
e || n.userData.id === t.id && (e = n);
|
|
1087
|
+
}), e;
|
|
1088
|
+
}
|
|
1089
|
+
addSceneObject(t) {
|
|
1090
|
+
let e = this.getSceneObject(t);
|
|
1091
|
+
if (e)
|
|
1092
|
+
return console.warn(
|
|
1093
|
+
`DIVERoot.addSceneObject: Scene object with id ${t.id} already exists`
|
|
1094
|
+
), e;
|
|
1095
|
+
switch (t.entityType) {
|
|
1096
|
+
case "pov":
|
|
1097
|
+
break;
|
|
1098
|
+
case "light": {
|
|
1099
|
+
switch (t.type) {
|
|
1100
|
+
case "scene": {
|
|
1101
|
+
e = new Je();
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
case "ambient": {
|
|
1105
|
+
e = new si();
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
case "point": {
|
|
1109
|
+
e = new ni();
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
default:
|
|
1113
|
+
throw new Error(
|
|
1114
|
+
`DIVERoot.addSceneObject: Unknown light type: ${t.type}`
|
|
1115
|
+
);
|
|
1116
|
+
}
|
|
1117
|
+
e.name = t.name, e.userData.id = t.id, this.add(e), this._updateLight(e, t);
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
case "model": {
|
|
1121
|
+
e = new $e(), e.name = t.name, e.userData.id = t.id, e.userData.uri = t.uri, this.add(e), this._updateModel(e, t);
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
case "primitive": {
|
|
1125
|
+
e = new hi(), e.name = t.name, e.userData.id = t.id, this.add(e), this._updatePrimitive(e, t);
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
case "group": {
|
|
1129
|
+
e = new li(), e.name = t.name, e.userData.id = t.id, this.add(e), this._updateGroup(e, t);
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
default:
|
|
1133
|
+
throw new Error(
|
|
1134
|
+
`DIVERoot.addSceneObject: Unknown entity type: ${t.entityType}`
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
return e;
|
|
1138
|
+
}
|
|
1139
|
+
updateSceneObject(t) {
|
|
1140
|
+
const e = this.getSceneObject(t);
|
|
1141
|
+
if (!e) {
|
|
1142
|
+
console.warn(
|
|
1143
|
+
`DIVERoot.updateSceneObject: Scene object with id ${t.id} does not exist`
|
|
1144
|
+
);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
switch (t.entityType) {
|
|
1148
|
+
case "pov":
|
|
1149
|
+
break;
|
|
1150
|
+
case "light": {
|
|
1151
|
+
this._updateLight(e, t);
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
case "model": {
|
|
1155
|
+
this._updateModel(e, t);
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
case "primitive": {
|
|
1159
|
+
this._updatePrimitive(e, t);
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
case "group": {
|
|
1163
|
+
this._updateGroup(e, t);
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
default:
|
|
1167
|
+
throw new Error(
|
|
1168
|
+
`DIVERoot.updateSceneObject: Unknown entity type: ${t.entityType}`
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
deleteSceneObject(t) {
|
|
1173
|
+
const e = this.getSceneObject(t);
|
|
1174
|
+
if (!e) {
|
|
1175
|
+
console.warn(
|
|
1176
|
+
`DIVERoot.deleteSceneObject: Object with id ${t.id} not found`
|
|
1177
|
+
);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
switch (t.entityType) {
|
|
1181
|
+
case "pov":
|
|
1182
|
+
break;
|
|
1183
|
+
case "light": {
|
|
1184
|
+
this._deleteLight(e);
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
case "model": {
|
|
1188
|
+
this._deleteModel(e);
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
case "primitive": {
|
|
1192
|
+
this._deletePrimitive(e);
|
|
1193
|
+
break;
|
|
1194
|
+
}
|
|
1195
|
+
case "group": {
|
|
1196
|
+
this._deleteGroup(e);
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
default:
|
|
1200
|
+
throw new Error(
|
|
1201
|
+
`DIVERoot.deleteSceneObject: Unknown entity type: ${t.entityType}`
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
_updateLight(t, e) {
|
|
1206
|
+
e.name !== void 0 && e.name !== null && (t.name = e.name), e.position !== void 0 && e.position !== null && t.position.set(
|
|
1207
|
+
e.position.x,
|
|
1208
|
+
e.position.y,
|
|
1209
|
+
e.position.z
|
|
1210
|
+
), 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 D(e.color)), e.visible !== void 0 && e.visible !== null && (t.visible = e.visible), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
1211
|
+
}
|
|
1212
|
+
_updateModel(t, e) {
|
|
1213
|
+
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 });
|
|
1214
|
+
}
|
|
1215
|
+
_updatePrimitive(t, e) {
|
|
1216
|
+
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 });
|
|
1217
|
+
}
|
|
1218
|
+
_updateGroup(t, e) {
|
|
1219
|
+
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 });
|
|
1220
|
+
}
|
|
1221
|
+
_deleteLight(t) {
|
|
1222
|
+
this._detachTransformControls(t), t.parent.remove(t);
|
|
1223
|
+
}
|
|
1224
|
+
_deleteModel(t) {
|
|
1225
|
+
this._detachTransformControls(t), t.parent.remove(t);
|
|
1226
|
+
}
|
|
1227
|
+
_deletePrimitive(t) {
|
|
1228
|
+
this._detachTransformControls(t), t.parent.remove(t);
|
|
1229
|
+
}
|
|
1230
|
+
_deleteGroup(t) {
|
|
1231
|
+
this._detachTransformControls(t);
|
|
1232
|
+
for (let e = t.members.length - 1; e >= 0; e--)
|
|
1233
|
+
this.attach(t.members[e]);
|
|
1234
|
+
t.parent.remove(t);
|
|
1235
|
+
}
|
|
1236
|
+
_setParent(t) {
|
|
1237
|
+
const e = this.getSceneObject(t);
|
|
1238
|
+
if (t.parentId !== null) {
|
|
1239
|
+
const n = this.getSceneObject({
|
|
1240
|
+
id: t.parentId,
|
|
1241
|
+
entityType: t.entityType
|
|
1242
|
+
});
|
|
1243
|
+
if (!n) return;
|
|
1244
|
+
n.attach(e);
|
|
1245
|
+
} else
|
|
1246
|
+
this.attach(e);
|
|
1247
|
+
}
|
|
1248
|
+
_detachTransformControls(t) {
|
|
1249
|
+
this._findScene(t).children.find((e) => {
|
|
1250
|
+
"isTransformControls" in e && e.detach();
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
_findScene(t) {
|
|
1254
|
+
return t.parent !== null ? this._findScene(t.parent) : t;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
const ui = "#888888", mi = "#dddddd";
|
|
1258
|
+
class pi extends j {
|
|
1259
|
+
constructor() {
|
|
1260
|
+
super(), this.name = "Grid";
|
|
1261
|
+
const s = new Ut(
|
|
1262
|
+
100,
|
|
1263
|
+
100,
|
|
1264
|
+
ui,
|
|
1265
|
+
mi
|
|
1266
|
+
);
|
|
1267
|
+
s.material.depthTest = !1, s.layers.mask = Ht, this.add(s);
|
|
1268
|
+
}
|
|
1269
|
+
setVisibility(s) {
|
|
1270
|
+
this.visible = s;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
class fi extends Gt {
|
|
1274
|
+
constructor() {
|
|
1275
|
+
super();
|
|
1276
|
+
a(this, "_root");
|
|
1277
|
+
a(this, "_grid");
|
|
1278
|
+
this.background = new D(16777215), this._root = new di(), this.add(this._root), this._grid = new pi(), this.add(this._grid);
|
|
1279
|
+
}
|
|
1280
|
+
get root() {
|
|
1281
|
+
return this._root;
|
|
1282
|
+
}
|
|
1283
|
+
get grid() {
|
|
1284
|
+
return this._grid;
|
|
1285
|
+
}
|
|
1286
|
+
setBackground(t) {
|
|
1287
|
+
this.background = new D(t);
|
|
1288
|
+
}
|
|
1289
|
+
computeSceneBB() {
|
|
1290
|
+
return this.root.computeSceneBB();
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
const Qe = {
|
|
1294
|
+
canvas: void 0,
|
|
1295
|
+
antialias: !0,
|
|
1296
|
+
alpha: !0,
|
|
1297
|
+
powerPreference: "high-performance",
|
|
1298
|
+
precision: "highp",
|
|
1299
|
+
stencil: !1,
|
|
1300
|
+
depth: !0,
|
|
1301
|
+
logarithmicDepthBuffer: !1
|
|
1302
|
+
};
|
|
1303
|
+
class gi {
|
|
1304
|
+
constructor(s, t, e) {
|
|
1305
|
+
a(this, "_webglrenderer");
|
|
1306
|
+
a(this, "_settings");
|
|
1307
|
+
this._scene = s, this._camera = t, this._settings = {
|
|
1308
|
+
...Qe,
|
|
1309
|
+
...e ?? {}
|
|
1310
|
+
}, this._webglrenderer = new Ue({
|
|
1311
|
+
canvas: this._settings.canvas,
|
|
1312
|
+
antialias: this._settings.antialias,
|
|
1313
|
+
alpha: this._settings.alpha,
|
|
1314
|
+
powerPreference: this._settings.powerPreference,
|
|
1315
|
+
precision: this._settings.precision,
|
|
1316
|
+
stencil: this._settings.stencil,
|
|
1317
|
+
depth: this._settings.depth,
|
|
1318
|
+
logarithmicDepthBuffer: this._settings.logarithmicDepthBuffer
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
get webglrenderer() {
|
|
1322
|
+
return this._webglrenderer;
|
|
1323
|
+
}
|
|
1324
|
+
setCanvas(s) {
|
|
1325
|
+
this._webglrenderer.dispose(), this._settings.canvas = s, this._webglrenderer = new Ue(this._settings);
|
|
1326
|
+
}
|
|
1327
|
+
render() {
|
|
1328
|
+
this._webglrenderer.render(this._scene, this._camera);
|
|
1329
|
+
}
|
|
1330
|
+
onResize(s, t) {
|
|
1331
|
+
this._webglrenderer.setSize(s, t, !1);
|
|
1332
|
+
}
|
|
1333
|
+
dispose() {
|
|
1334
|
+
this._webglrenderer.dispose();
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
class _i {
|
|
1338
|
+
constructor() {
|
|
1339
|
+
a(this, "_renderer", null);
|
|
1340
|
+
a(this, "_lastTime", 0);
|
|
1341
|
+
a(this, "_isRunning", !1);
|
|
1342
|
+
a(this, "_tickers", []);
|
|
1343
|
+
}
|
|
1344
|
+
start() {
|
|
1345
|
+
this._isRunning || (this._isRunning = !0, this._lastTime = performance.now(), requestAnimationFrame(this._tick.bind(this)));
|
|
1346
|
+
}
|
|
1347
|
+
stop() {
|
|
1348
|
+
this._isRunning = !1;
|
|
1349
|
+
}
|
|
1350
|
+
setRenderer(s) {
|
|
1351
|
+
this._renderer = s;
|
|
1352
|
+
}
|
|
1353
|
+
addTicker(s) {
|
|
1354
|
+
this._tickers.find((t) => t.uuid === s.uuid) || this._tickers.push(s);
|
|
1355
|
+
}
|
|
1356
|
+
removeTicker(s) {
|
|
1357
|
+
const t = this._tickers.findIndex((e) => e.uuid === s.uuid);
|
|
1358
|
+
t !== -1 && this._tickers.splice(t, 1);
|
|
1359
|
+
}
|
|
1360
|
+
dispose() {
|
|
1361
|
+
this.stop(), this._tickers.forEach((s) => {
|
|
1362
|
+
var t;
|
|
1363
|
+
return (t = s.dispose) == null ? void 0 : t.call(s);
|
|
1364
|
+
}), this._tickers = [], this._isRunning = !1, this._lastTime = 0;
|
|
1365
|
+
}
|
|
1366
|
+
_tick(s) {
|
|
1367
|
+
var e;
|
|
1368
|
+
if (!this._isRunning) return;
|
|
1369
|
+
const t = (s - this._lastTime) / 1e3;
|
|
1370
|
+
this._lastTime = s, this._tickers.forEach((n) => n.tick(t)), (e = this._renderer) == null || e.render(), requestAnimationFrame(this._tick.bind(this));
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
class yi {
|
|
1374
|
+
constructor(s, t) {
|
|
1375
|
+
a(this, "_resizeObserver");
|
|
1376
|
+
a(this, "_width", 0);
|
|
1377
|
+
a(this, "_height", 0);
|
|
1378
|
+
this._resizeObserver = new ResizeObserver((e) => {
|
|
1379
|
+
for (const n of e) {
|
|
1380
|
+
const { width: o, height: c } = n.contentRect;
|
|
1381
|
+
o === this._width && c === this._height || (s.onResize(o, c), t.onResize(o, c), this._width = o, this._height = c);
|
|
1382
|
+
}
|
|
1383
|
+
}), this._observeCanvas(s.webglrenderer.domElement);
|
|
1384
|
+
}
|
|
1385
|
+
setCanvas(s) {
|
|
1386
|
+
this._resizeObserver.disconnect(), this._observeCanvas(s);
|
|
1387
|
+
}
|
|
1388
|
+
dispose() {
|
|
1389
|
+
this._resizeObserver.disconnect();
|
|
1390
|
+
}
|
|
1391
|
+
_observeCanvas(s) {
|
|
1392
|
+
if (s.parentElement)
|
|
1393
|
+
this._resizeObserver.observe(s.parentElement);
|
|
1394
|
+
else {
|
|
1395
|
+
const t = setInterval(() => {
|
|
1396
|
+
s.parentElement && (this._resizeObserver.observe(s.parentElement), clearInterval(t));
|
|
1397
|
+
}, 16);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
const et = {
|
|
1402
|
+
autoStart: !0,
|
|
1403
|
+
displayAxes: !1,
|
|
1404
|
+
...$t,
|
|
1405
|
+
...Qe
|
|
1406
|
+
};
|
|
1407
|
+
class bi {
|
|
1408
|
+
constructor(s) {
|
|
1409
|
+
a(this, "_renderer");
|
|
1410
|
+
a(this, "_scene");
|
|
1411
|
+
a(this, "_camera");
|
|
1412
|
+
a(this, "_resizeManager");
|
|
1413
|
+
a(this, "_clock");
|
|
1414
|
+
a(this, "_settings");
|
|
1415
|
+
this._settings = {
|
|
1416
|
+
...et,
|
|
1417
|
+
...s ?? {}
|
|
1418
|
+
}, this._scene = new fi(), this._camera = new Qt(this._settings), this._renderer = new gi(
|
|
1419
|
+
this._scene,
|
|
1420
|
+
this._camera,
|
|
1421
|
+
this._settings
|
|
1422
|
+
), this._resizeManager = new yi(
|
|
1423
|
+
this._renderer,
|
|
1424
|
+
this._camera
|
|
1425
|
+
), this._clock = new _i(), this._clock.setRenderer(this._renderer), this._settings.autoStart && this.start();
|
|
1426
|
+
}
|
|
1427
|
+
get scene() {
|
|
1428
|
+
return this._scene;
|
|
1429
|
+
}
|
|
1430
|
+
get camera() {
|
|
1431
|
+
return this._camera;
|
|
1432
|
+
}
|
|
1433
|
+
get renderer() {
|
|
1434
|
+
return this._renderer;
|
|
1435
|
+
}
|
|
1436
|
+
setCanvas(s) {
|
|
1437
|
+
this._renderer.setCanvas(s), this._resizeManager.setCanvas(s);
|
|
1438
|
+
}
|
|
1439
|
+
get clock() {
|
|
1440
|
+
return this._clock;
|
|
1441
|
+
}
|
|
1442
|
+
start() {
|
|
1443
|
+
this._clock.start();
|
|
1444
|
+
}
|
|
1445
|
+
stop() {
|
|
1446
|
+
this._clock.stop();
|
|
1447
|
+
}
|
|
1448
|
+
dispose() {
|
|
1449
|
+
this._clock.dispose(), this._resizeManager.dispose(), this._renderer.dispose();
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
function x(h, s) {
|
|
1453
|
+
const t = (h + "e").split("e");
|
|
1454
|
+
return +(t[0] + "e" + (+t[1] + (s || 0)));
|
|
1455
|
+
}
|
|
1456
|
+
function wi(h, s = 0) {
|
|
1457
|
+
const t = x(h, +s);
|
|
1458
|
+
return x(Math.ceil(t), -s);
|
|
1459
|
+
}
|
|
1460
|
+
function Ei(h, s = 0) {
|
|
1461
|
+
const t = x(h, +s);
|
|
1462
|
+
return x(Math.floor(t), -s);
|
|
1463
|
+
}
|
|
1464
|
+
function tt(h, s = 0) {
|
|
1465
|
+
if (h < 0) return -tt(-h, s);
|
|
1466
|
+
const t = x(h, +s);
|
|
1467
|
+
return x(Math.round(t), -s);
|
|
1468
|
+
}
|
|
1469
|
+
function Di(h, s, t) {
|
|
1470
|
+
return Math.atan2(
|
|
1471
|
+
h.clone().cross(s).dot(t),
|
|
1472
|
+
s.clone().dot(h)
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
function xi(h, s = 0) {
|
|
1476
|
+
const t = x(h, +s);
|
|
1477
|
+
return x(Math.round(t), -s).toFixed(s);
|
|
1478
|
+
}
|
|
1479
|
+
function Si(h, s = 0) {
|
|
1480
|
+
const t = x(h, +s);
|
|
1481
|
+
return x(Math.trunc(t), -s);
|
|
1482
|
+
}
|
|
1483
|
+
function Ti(h) {
|
|
1484
|
+
return (C.radToDeg(h) + 360) % 360;
|
|
1485
|
+
}
|
|
1486
|
+
function Li(h) {
|
|
1487
|
+
return C.degToRad(h);
|
|
1488
|
+
}
|
|
1489
|
+
const Bi = {
|
|
1490
|
+
ceilExp: wi,
|
|
1491
|
+
floorExp: Ei,
|
|
1492
|
+
roundExp: tt,
|
|
1493
|
+
toFixedExp: xi,
|
|
1494
|
+
truncateExp: Si,
|
|
1495
|
+
signedAngleTo: Di,
|
|
1496
|
+
radToDeg: Ti,
|
|
1497
|
+
degToRad: Li
|
|
1498
|
+
};
|
|
1499
|
+
window.DIVE = {
|
|
1500
|
+
instances: [],
|
|
1501
|
+
get instance() {
|
|
1502
|
+
return window.DIVE.instances[0];
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
const Pi = {
|
|
1506
|
+
...et,
|
|
1507
|
+
...se
|
|
1508
|
+
};
|
|
1509
|
+
class it {
|
|
1510
|
+
constructor(s) {
|
|
1511
|
+
// descriptive members
|
|
1512
|
+
a(this, "_settings");
|
|
1513
|
+
a(this, "_engine");
|
|
1514
|
+
a(this, "orbitController");
|
|
1515
|
+
a(this, "axisCamera");
|
|
1516
|
+
this._settings = {
|
|
1517
|
+
...Pi,
|
|
1518
|
+
...s ?? {}
|
|
1519
|
+
}, this._engine = new bi(s), this.orbitController = new ne(
|
|
1520
|
+
this._engine.camera,
|
|
1521
|
+
this._engine.renderer.webglrenderer.domElement,
|
|
1522
|
+
this._settings
|
|
1523
|
+
), this._engine.clock.addTicker(this.orbitController), this._settings.displayAxes ? (this.axisCamera = new ii(
|
|
1524
|
+
this._engine.renderer,
|
|
1525
|
+
this._engine.scene,
|
|
1526
|
+
this._engine.camera
|
|
1527
|
+
), this._engine.clock.addTicker(this.axisCamera)) : this.axisCamera = null, import("./chunks/package-BHjZWYD6.mjs").then((t) => {
|
|
1528
|
+
console.log(
|
|
1529
|
+
`DIVE ${t.default.version} initialized successfully!`
|
|
1530
|
+
), console.log(`
|
|
1531
|
+
@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
|
|
1532
|
+
@@@@+-:::::::---------------------==------------------------------=#@@@@
|
|
1533
|
+
@@%=::::.......::---------------------------------------------------------+@@
|
|
1534
|
+
@@+:::...........::-----------------------------------------------------------#@@
|
|
1535
|
+
@@=:::.........::::::-------------------------------------------------------------%@
|
|
1536
|
+
@%:::.......:::::::-----------------------------------------------------------------#@
|
|
1537
|
+
@*:::.....:::::-----------------------------------------------------------------------*@
|
|
1538
|
+
@%::::::.::::---------------------------------------------------------------------------@@
|
|
1539
|
+
@@-:::::::::-----------------------------------------------------------------------------=@
|
|
1540
|
+
@%::::::::--------------------------------------------------------------------------------%@
|
|
1541
|
+
@+::::::::--------------------------------=@@@@@%-----------------------------------------%@
|
|
1542
|
+
@=:::::::--------------------------------*@@ @@+---------------------------------------#@
|
|
1543
|
+
@+:::::::-------------------------------*@ @*--------------------------------------%@
|
|
1544
|
+
@#::::::::-----------------------------=@@ @@=-------------------------------------%@
|
|
1545
|
+
@@-::::::::----------------------------@@ @@------------------------------------=@
|
|
1546
|
+
@%:::::::::--------------------------*@ @*-----------------------------------@@
|
|
1547
|
+
@*:::::::::-------------------------@@ @@----------------------------------%@
|
|
1548
|
+
@#::::::::::----------------------%@ @%--------------------------------%@
|
|
1549
|
+
@#:::::::::::-------------------=@@ @@=------------------------------%@
|
|
1550
|
+
@@-::::::::::::----------------%@ @%----------------------------=@@
|
|
1551
|
+
@@#::::::::::::::------------*@ @*--------------------------#@@
|
|
1552
|
+
@@+::::::::::::::::--------@@ @@------------------------+@@
|
|
1553
|
+
@@*:::::::::::::::::----@@ @@---------------------+@@
|
|
1554
|
+
@@@-:::::::::::::::--#@ @#-----------------=%@@
|
|
1555
|
+
@@%-::::::::::::-%@ @%-------------=%@@
|
|
1556
|
+
@@@@+:::::::#@@ @@*-------*@@@@
|
|
1557
|
+
@@@@@@@ @@@@@@
|
|
1558
|
+
|
|
1559
|
+
`);
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
// static members
|
|
1563
|
+
static async QuickView(s, t) {
|
|
1564
|
+
const e = new it(t);
|
|
1565
|
+
window.DIVE.instances.push(e), e.engine.scene.background = new D(16777215), e.engine.scene.grid.setVisibility(!1), e.engine.scene.root.floor.setVisibility(!1), e.engine.scene.root.floor.setColor(16777215), e.engine.camera.position.set(0, 2, 2), e.orbitController.target.set(0, 0.5, 0);
|
|
1566
|
+
const n = new Je();
|
|
1567
|
+
n.name = "SceneLight", n.userData.id = C.generateUUID(), n.setEnabled(!0), n.visible = !0, n.setIntensity((t == null ? void 0 : t.lightIntensity) ?? 1), n.setColor(new D(16777215)), e.engine.scene.root.add(n);
|
|
1568
|
+
const o = new $e();
|
|
1569
|
+
o.name = "object", o.userData.id = C.generateUUID(), o.userData.uri = s, o.visible = !0, e.engine.scene.root.add(o), await o.setFromURL(s);
|
|
1570
|
+
const c = e.engine.scene.computeSceneBB(), l = e.orbitController.computeEncompassingView(c);
|
|
1571
|
+
return e.engine.camera.position.copy(l.position), e.orbitController.target.copy(l.target), e;
|
|
1572
|
+
}
|
|
1573
|
+
get engine() {
|
|
1574
|
+
return this._engine;
|
|
1575
|
+
}
|
|
1576
|
+
get canvas() {
|
|
1577
|
+
return this._engine.renderer.webglrenderer.domElement;
|
|
1578
|
+
}
|
|
1579
|
+
setCanvas(s) {
|
|
1580
|
+
this._engine.setCanvas(s), this._engine.clock.removeTicker(this.orbitController), this.orbitController.dispose(), this.orbitController = new ne(
|
|
1581
|
+
this._engine.camera,
|
|
1582
|
+
s,
|
|
1583
|
+
this._settings
|
|
1584
|
+
), this._engine.clock.addTicker(this.orbitController);
|
|
1585
|
+
}
|
|
1586
|
+
async Dispose() {
|
|
1587
|
+
return new Promise((s) => {
|
|
1588
|
+
this._engine.clock.removeTicker(this.orbitController), this.orbitController.dispose(), this.axisCamera && (this._engine.clock.removeTicker(this.axisCamera), this.axisCamera.Dispose()), s();
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
const We = (h, s) => {
|
|
1593
|
+
if (Object.keys(h).length === 0 && Object.keys(s).length === 0)
|
|
1594
|
+
return {};
|
|
1595
|
+
if (typeof h != "object" || typeof s != "object")
|
|
1596
|
+
return s;
|
|
1597
|
+
let t = {};
|
|
1598
|
+
return Object.keys(s).forEach((e) => {
|
|
1599
|
+
if (!Object.keys(h).includes(e)) {
|
|
1600
|
+
t = { ...t, [e]: s[e] };
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
if (Array.isArray(s[e])) {
|
|
1604
|
+
if (!Array.isArray(h[e])) {
|
|
1605
|
+
t = { ...t, [e]: s[e] };
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
const n = h[e], o = s[e];
|
|
1609
|
+
if (n.length === 0 && o.length === 0) {
|
|
1610
|
+
t = { ...t };
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
if (n.length !== o.length) {
|
|
1614
|
+
t = { ...t, [e]: s[e] };
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
const c = [];
|
|
1618
|
+
if (o.forEach((l, p) => {
|
|
1619
|
+
const f = We(
|
|
1620
|
+
n[p],
|
|
1621
|
+
o[p]
|
|
1622
|
+
);
|
|
1623
|
+
Object.keys(f).length && c.push(o[p]);
|
|
1624
|
+
}), Object.keys(c).length) {
|
|
1625
|
+
t = { ...t, [e]: c };
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
if (typeof s[e] == "object") {
|
|
1631
|
+
if (typeof h[e] != "object") {
|
|
1632
|
+
t = { ...t, [e]: s[e] };
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
const n = We(
|
|
1636
|
+
h[e],
|
|
1637
|
+
s[e]
|
|
1638
|
+
);
|
|
1639
|
+
if (Object.keys(n).length) {
|
|
1640
|
+
t = { ...t, [e]: n };
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
h[e] !== s[e] && (t = { ...t, [e]: s[e] });
|
|
1645
|
+
}), t;
|
|
1646
|
+
};
|
|
1647
|
+
export {
|
|
1648
|
+
it as DIVE,
|
|
1649
|
+
Pi as DIVEDefaultSettings,
|
|
1650
|
+
Bi as DIVEMath,
|
|
1651
|
+
Zi as ESystem,
|
|
1652
|
+
Xi as EWebXRUnsupportedReason,
|
|
1653
|
+
Gi as FILE_TYPES,
|
|
1654
|
+
ji as SUPPORTED_FILE_TYPES,
|
|
1655
|
+
ai as applyMixins,
|
|
1656
|
+
Fi as findInterface,
|
|
1657
|
+
ge as findSceneRecursive,
|
|
1658
|
+
Hi as getFileTypeFromUri,
|
|
1659
|
+
w as getModule,
|
|
1660
|
+
We as getObjectDelta,
|
|
1661
|
+
Yi as implementsInterface,
|
|
1662
|
+
Wi as isFileTypeSupported
|
|
1663
|
+
};
|