three-stdlib 2.21.4 → 2.21.6

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.
@@ -31,15 +31,15 @@ declare class OrbitControls extends EventDispatcher {
31
31
  RIGHT: string;
32
32
  BOTTOM: string;
33
33
  };
34
- mouseButtons: {
34
+ mouseButtons: Partial<{
35
35
  LEFT: MOUSE;
36
36
  MIDDLE: MOUSE;
37
37
  RIGHT: MOUSE;
38
- };
39
- touches: {
38
+ }>;
39
+ touches: Partial<{
40
40
  ONE: TOUCH;
41
41
  TWO: TOUCH;
42
- };
42
+ }>;
43
43
  target0: Vector3;
44
44
  position0: Vector3;
45
45
  zoom0: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e);class n extends t.EventDispatcher{constructor(e,o){super(),i.default(this,"camera",void 0),i.default(this,"domElement",void 0),i.default(this,"isLocked",!1),i.default(this,"minPolarAngle",0),i.default(this,"maxPolarAngle",Math.PI),i.default(this,"changeEvent",{type:"change"}),i.default(this,"lockEvent",{type:"lock"}),i.default(this,"unlockEvent",{type:"unlock"}),i.default(this,"euler",new t.Euler(0,0,0,"YXZ")),i.default(this,"PI_2",Math.PI/2),i.default(this,"vec",new t.Vector3),i.default(this,"onMouseMove",(e=>{if(!this.domElement||!1===this.isLocked)return;const t=e.movementX||e.mozMovementX||e.webkitMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||0;this.euler.setFromQuaternion(this.camera.quaternion),this.euler.y-=.002*t,this.euler.x-=.002*o,this.euler.x=Math.max(this.PI_2-this.maxPolarAngle,Math.min(this.PI_2-this.minPolarAngle,this.euler.x)),this.camera.quaternion.setFromEuler(this.euler),this.dispatchEvent(this.changeEvent)})),i.default(this,"onPointerlockChange",(()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(this.lockEvent),this.isLocked=!0):(this.dispatchEvent(this.unlockEvent),this.isLocked=!1))})),i.default(this,"onPointerlockError",(()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")})),i.default(this,"connect",(e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))})),i.default(this,"disconnect",(()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))})),i.default(this,"dispose",(()=>{this.disconnect()})),i.default(this,"getObject",(()=>this.camera)),i.default(this,"direction",new t.Vector3(0,0,-1)),i.default(this,"getDirection",(e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion))),i.default(this,"moveForward",(e=>{this.vec.setFromMatrixColumn(this.camera.matrix,0),this.vec.crossVectors(this.camera.up,this.vec),this.camera.position.addScaledVector(this.vec,e)})),i.default(this,"moveRight",(e=>{this.vec.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(this.vec,e)})),i.default(this,"lock",(()=>{this.domElement&&this.domElement.requestPointerLock()})),i.default(this,"unlock",(()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()})),this.domElement=o,this.camera=e,this.domElement&&this.connect(this.domElement)}}exports.PointerLockControls=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e);const n=new t.Euler(0,0,0,"YXZ"),r=new t.Vector3,s={type:"change"},m={type:"lock"},a={type:"unlock"},h=Math.PI/2;class l extends t.EventDispatcher{constructor(e,o){super(),i.default(this,"camera",void 0),i.default(this,"domElement",void 0),i.default(this,"isLocked",void 0),i.default(this,"minPolarAngle",void 0),i.default(this,"maxPolarAngle",void 0),i.default(this,"pointerSpeed",void 0),i.default(this,"onMouseMove",(e=>{if(!this.domElement||!1===this.isLocked)return;const t=e.movementX||e.mozMovementX||e.webkitMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||0;n.setFromQuaternion(this.camera.quaternion),n.y-=.002*t*this.pointerSpeed,n.x-=.002*o*this.pointerSpeed,n.x=Math.max(h-this.maxPolarAngle,Math.min(h-this.minPolarAngle,n.x)),this.camera.quaternion.setFromEuler(n),this.dispatchEvent(s)})),i.default(this,"onPointerlockChange",(()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(m),this.isLocked=!0):(this.dispatchEvent(a),this.isLocked=!1))})),i.default(this,"onPointerlockError",(()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")})),i.default(this,"connect",(e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))})),i.default(this,"disconnect",(()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))})),i.default(this,"dispose",(()=>{this.disconnect()})),i.default(this,"getObject",(()=>this.camera)),i.default(this,"direction",new t.Vector3(0,0,-1)),i.default(this,"getDirection",(e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion))),i.default(this,"moveForward",(e=>{r.setFromMatrixColumn(this.camera.matrix,0),r.crossVectors(this.camera.up,r),this.camera.position.addScaledVector(r,e)})),i.default(this,"moveRight",(e=>{r.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(r,e)})),i.default(this,"lock",(()=>{this.domElement&&this.domElement.requestPointerLock()})),i.default(this,"unlock",(()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()})),this.camera=e,this.domElement=o,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,o&&this.connect(o)}}exports.PointerLockControls=l;
