three-stdlib 2.23.8 → 2.23.9

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-stdlib",
3
- "version": "2.23.8",
3
+ "version": "2.23.9",
4
4
  "description": "stand-alone library of threejs examples",
5
5
  "keywords": [
6
6
  "three",
@@ -50,14 +50,25 @@ class OculusHandPointerModel extends THREE__namespace.Object3D {
50
50
  this.attached = false;
51
51
  this.cursorObject = null;
52
52
  this.raycaster = null;
53
- hand.addEventListener("connected", (event) => {
54
- const xrInputSource = event.data;
55
- if (xrInputSource.hand) {
56
- this.visible = true;
57
- this.xrInputSource = xrInputSource;
58
- this.createPointer();
59
- }
60
- });
53
+ this._onConnected = this._onConnected.bind(this);
54
+ this._onDisconnected = this._onDisconnected.bind(this);
55
+ this.hand.addEventListener("connected", this._onConnected);
56
+ this.hand.addEventListener("disconnected", this._onDisconnected);
57
+ }
58
+ _onConnected(event) {
59
+ const xrInputSource = event.data;
60
+ if (xrInputSource.hand) {
61
+ this.visible = true;
62
+ this.xrInputSource = xrInputSource;
63
+ this.createPointer();
64
+ }
65
+ }
66
+ _onDisconnected() {
67
+ this.visible = false;
68
+ this.xrInputSource = null;
69
+ this.pointerGeometry.dispose();
70
+ this.pointerMesh.material.dispose();
71
+ this.clear();
61
72
  }
62
73
  _drawVerticesRing(vertices, baseVector, ringIndex) {
63
74
  const segmentVector = baseVector.clone();
@@ -220,5 +231,10 @@ class OculusHandPointerModel extends THREE__namespace.Object3D {
220
231
  this.cursorObject.position.copy(direction.multiplyScalar(distance));
221
232
  }
222
233
  }
234
+ dispose() {
235
+ this._onDisconnected();
236
+ this.hand.removeEventListener("connected", this._onConnected);
237
+ this.hand.removeEventListener("disconnected", this._onDisconnected);
238
+ }
223
239
  }
224
240
  exports.OculusHandPointerModel = OculusHandPointerModel;
@@ -60,4 +60,6 @@ export class OculusHandPointerModel extends Object3D {
60
60
  public checkIntersections(objects: Object3D[], recursive?: boolean): void
61
61
 
62
62
  public setCursor(distance: number): void
63
+
64
+ public dispose(): void
63
65
  }
@@ -31,14 +31,25 @@ class OculusHandPointerModel extends THREE.Object3D {
31
31
  this.attached = false;
32
32
  this.cursorObject = null;
33
33
  this.raycaster = null;
34
- hand.addEventListener("connected", (event) => {
35
- const xrInputSource = event.data;
36
- if (xrInputSource.hand) {
37
- this.visible = true;
38
- this.xrInputSource = xrInputSource;
39
- this.createPointer();
40
- }
41
- });
34
+ this._onConnected = this._onConnected.bind(this);
35
+ this._onDisconnected = this._onDisconnected.bind(this);
36
+ this.hand.addEventListener("connected", this._onConnected);
37
+ this.hand.addEventListener("disconnected", this._onDisconnected);
38
+ }
39
+ _onConnected(event) {
40
+ const xrInputSource = event.data;
41
+ if (xrInputSource.hand) {
42
+ this.visible = true;
43
+ this.xrInputSource = xrInputSource;
44
+ this.createPointer();
45
+ }
46
+ }
47
+ _onDisconnected() {
48
+ this.visible = false;
49
+ this.xrInputSource = null;
50
+ this.pointerGeometry.dispose();
51
+ this.pointerMesh.material.dispose();
52
+ this.clear();
42
53
  }
43
54
  _drawVerticesRing(vertices, baseVector, ringIndex) {
44
55
  const segmentVector = baseVector.clone();
@@ -201,6 +212,11 @@ class OculusHandPointerModel extends THREE.Object3D {
201
212
  this.cursorObject.position.copy(direction.multiplyScalar(distance));
202
213
  }
203
214
  }
215
+ dispose() {
216
+ this._onDisconnected();
217
+ this.hand.removeEventListener("connected", this._onConnected);
218
+ this.hand.removeEventListener("disconnected", this._onDisconnected);
219
+ }
204
220
  }
205
221
  export {
206
222
  OculusHandPointerModel