@shopware-ag/dive 3.1.0 → 4.0.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 +31 -5
- package/build/chunks/{AssetCache-xpY_N7Yp.cjs → AssetCache-CUVFS7wk.cjs} +1 -1
- package/build/chunks/{AssetCache-C3YXhbaX.mjs → AssetCache-DnAAa719.mjs} +1 -1
- package/build/chunks/AssetExporter-CD2iuQce.mjs +108 -0
- package/build/chunks/AssetExporter-CoL-QXkB.cjs +1 -0
- package/build/chunks/{AssetLoader-MfH5d_Rr.mjs → AssetLoader-Bkp3fWZz.mjs} +9 -9
- package/build/chunks/{AssetLoader-CRxLq0AL.cjs → AssetLoader-DnVvCd41.cjs} +2 -2
- package/build/chunks/FileTypes-B-MjfMGd.cjs +29 -0
- package/build/chunks/FileTypes-D3Dxr2dj.mjs +2294 -0
- package/build/chunks/ModelComponent-Cmu0EX0r.cjs +1 -0
- package/build/chunks/ModelComponent-WA0kLOEY.mjs +87 -0
- package/build/chunks/OrbitController-CAJIiZeE.cjs +1 -0
- package/build/chunks/OrbitController-DxCbrQVB.mjs +612 -0
- package/build/chunks/SpriteTextComponent-BpoKLOjA.cjs +1 -0
- package/build/chunks/SpriteTextComponent-DIZFqao0.mjs +83 -0
- package/build/chunks/collectAnimations-BgYCN1le.mjs +35 -0
- package/build/chunks/collectAnimations-C3HfZHte.cjs +1 -0
- package/build/chunks/contributesToBounds-C1mva__U.cjs +1 -0
- package/build/chunks/contributesToBounds-DYmHYES4.mjs +14 -0
- package/build/chunks/detachTransformControls-B4iRF1bw.mjs +209 -0
- package/build/chunks/detachTransformControls-CZ2cd5hx.cjs +1 -0
- package/build/chunks/{isFileTypeSupported-BBU39V4u.cjs → isFileExtensionSupported-B1q2eWs7.cjs} +1 -1
- package/build/chunks/{isFileTypeSupported-9h8lrIuG.mjs → isFileExtensionSupported-BqOqU3-h.mjs} +1 -1
- package/build/chunks/isVisibleInHierarchy-D9JcLqR5.cjs +1 -0
- package/build/chunks/isVisibleInHierarchy-KzVGvDEw.mjs +21 -0
- package/build/components/boundingbox/BoundingBoxComponent.d.ts +100 -0
- package/build/components/boundingbox/index.d.ts +1 -0
- package/build/components/camera/CameraComponent.d.ts +75 -0
- package/build/components/camera/index.d.ts +2 -0
- package/build/components/camera/perspective/PerspectiveCameraComponent.d.ts +39 -0
- package/build/components/grid/GridComponent.d.ts +50 -0
- package/build/components/index.d.ts +6 -10
- package/build/components/light/LightComponent.d.ts +65 -0
- package/build/components/light/ambient/AmbientLightComponent.d.ts +10 -0
- package/build/components/light/directional/DirectionalLightComponent.d.ts +23 -0
- package/build/components/light/hemi/HemisphereLightComponent.d.ts +21 -0
- package/build/components/light/index.d.ts +5 -3
- package/build/components/light/point/PointLightComponent.d.ts +26 -0
- package/build/components/line/MultiLineComponent.d.ts +133 -0
- package/build/components/line/index.d.ts +1 -0
- package/build/components/mesh/MeshComponent.d.ts +74 -0
- package/build/components/mesh/floor/FloorComponent.d.ts +36 -0
- package/build/components/mesh/index.d.ts +4 -0
- package/build/components/mesh/model/ModelComponent.d.ts +67 -0
- package/build/components/mesh/primitive/PrimitiveComponent.d.ts +43 -0
- package/build/components/spritetext/SpriteTextComponent.d.ts +58 -0
- package/build/constants/VisibilityLayerMask.d.ts +23 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +252 -773
- package/build/engine/Dive.d.ts +11 -13
- package/build/engine/boundingbox/BoundingBox.d.ts +76 -0
- package/build/engine/component/Component.d.ts +236 -0
- package/build/engine/environment/Environment.d.ts +0 -18
- package/build/engine/index.d.ts +4 -1
- package/build/engine/node/Node.d.ts +189 -0
- package/build/engine/promise/abortable/AbortablePromise.d.ts +8 -0
- package/build/engine/renderer/Renderer.d.ts +43 -7
- package/build/engine/scene/Scene.d.ts +88 -4
- package/build/engine/scene/root/Root.d.ts +29 -0
- package/build/engine/scene/xrroot/XRRoot.d.ts +1 -1
- package/build/engine/view/View.d.ts +15 -4
- package/build/helpers/collectAnimations/collectAnimations.d.ts +23 -0
- package/build/helpers/computeProductBounds/computeProductBounds.d.ts +18 -0
- package/build/helpers/contributesToBounds/contributesToBounds.d.ts +17 -0
- package/build/helpers/detachTransformControls/detachTransformControls.d.ts +15 -0
- package/build/helpers/disposeComponents/disposeComponents.d.ts +20 -0
- package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +7 -3
- package/build/helpers/implementsInterface/implementsInterface.d.ts +11 -0
- package/build/helpers/index.d.ts +6 -1
- package/build/helpers/isVisibleInHierarchy/isVisibleInHierarchy.d.ts +12 -0
- package/build/index.d.ts +0 -1
- package/build/plugins/animation/index.mjs +3 -2
- package/build/plugins/animation/src/system/AnimationSystem.d.ts +3 -2
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +2 -2
- package/build/plugins/ar/src/webxr/WebXR.d.ts +7 -0
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetexporter/src/AssetExporter.d.ts +12 -0
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +32 -30
- package/build/plugins/mediacreator/src/MediaCreator.d.ts +1 -2
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.d.ts +1 -0
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orbitcontroller/src/OrbitController.d.ts +39 -6
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +39 -31
- package/build/plugins/orientationdisplay/src/OrientationDisplay.d.ts +3 -3
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +68 -45
- package/build/plugins/quickview/src/QuickView.d.ts +40 -13
- package/build/plugins/quickview/types/index.d.ts +0 -18
- package/build/plugins/state/index.cjs +1 -27
- package/build/plugins/state/index.mjs +1983 -4262
- package/build/plugins/state/src/EngineGateway.d.ts +98 -0
- package/build/plugins/state/src/EntityRegistry.d.ts +51 -0
- package/build/plugins/state/src/State.d.ts +20 -9
- package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
- package/build/plugins/state/src/actions/camera/movecamera.d.ts +2 -2
- package/build/plugins/state/src/actions/media/generatemedia.d.ts +1 -1
- package/build/plugins/state/src/actions/object/addobject.d.ts +2 -3
- package/build/plugins/state/src/actions/object/deleteobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/deselectobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/dropit.d.ts +2 -2
- package/build/plugins/state/src/actions/object/getallobjects.d.ts +2 -3
- package/build/plugins/state/src/actions/object/getobjects.d.ts +3 -4
- package/build/plugins/state/src/actions/object/index.d.ts +0 -1
- package/build/plugins/state/src/actions/object/modelloaded.d.ts +2 -2
- package/build/plugins/state/src/actions/object/selectobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/setparent.d.ts +3 -4
- package/build/plugins/state/src/actions/object/updateobject.d.ts +3 -4
- package/build/plugins/state/src/actions/renderer/startrender.d.ts +1 -1
- package/build/plugins/state/src/actions/scene/exportscene.d.ts +2 -2
- package/build/plugins/state/src/actions/scene/index.d.ts +0 -1
- package/build/plugins/state/src/actions/scene/setbackground.d.ts +2 -2
- package/build/plugins/state/src/actions/scene/updatescene.d.ts +2 -2
- package/build/plugins/state/src/actions/state/getstate.d.ts +1 -1
- package/build/plugins/state/src/actions/state/setstate.d.ts +1 -1
- package/build/plugins/state/src/helpers/copyVectors/copyVectors.d.ts +17 -0
- package/build/plugins/state/src/helpers/updateParentLink/updateParentLink.d.ts +29 -0
- package/build/plugins/state/src/helpers/watchEntity/watchEntity.d.ts +30 -0
- package/build/plugins/state/types/ActionTypes.d.ts +18 -3
- package/build/plugins/state/types/RegisteredEntity.d.ts +27 -0
- package/build/plugins/state/types/StateData.d.ts +1 -1
- package/build/plugins/state/types/index.d.ts +2 -1
- package/build/{types → plugins/state/types}/schema/GroupSchema.d.ts +1 -1
- package/build/{types → plugins/state/types}/schema/ModelSchema.d.ts +7 -4
- package/build/{types → plugins/state/types}/schema/PrimitiveSchema.d.ts +4 -5
- package/build/{types → plugins/state/types}/schema/index.d.ts +0 -3
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +193 -140
- package/build/plugins/toolbox/src/PointerContext.d.ts +7 -0
- package/build/plugins/toolbox/src/SelectionState.d.ts +21 -0
- package/build/plugins/toolbox/src/Toolbox.d.ts +9 -2
- package/build/{components → plugins/toolbox/src}/gizmo/Gizmo.d.ts +16 -2
- package/build/{components → plugins/toolbox/src}/gizmo/handles/AxisHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/handles/RadialHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/handles/ScaleHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/rotate/RotateGizmo.d.ts +2 -2
- package/build/{components → plugins/toolbox/src}/gizmo/scale/ScaleGizmo.d.ts +3 -3
- package/build/{components → plugins/toolbox/src}/gizmo/translate/TranslateGizmo.d.ts +2 -2
- package/build/types/components/DIVESceneObject.d.ts +13 -6
- package/build/types/components/index.d.ts +0 -1
- package/build/types/events/DIVEComponentEventMap.d.ts +14 -0
- package/build/types/events/DIVEEntityEventMap.d.ts +47 -0
- package/build/types/events/index.d.ts +2 -0
- package/build/types/{schema/GeometrySchema.d.ts → geometry/DIVEGeometry.d.ts} +4 -4
- package/build/types/{schema/GeometryTypeSchema.d.ts → geometry/DIVEGeometryType.d.ts} +1 -1
- package/build/types/geometry/index.d.ts +2 -0
- package/build/types/index.d.ts +3 -1
- package/build/types/{schema/MaterialSchema.d.ts → material/DIVEMaterial.d.ts} +1 -1
- package/build/types/material/index.d.ts +1 -0
- package/package.json +6 -5
- package/build/chunks/AssetExporter-C5MScs9S.mjs +0 -70
- package/build/chunks/AssetExporter-Cdxb04b3.cjs +0 -1
- package/build/chunks/CameraSchema-cgY5WBGW.mjs +0 -10
- package/build/chunks/CameraSchema-twxH-72N.cjs +0 -1
- package/build/chunks/FileTypes-Cgyf8ocm.cjs +0 -29
- package/build/chunks/FileTypes-DiYB3WBp.mjs +0 -2166
- package/build/chunks/PerspectiveCamera-B5TvUzTa.mjs +0 -39
- package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +0 -1
- package/build/chunks/SpriteText-2lCRglsw.cjs +0 -1
- package/build/chunks/SpriteText-C_CQPvUn.mjs +0 -50
- package/build/chunks/findInterface-C6mrvf_t.cjs +0 -1
- package/build/chunks/findInterface-DbJ5qzbc.mjs +0 -11
- package/build/components/boundingbox/BoundingBox.d.ts +0 -140
- package/build/components/floor/Floor.d.ts +0 -14
- package/build/components/grid/Grid.d.ts +0 -23
- package/build/components/group/Group.d.ts +0 -28
- package/build/components/light/AmbientLight.d.ts +0 -19
- package/build/components/light/PointLight.d.ts +0 -29
- package/build/components/light/SceneLight.d.ts +0 -20
- package/build/components/model/Model.d.ts +0 -26
- package/build/components/node/Node.d.ts +0 -24
- package/build/components/primitive/Primitive.d.ts +0 -27
- package/build/components/root/Root.d.ts +0 -34
- package/build/components/spritetext/SpriteText.d.ts +0 -27
- package/build/engine/camera/PerspectiveCamera.d.ts +0 -24
- package/build/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +0 -9
- package/build/plugins/quickview/src/state/QuickViewState.d.ts +0 -4
- package/build/plugins/quickview/src/uri/QuickViewUri.d.ts +0 -3
- package/build/plugins/state/src/actions/object/placeonfloor.d.ts +0 -12
- package/build/plugins/state/src/actions/scene/getallscenedata.d.ts +0 -12
- package/build/plugins/state/types/StateSceneData.d.ts +0 -5
- package/build/types/components/DIVELight.d.ts +0 -4
- /package/build/{types → plugins/state/types}/schema/BaseEntitySchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/CameraSchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/EntitySchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/EntityTypeSchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/LightSchema.d.ts +0 -0
- /package/build/{components → plugins/toolbox/src}/gizmo/plane/GizmoPlane.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=(r,s,t)=>s in r?m(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var a=(r,s,t)=>u(r,typeof s!="symbol"?s+"":s,t);const l=require("./contributesToBounds-C1mva__U.cjs"),d=require("./FileTypes-B-MjfMGd.cjs");class _ extends d.MeshComponent{constructor(){super();a(this,"isModelComponent",!0);a(this,"animations",[]);a(this,"_url",null);a(this,"_assetLoader",null);this.name="ModelComponent"}async _getAssetLoader(){return this._assetLoader||(this._assetLoader=new(await Promise.resolve().then(()=>require("../plugins/assetloader/index.cjs"))).AssetLoader),this._assetLoader}async setFromURL(t){const o=await(await this._getAssetLoader()).load(t);return this.setFromGLTF(o),this._url=t,this.dispatchEvent({type:"object-load"}),this}setFromGLTF(t){const i=[...this.contributions];this.withdraw(...i),i.forEach(e=>e.traverse(h=>{var n;(n=h.geometry)==null||n.dispose()})),this._mesh=null;const o=this.isAttached?this.owner.layers.mask:l.PRODUCT_LAYER_MASK;return t.traverse(e=>{e.castShadow=!0,e.receiveShadow=!0,e.layers.mask=o,!this._mesh&&"isMesh"in e&&(this._mesh=e,this._materialIsOwn?e.material=this._material:Array.isArray(e.material)||(this._material=e.material))}),this.animations=t.animations,this.contribute(...t.children),this}get url(){return this._url}copy(t){return super.copy(t),this._url=t.url,this.animations=t.animations,this}}exports.ModelComponent=_;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var l = (a, e, t) => e in a ? m(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var r = (a, e, t) => l(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { P as u } from "./contributesToBounds-DYmHYES4.mjs";
|
|
5
|
+
import { M as _ } from "./FileTypes-D3Dxr2dj.mjs";
|
|
6
|
+
class c extends _ {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
r(this, "isModelComponent", !0);
|
|
10
|
+
/**
|
|
11
|
+
* The clips the asset came with.
|
|
12
|
+
*
|
|
13
|
+
* Its own field, not `Object3D.animations`: they belong to the asset, and the
|
|
14
|
+
* mixer takes a root and its clips separately, so nothing needs them to sit
|
|
15
|
+
* on a graph object.
|
|
16
|
+
*/
|
|
17
|
+
r(this, "animations", []);
|
|
18
|
+
/** What {@link setFromURL} last loaded, so a clone can load it again. */
|
|
19
|
+
r(this, "_url", null);
|
|
20
|
+
r(this, "_assetLoader", null);
|
|
21
|
+
this.name = "ModelComponent";
|
|
22
|
+
}
|
|
23
|
+
async _getAssetLoader() {
|
|
24
|
+
return this._assetLoader || (this._assetLoader = new (await import("../plugins/assetloader/index.mjs")).AssetLoader()), this._assetLoader;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Loads an asset and takes its content as this component's geometry.
|
|
28
|
+
*
|
|
29
|
+
* Reports the load on itself. Whoever wants to hear about an entity being
|
|
30
|
+
* loaded listens to the component that loads it -- the node has nothing to
|
|
31
|
+
* do with fetching, and a component with no owner yet had nowhere to report
|
|
32
|
+
* before, which silently dropped the event.
|
|
33
|
+
*
|
|
34
|
+
* @param url - The asset to load.
|
|
35
|
+
*/
|
|
36
|
+
async setFromURL(t) {
|
|
37
|
+
const o = await (await this._getAssetLoader()).load(t);
|
|
38
|
+
return this.setFromGLTF(o), this._url = t, this.dispatchEvent({ type: "object-load" }), this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Replaces the content with a loaded glTF hierarchy.
|
|
42
|
+
*
|
|
43
|
+
* @param gltf - What the loader returned: a glTF *scene*, whose children are
|
|
44
|
+
* the file's root nodes.
|
|
45
|
+
*/
|
|
46
|
+
setFromGLTF(t) {
|
|
47
|
+
const i = [...this.contributions];
|
|
48
|
+
this.withdraw(...i), i.forEach(
|
|
49
|
+
(s) => s.traverse((h) => {
|
|
50
|
+
var n;
|
|
51
|
+
(n = h.geometry) == null || n.dispose();
|
|
52
|
+
})
|
|
53
|
+
), this._mesh = null;
|
|
54
|
+
const o = this.isAttached ? this.owner.layers.mask : u;
|
|
55
|
+
return t.traverse((s) => {
|
|
56
|
+
s.castShadow = !0, s.receiveShadow = !0, s.layers.mask = o, !this._mesh && "isMesh" in s && (this._mesh = s, this._materialIsOwn ? s.material = this._material : Array.isArray(s.material) || (this._material = s.material));
|
|
57
|
+
}), this.animations = t.animations, this.contribute(...t.children), this;
|
|
58
|
+
}
|
|
59
|
+
/** The asset {@link setFromURL} last loaded, if any. */
|
|
60
|
+
get url() {
|
|
61
|
+
return this._url;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Carries over what identifies the content, not the content itself.
|
|
65
|
+
*
|
|
66
|
+
* The one component whose state a copy cannot reproduce on its own: a load is
|
|
67
|
+
* asynchronous, and `copy` is not. So the clone comes back with the same
|
|
68
|
+
* {@link url} and clips but no geometry, and the caller finishes it:
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const clone = source.clone();
|
|
72
|
+
* if (clone.url) await clone.setFromURL(clone.url);
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* Spelled out because the alternative is worse: cloning the loaded hierarchy
|
|
76
|
+
* would share every geometry and material with the source, and either
|
|
77
|
+
* component's `dispose` would then free what the other still draws.
|
|
78
|
+
*
|
|
79
|
+
* @param source - The component to copy from.
|
|
80
|
+
*/
|
|
81
|
+
copy(t) {
|
|
82
|
+
return super.copy(t), this._url = t.url, this.animations = t.animations, this;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
c as M
|
|
87
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var D=Object.defineProperty;var E=(r,h,t)=>h in r?D(r,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[h]=t;var s=(r,h,t)=>E(r,typeof h!="symbol"?h+"":h,t);const i=require("three/webgpu"),S=require("./FileTypes-B-MjfMGd.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const w={enableDamping:!0,dampingFactor:.05,enabled:!0,target:new i.Vector3,minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,enableZoom:!0,zoomSpeed:1,enableRotate:!0,rotateSpeed:1,enablePan:!0,panSpeed:1,screenSpacePanning:!0,keyPanSpeed:7,autoRotate:!1,autoRotateSpeed:2,keys:{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},mouseButtons:{LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN},touches:{ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN}},c=class c extends i.EventDispatcher{constructor(t,e,a){super();s(this,"object");s(this,"domElements");s(this,"enabled",!0);s(this,"target",new i.Vector3);s(this,"minDistance",0);s(this,"maxDistance",1/0);s(this,"minZoom",0);s(this,"maxZoom",1/0);s(this,"minPolarAngle",0);s(this,"maxPolarAngle",Math.PI);s(this,"minAzimuthAngle",-1/0);s(this,"maxAzimuthAngle",1/0);s(this,"enableDamping",!0);s(this,"dampingFactor",.05);s(this,"enableZoom",!0);s(this,"zoomSpeed",1);s(this,"enableRotate",!0);s(this,"rotateSpeed",1);s(this,"enablePan",!0);s(this,"panSpeed",1);s(this,"screenSpacePanning",!0);s(this,"keyPanSpeed",7);s(this,"autoRotate",!1);s(this,"autoRotateSpeed",2);s(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"});s(this,"mouseButtons",{LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN});s(this,"touches",{ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN});s(this,"target0");s(this,"position0");s(this,"zoom0");s(this,"uuid",i.MathUtils.generateUUID());s(this,"state",-1);s(this,"EPS",1e-6);s(this,"spherical",new i.Spherical);s(this,"sphericalDelta",new i.Spherical);s(this,"scale",1);s(this,"panOffset",new i.Vector3);s(this,"zoomChanged",!1);s(this,"rotateStart",new i.Vector2);s(this,"rotateEnd",new i.Vector2);s(this,"rotateDelta",new i.Vector2);s(this,"panStart",new i.Vector2);s(this,"panEnd",new i.Vector2);s(this,"panDelta",new i.Vector2);s(this,"dollyStart",new i.Vector2);s(this,"dollyEnd",new i.Vector2);s(this,"dollyDelta",new i.Vector2);s(this,"pointers",[]);s(this,"pointerPositions",{});s(this,"offset",new i.Vector3);s(this,"quat");s(this,"quatInverse");s(this,"lastPosition",new i.Vector3);s(this,"lastQuaternion",new i.Quaternion);s(this,"lastTarget",new i.Vector3);s(this,"panLeft",(()=>{const t=new i.Vector3;return(e,a)=>{t.setFromMatrixColumn(a,0),t.multiplyScalar(-e),this.panOffset.add(t)}})());s(this,"panUp",(()=>{const t=new i.Vector3;return(e,a)=>{this.screenSpacePanning===!0?t.setFromMatrixColumn(a,1):(t.setFromMatrixColumn(a,0),t.crossVectors(this.object.camera.up,t)),t.multiplyScalar(e),this.panOffset.add(t)}})());s(this,"onMouseDown",t=>{let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case i.MOUSE.DOLLY:if(this.enableZoom===!1)return;this.handleMouseDownDolly(t),this.state=1;break;case i.MOUSE.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case i.MOUSE.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});s(this,"onMouseMove",t=>{if(this.enabled!==!1)switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}});s(this,"onMouseWheel",t=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1||(t.preventDefault(),this.dispatchEvent({type:"start"}),this.handleMouseWheel(t),this.dispatchEvent({type:"end"}))});s(this,"onKeyDown",t=>{this.enabled===!1||this.enablePan===!1||this.handleKeyDown(t)});s(this,"onTouchStart",t=>{switch(this.trackPointer(t),this.pointers.length){case 1:switch(this.touches.ONE){case i.TOUCH.ROTATE:if(this.enableRotate===!1)return;this.handleTouchStartRotate(t),this.state=3;break;case i.TOUCH.PAN:if(this.enablePan===!1)return;this.handleTouchStartPan(t),this.state=4;break;default:this.state=-1}break;case 2:switch(this.touches.TWO){case i.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(t),this.state=5;break;case i.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=-1}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});s(this,"onTouchMove",t=>{switch(this.trackPointer(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}});s(this,"onPointerDown",t=>{if(this.enabled!==!1){if(this.pointers.length===0){const e=t.currentTarget;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp)}this.isTrackingPointer(t)||(this.addPointer(t),t.pointerType==="touch"?this.onTouchStart(t):this.onMouseDown(t))}});s(this,"onPointerMove",t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onTouchMove(t):this.onMouseMove(t))});s(this,"onPointerUp",t=>{if(this.removePointer(t),this.pointers.length===0){const e=t.currentTarget;e.releasePointerCapture(t.pointerId),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent({type:"end"}),this.state=-1}});s(this,"onPointerCancel",t=>{this.removePointer(t)});s(this,"onContextMenu",t=>{this.enabled!==!1&&t.preventDefault()});if(this.object=t,!t.isAttached)throw new Error("OrbitController: the camera component must be attached to a node, because that is what gets moved.");this.domElements=Array.isArray(e)?e:[e],Object.assign(this,a),this.target0=this.target.clone(),this.position0=this.object.owner.position.clone(),this.zoom0=this._camera.zoom,this.quat=new i.Quaternion().setFromUnitVectors(this.object.camera.up,new i.Vector3(0,1,0)),this.quatInverse=this.quat.clone().invert(),this.domElements.forEach(o=>this.addEventListeners(o)),this.update()}get _camera(){return this.object.camera}get domElement(){return this.domElements[0]}tick(){this.enabled&&this.update()}getPolarAngle(){return this.spherical.phi}getAzimuthalAngle(){return this.spherical.theta}getDistance(){return this.object.owner.position.distanceTo(this.target)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.owner.position),this.zoom0=this._camera.zoom}reset(){this.target.copy(this.target0),this.object.owner.position.copy(this.position0),this._camera.zoom=this.zoom0,this._camera.updateProjectionMatrix(),this.dispatchEvent({type:"change"}),this.update(),this.state=-1}update(){return this.offset.copy(this.object.owner.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(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),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.owner.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.owner.position)>this.EPS||8*(1-this.lastQuaternion.dot(this.object.owner.quaternion))>this.EPS||this.lastTarget.distanceToSquared(this.target)>this.EPS?(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.object.owner.position),this.lastQuaternion.copy(this.object.owner.quaternion),this.lastTarget.copy(this.target),this.zoomChanged=!1,!0):!1}dispose(){this.domElements.forEach(t=>this.removeEventListeners(t)),this.dispatchEvent({type:"dispose"})}addDomElements(...t){t.forEach(e=>{this.domElements.includes(e)||(this.domElements.push(e),this.addEventListeners(e))})}removeDomElements(...t){t.forEach(e=>{const a=this.domElements.indexOf(e);a>-1&&(this.removeEventListeners(e),this.domElements.splice(a,1))})}setDomElements(...t){this.removeDomElements(...this.domElements),this.domElements=[],this.addDomElements(...t)}computeEncompassingView(t,e=0){const a=t.center,o=t.radius,n=this._camera,l=n.fov*(Math.PI/180),m=n.aspect,d=l/2,f=Math.atan(Math.tan(d)*m),g=o/Math.sin(d),y=o/Math.sin(f),b=Math.max(g,y)*(1+e),u=this.object.owner.position.clone().sub(this.target).normalize(),P=u.length()>.001?u:new i.Vector3(0,0,1);return{position:a.clone().add(P.multiplyScalar(b)),target:a}}focusObject(t,e=0){const a=this.computeEncompassingView(new S.BoundingBox().enclose(t).sphere,e);this.object.owner.position.copy(a.position),this.target.copy(a.target),this.update()}zoomIn(t){this.dollyIn(Math.pow(.95,t??c.DEFAULT_ZOOM_FACTOR)),this.update()}zoomOut(t){this.dollyOut(Math.pow(.95,t??c.DEFAULT_ZOOM_FACTOR)),this.update()}getState(){return{target:this.target.clone(),azimuthalAngle:this.getAzimuthalAngle(),polarAngle:this.getPolarAngle(),distance:this.getDistance(),position:this.object.owner.position.clone(),quaternion:this.object.owner.quaternion.clone()}}setState(t){this.target.copy(t.target),this.object.owner.position.copy(t.position),this.object.owner.quaternion.copy(t.quaternion),this.update()}addEventListeners(t){t.style.touchAction="none",t.addEventListener("contextmenu",this.onContextMenu),t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointercancel",this.onPointerCancel),t.addEventListener("wheel",this.onMouseWheel,{passive:!1}),t.addEventListener("keydown",this.onKeyDown)}removeEventListeners(t){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)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}pan(t,e,a){const o=new i.Vector3;if("isPerspectiveCamera"in this._camera){const n=this.object.owner.position;o.copy(n).sub(this.target);let l=o.length();l*=Math.tan(this._camera.fov/2*Math.PI/180),this.panLeft(2*t*l/a.clientHeight,this.object.owner.matrix),this.panUp(2*e*l/a.clientHeight,this.object.owner.matrix)}else"isOrthographicCamera"in this._camera?(this.panLeft(t*(this._camera.right-this._camera.left)/this._camera.zoom/a.clientWidth,this.object.owner.matrix),this.panUp(e*(this._camera.top-this._camera.bottom)/this._camera.zoom/a.clientHeight,this.object.owner.matrix)):(console.warn("WARNING: OrbitController encountered an unknown camera type - pan disabled."),this.enablePan=!1)}dollyIn(t){"isPerspectiveCamera"in this._camera||"isOrthographicCamera"in this._camera?this.scale*=t:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyOut(t){"isPerspectiveCamera"in this._camera||"isOrthographicCamera"in this._camera?this.scale/=t:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);const e=t.currentTarget;this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){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()}handleMouseMovePan(t){const e=t.currentTarget;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()}handleMouseWheel(t){t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update()}handleKeyDown(t){let e=!1;const a=t.currentTarget;switch(t.code){case this.keys.UP:this.pan(0,this.keyPanSpeed,a),e=!0;break;case this.keys.BOTTOM:this.pan(0,-this.keyPanSpeed,a),e=!0;break;case this.keys.LEFT:this.pan(this.keyPanSpeed,0,a),e=!0;break;case this.keys.RIGHT:this.pan(-this.keyPanSpeed,0,a),e=!0;break}e&&(t.preventDefault(),this.update())}handleTouchStartRotate(t){if(this.pointers.length===1)this.rotateStart.set(t.pageX,t.pageY);else{const e=this.getSecondPointer(t),a=.5*(t.pageX+e.pageX),o=.5*(t.pageY+e.pageY);this.rotateStart.set(a,o)}}handleTouchStartPan(t){if(this.pointers.length===1)this.panStart.set(t.pageX,t.pageY);else{const e=this.getSecondPointer(t),a=.5*(t.pageX+e.pageX),o=.5*(t.pageY+e.pageY);this.panStart.set(a,o)}}handleTouchStartDolly(t){const e=this.getSecondPointer(t),a=t.pageX-e.pageX,o=t.pageY-e.pageY,n=Math.sqrt(a*a+o*o);this.dollyStart.set(0,n)}handleTouchStartDollyPan(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enablePan&&this.handleTouchStartPan(t)}handleTouchStartDollyRotate(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enableRotate&&this.handleTouchStartRotate(t)}handleTouchMoveRotate(t){if(this.pointers.length===1)this.rotateEnd.set(t.pageX,t.pageY);else{const a=this.getSecondPointer(t),o=.5*(t.pageX+a.pageX),n=.5*(t.pageY+a.pageY);this.rotateEnd.set(o,n)}const e=t.currentTarget;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed),this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(this.pointers.length===1)this.panEnd.set(t.pageX,t.pageY);else{const a=this.getSecondPointer(t),o=.5*(t.pageX+a.pageX),n=.5*(t.pageY+a.pageY);this.panEnd.set(o,n)}const e=t.currentTarget;this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,e),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){const e=this.getSecondPointer(t),a=t.pageX-e.pageX,o=t.pageY-e.pageY,n=Math.sqrt(a*a+o*o);this.dollyEnd.set(0,n),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}addPointer(t){this.pointers.push(t)}removePointer(t){delete this.pointerPositions[t.pointerId];for(let e=0;e<this.pointers.length;e++)if(this.pointers[e].pointerId==t.pointerId){this.pointers.splice(e,1);return}}trackPointer(t){let e=this.pointerPositions[t.pointerId];e===void 0&&(e=new i.Vector2,this.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}getSecondPointer(t){return this.pointers[0].pointerId===t.pointerId?this.pointers[1]:this.pointers[0]}isTrackingPointer(t){return this.pointers.some(e=>e.pointerId===t.pointerId)}};s(c,"DEFAULT_ZOOM_FACTOR",1);let p=c;exports.OrbitController=p;exports.OrbitControllerDefaultSettings=w;
|