@@ -1,24 +1,19 @@
1
1
  import { Camera, EventDispatcher, Vector3 } from 'three';
2
2
  declare class PointerLockControls extends EventDispatcher {
3
- private camera;
3
+ camera: Camera;
4
4
  domElement?: HTMLElement;
5
5
  isLocked: boolean;
6
6
  minPolarAngle: number;
7
7
  maxPolarAngle: number;
8
- private changeEvent;
9
- private lockEvent;
10
- private unlockEvent;
11
- private euler;
12
- private PI_2;
13
- private vec;
8
+ pointerSpeed: number;
14
9
  constructor(camera: Camera, domElement?: HTMLElement);
15
10
  private onMouseMove;
16
11
  private onPointerlockChange;
17
12
  private onPointerlockError;
18
- connect: (domElement?: HTMLElement | undefined) => void;
13
+ connect: (domElement: HTMLElement) => void;
19
14
  disconnect: () => void;
20
15
  dispose: () => void;
21
- private getObject;
16
+ getObject: () => Camera;
22
17
  private direction;
23
18
  getDirection: (v: Vector3) => Vector3;
24
19
  moveForward: (distance: number) => void;
@@ -1,11 +1,23 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import { EventDispatcher, Euler, Vector3 } from 'three';
2
+ import { Euler, Vector3, EventDispatcher } from 'three';
3
+
4
+ const _euler = new Euler(0, 0, 0, 'YXZ');
5
+
6
+ const _vector = new Vector3();
7
+
8
+ const _changeEvent = {
9
+ type: 'change'
10
+ };
11
+ const _lockEvent = {
12
+ type: 'lock'
13
+ };
14
+ const _unlockEvent = {
15
+ type: 'unlock'
16
+ };
17
+
18
+ const _PI_2 = Math.PI / 2;
3
19
 
4
20
  class PointerLockControls extends EventDispatcher {
5
- // Set to constrain the pitch of the camera
6
- // Range is 0 to Math.PI radians
7
- // radians
8
- // radians
9
21
  constructor(camera, _domElement) {
10
22
  super();
11
23
 
@@ -13,50 +25,36 @@ class PointerLockControls extends EventDispatcher {
13
25
 
14
26
  _defineProperty(this, "domElement", void 0);
15
27
 
16
- _defineProperty(this, "isLocked", false);
28
+ _defineProperty(this, "isLocked", void 0);
17
29
 
18
- _defineProperty(this, "minPolarAngle", 0);
30
+ _defineProperty(this, "minPolarAngle", void 0);
19
31
 
20
- _defineProperty(this, "maxPolarAngle", Math.PI);
32
+ _defineProperty(this, "maxPolarAngle", void 0);
21
33
 
22
- _defineProperty(this, "changeEvent", {
23
- type: 'change'
24
- });
25
-
26
- _defineProperty(this, "lockEvent", {
27
- type: 'lock'
28
- });
29
-
30
- _defineProperty(this, "unlockEvent", {
31
- type: 'unlock'
32
- });
33
-
34
- _defineProperty(this, "euler", new Euler(0, 0, 0, 'YXZ'));
35
-
36
- _defineProperty(this, "PI_2", Math.PI / 2);
37
-
38
- _defineProperty(this, "vec", new Vector3());
34
+ _defineProperty(this, "pointerSpeed", void 0);
39
35
 
40
36
  _defineProperty(this, "onMouseMove", event => {
41
37
  if (!this.domElement || this.isLocked === false) return;
42
38
  const movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
43
39
  const movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
44
- this.euler.setFromQuaternion(this.camera.quaternion);
45
- this.euler.y -= movementX * 0.002;
46
- this.euler.x -= movementY * 0.002;
47
- this.euler.x = Math.max(this.PI_2 - this.maxPolarAngle, Math.min(this.PI_2 - this.minPolarAngle, this.euler.x));
48
- this.camera.quaternion.setFromEuler(this.euler);
49
- this.dispatchEvent(this.changeEvent);
40
+
41
+ _euler.setFromQuaternion(this.camera.quaternion);
42
+
43
+ _euler.y -= movementX * 0.002 * this.pointerSpeed;
44
+ _euler.x -= movementY * 0.002 * this.pointerSpeed;
45
+ _euler.x = Math.max(_PI_2 - this.maxPolarAngle, Math.min(_PI_2 - this.minPolarAngle, _euler.x));
46
+ this.camera.quaternion.setFromEuler(_euler);
47
+ this.dispatchEvent(_changeEvent);
50
48
  });
51
49
 
52
50
  _defineProperty(this, "onPointerlockChange", () => {
53
51
  if (!this.domElement) return;
54
52
 
55
53
  if (this.domElement.ownerDocument.pointerLockElement === this.domElement) {
56
- this.dispatchEvent(this.lockEvent);
54
+ this.dispatchEvent(_lockEvent);
57
55
  this.isLocked = true;
58
56
  } else {
59
- this.dispatchEvent(this.unlockEvent);
57
+ this.dispatchEvent(_unlockEvent);
60
58
  this.isLocked = false;
61
59
  }
62
60
  });
@@ -84,39 +82,52 @@ class PointerLockControls extends EventDispatcher {
84
82
  this.disconnect();
85
83
  });
86
84
 
87
- _defineProperty(this, "getObject", () => // retaining this method for backward compatibility
88
- this.camera);
85
+ _defineProperty(this, "getObject", () => {
86
+ // retaining this method for backward compatibility
87
+ return this.camera;
88
+ });
89
89
 
90
90
  _defineProperty(this, "direction", new Vector3(0, 0, -1));
91
91
 
92
- _defineProperty(this, "getDirection", v => v.copy(this.direction).applyQuaternion(this.camera.quaternion));
92
+ _defineProperty(this, "getDirection", v => {
93
+ return v.copy(this.direction).applyQuaternion(this.camera.quaternion);
94
+ });
93
95
 
94
96
  _defineProperty(this, "moveForward", distance => {
95
97
  // move forward parallel to the xz-plane
96
- // assumes this.camera.up is y-up
97
- this.vec.setFromMatrixColumn(this.camera.matrix, 0);
98
- this.vec.crossVectors(this.camera.up, this.vec);
99
- this.camera.position.addScaledVector(this.vec, distance);
98
+ // assumes camera.up is y-up
99
+ _vector.setFromMatrixColumn(this.camera.matrix, 0);
100
+
101
+ _vector.crossVectors(this.camera.up, _vector);
102
+
103
+ this.camera.position.addScaledVector(_vector, distance);
100
104
  });
101
105
 
102
106
  _defineProperty(this, "moveRight", distance => {
103
- this.vec.setFromMatrixColumn(this.camera.matrix, 0);
104
- this.camera.position.addScaledVector(this.vec, distance);
107
+ _vector.setFromMatrixColumn(this.camera.matrix, 0);
108
+
109
+ this.camera.position.addScaledVector(_vector, distance);
105
110
  });
106
111
 
107
112
  _defineProperty(this, "lock", () => {
108
- if (!this.domElement) return;
109
- this.domElement.requestPointerLock();
113
+ if (this.domElement) this.domElement.requestPointerLock();
110
114
  });
111
115
 
112
116
  _defineProperty(this, "unlock", () => {
113
- if (!this.domElement) return;
114
- this.domElement.ownerDocument.exitPointerLock();
117
+ if (this.domElement) this.domElement.ownerDocument.exitPointerLock();
115
118
  });
116
119
 
117
- this.domElement = _domElement;
118
120
  this.camera = camera;
119
- if (this.domElement) this.connect(this.domElement);
121
+ this.domElement = _domElement;
122
+ this.isLocked = false; // Set to constrain the pitch of the camera
123
+ // Range is 0 to Math.PI radians
124
+
125
+ this.minPolarAngle = 0; // radians
126
+
127
+ this.maxPolarAngle = Math.PI; // radians
128
+
129
+ this.pointerSpeed = 1.0;
130
+ if (_domElement) this.connect(_domElement);
120
131
  }
121
132
 
122
133
  }