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);
|
|
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
|
-
|
|
3
|
+
camera: Camera;
|
|
4
4
|
domElement?: HTMLElement;
|
|
5
5
|
isLocked: boolean;
|
|
6
6
|
minPolarAngle: number;
|
|
7
7
|
maxPolarAngle: number;
|
|
8
|
-
|
|
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
|
|
13
|
+
connect: (domElement: HTMLElement) => void;
|
|
19
14
|
disconnect: () => void;
|
|
20
15
|
dispose: () => void;
|
|
21
|
-
|
|
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 {
|
|
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",
|
|
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",
|
|
32
|
+
_defineProperty(this, "maxPolarAngle", void 0);
|
|
21
33
|
|
|
22
|
-
_defineProperty(this, "
|
|
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
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
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(
|
|
54
|
+
this.dispatchEvent(_lockEvent);
|
|
57
55
|
this.isLocked = true;
|
|
58
56
|
} else {
|
|
59
|
-
this.dispatchEvent(
|
|
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", () =>
|
|
88
|
-
|
|
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 =>
|
|
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
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.camera.
|
|
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
|
-
|
|
104
|
-
|
|
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 (
|
|
109
|
-
this.domElement.requestPointerLock();
|
|
113
|
+
if (this.domElement) this.domElement.requestPointerLock();
|
|
110
114
|
});
|
|
111
115
|
|
|
112
116
|
_defineProperty(this, "unlock", () => {
|
|
113
|
-
if (
|
|
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
|
-
|
|
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
|
}
|