@soonspacejs/plugin-drag-controls 2.13.10 → 2.13.11
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/dist/index.d.ts +16 -16
- package/dist/index.esm.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import SoonSpace from 'soonspacejs';
|
|
2
|
-
import { DragControls } from 'three/examples/jsm/controls/DragControls.js';
|
|
3
|
-
import { Object3D } from 'three';
|
|
4
|
-
export interface StartOptions {
|
|
5
|
-
dragStart?: (object: Object3D) => void;
|
|
6
|
-
drag?: (object: Object3D) => void;
|
|
7
|
-
dragEnd?: (object: Object3D) => void;
|
|
8
|
-
}
|
|
9
|
-
declare class DragControlsPlugin {
|
|
10
|
-
controls: DragControls | null;
|
|
11
|
-
viewport: SoonSpace['viewport'];
|
|
12
|
-
constructor(ssp: SoonSpace);
|
|
13
|
-
start(objects: Object3D[], options?: StartOptions): void;
|
|
14
|
-
stop(): void;
|
|
15
|
-
}
|
|
16
|
-
export default DragControlsPlugin;
|
|
1
|
+
import SoonSpace from 'soonspacejs';
|
|
2
|
+
import { DragControls } from 'three/examples/jsm/controls/DragControls.js';
|
|
3
|
+
import { Object3D } from 'three';
|
|
4
|
+
export interface StartOptions {
|
|
5
|
+
dragStart?: (object: Object3D) => void;
|
|
6
|
+
drag?: (object: Object3D) => void;
|
|
7
|
+
dragEnd?: (object: Object3D) => void;
|
|
8
|
+
}
|
|
9
|
+
declare class DragControlsPlugin {
|
|
10
|
+
controls: DragControls | null;
|
|
11
|
+
viewport: SoonSpace['viewport'];
|
|
12
|
+
constructor(ssp: SoonSpace);
|
|
13
|
+
start(objects: Object3D[], options?: StartOptions): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
}
|
|
16
|
+
export default DragControlsPlugin;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plane as t,Vector2 as e,Vector3 as n,Matrix4 as o,Controls as s,Raycaster as i,MOUSE as r,TOUCH as a}from"three";const l=new t,h=new e,c=new n,d=new e,u=new e,m=new n,p=new n,E=new o,v=new n,b=new n;let w=null;const y=[],P=-1,_=0,L=1;class x extends s{constructor(t,e,n=null){super(e,n),this.objects=t,this.objectSet=new WeakSet(t),this.poiNodeSet=new Set,t.forEach(
|
|
1
|
+
import{Plane as t,Vector2 as e,Vector3 as n,Matrix4 as o,Controls as s,Raycaster as i,MOUSE as r,TOUCH as a}from"three";const l=new t,h=new e,c=new n,d=new e,u=new e,m=new n,p=new n,E=new o,v=new n,b=new n;let w=null;const y=[],P=-1,_=0,L=1;class x extends s{constructor(t,e,n=null){super(e,n),this.objects=t,this.objectSet=new WeakSet(t),this.poiNodeSet=new Set,t.forEach(t=>{"PoiNode"===t.stype&&this.poiNodeSet.add(t)}),this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new i,this.mouseButtons={LEFT:r.PAN,MIDDLE:r.PAN,RIGHT:r.ROTATE},this.touches={ONE:a.PAN},this._onPointerMove=f.bind(this),this._onPointerDown=g.bind(this),this._onPointerCancel=S.bind(this),null!==n&&this.connect()}connect(){this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none",this.domElement.style.userSelect="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto",this.domElement.style.userSelect="auto",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(t){const e=this.domElement.getBoundingClientRect();h.x=(t.clientX-e.left)/e.width*2-1,h.y=-(t.clientY-e.top)/e.height*2+1}_updateState(t){let e;if("touch"===t.pointerType)e=this.touches.ONE;else 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=null}switch(e){case r.PAN:case a.PAN:this.state=_;break;case r.ROTATE:case a.ROTATE:this.state=L;break;default:this.state=P}}}function f(t){const e=this.object;this.domElement;const n=this.raycaster;!1!==this.enabled&&(this._updatePointer(t),n.setFromCamera(h,e),w&&(this.state===_?n.ray.intersectPlane(l,m)&&w.position.copy(m.sub(c).applyMatrix4(E)):this.state===L&&(d.subVectors(h,u).multiplyScalar(this.rotateSpeed),w.rotateOnWorldAxis(v,d.x),w.rotateOnWorldAxis(b.normalize(),-d.y)),this.dispatchEvent({type:"drag",object:w}),u.copy(h)),u.copy(h))}function g(t){const e=this.object,n=this.domElement,o=this.raycaster;if(!1===this.enabled)return;this._updatePointer(t),this._updateState(t),y.length=0;let s=null;var i;(this.poiNodeSet.forEach(e=>{e.element.contains(t.target)&&(s=e)}),s||(o.setFromCamera(h,e),o.intersectObjects(this.objects,this.recursive,y),s=y[0]?y[0].object:null),s)&&(w=null!==(i=j(s,this.objectSet))&&void 0!==i?i:s,l.setFromNormalAndCoplanarPoint(e.getWorldDirection(l.normal),p.setFromMatrixPosition(w.matrixWorld)),o.ray.intersectPlane(l,m)&&(this.state===_?(E.copy(w.parent.matrixWorld).invert(),c.copy(m).sub(p.setFromMatrixPosition(w.matrixWorld))):this.state===L&&(v.set(0,1,0).applyQuaternion(e.quaternion).normalize(),b.set(1,0,0).applyQuaternion(e.quaternion).normalize())),n.style.cursor="move",this.dispatchEvent({type:"dragstart",object:w}));u.copy(h)}function S(){!1!==this.enabled&&(w&&(this.dispatchEvent({type:"dragend",object:w}),w=null),this.domElement.style.cursor="auto",this.state=P)}function j(t,e){return e.has(t)?t:null===t.parent?null:j(t.parent,e)}class A{constructor(t){this.controls=null,this.viewport=t.viewport}start(t,e={}){var n,o,s;if(!this.controls){const{dragStart:i,drag:r,dragEnd:a}=e;this.controls=new x(t,this.viewport.camera,this.viewport.container),null===(n=this.controls)||void 0===n||n.addEventListener("dragstart",t=>{this.viewport.controls.enabled=!1,null==i||i(t.object)}),null===(o=this.controls)||void 0===o||o.addEventListener("drag",t=>{this.viewport.render(),null==r||r(t.object)}),null===(s=this.controls)||void 0===s||s.addEventListener("dragend",t=>{this.viewport.controls.enabled=!0,null==a||a(t.object)})}}stop(){this.controls&&(this.controls.dispose(),this.controls=null)}}export{A as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-drag-controls",
|
|
3
3
|
"pluginName": "Drag Controls Plugin",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.11",
|
|
5
5
|
"description": "Drag Controls Plugin plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xunwei",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "08bf9efb38c291f22ca044b936fd49269c716bbb",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.13.
|
|
18
|
+
"soonspacejs": "2.13.11"
|
|
19
19
|
}
|
|
20
20
|
}
|