three-stdlib 2.23.7 → 2.23.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const THREE = require("three");
4
4
  const fflate = require("fflate");
5
+ const hasColorSpace = "colorSpace" in /* @__PURE__ */ new THREE.Texture();
5
6
  class EXRLoader extends THREE.DataTextureLoader {
6
7
  constructor(manager) {
7
8
  super(manager);
@@ -1200,7 +1201,7 @@ class EXRLoader extends THREE.DataTextureLoader {
1200
1201
  uncompress: null,
1201
1202
  getter: null,
1202
1203
  format: null,
1203
- encoding: null
1204
+ [hasColorSpace ? "colorSpace" : "encoding"]: null
1204
1205
  };
1205
1206
  switch (EXRHeader2.compression) {
1206
1207
  case "NO_COMPRESSION":
@@ -1284,13 +1285,14 @@ class EXRLoader extends THREE.DataTextureLoader {
1284
1285
  break;
1285
1286
  }
1286
1287
  EXRDecoder2.bytesPerLine = EXRDecoder2.width * EXRDecoder2.inputSize * EXRDecoder2.channels;
1287
- if (EXRDecoder2.outputChannels == 4) {
1288
+ if (EXRDecoder2.outputChannels == 4)
1288
1289
  EXRDecoder2.format = THREE.RGBAFormat;
1289
- EXRDecoder2.encoding = 3e3;
1290
- } else {
1290
+ else
1291
1291
  EXRDecoder2.format = THREE.RedFormat;
1292
+ if (hasColorSpace)
1293
+ EXRDecoder2.colorSpace = "srgb-linear";
1294
+ else
1292
1295
  EXRDecoder2.encoding = 3e3;
1293
- }
1294
1296
  return EXRDecoder2;
1295
1297
  }
1296
1298
  const bufferDataView = new DataView(buffer);
@@ -1327,7 +1329,7 @@ class EXRLoader extends THREE.DataTextureLoader {
1327
1329
  height: EXRDecoder.height,
1328
1330
  data: EXRDecoder.byteArray,
1329
1331
  format: EXRDecoder.format,
1330
- encoding: EXRDecoder.encoding,
1332
+ [hasColorSpace ? "colorSpace" : "encoding"]: EXRDecoder[hasColorSpace ? "colorSpace" : "encoding"],
1331
1333
  type: this.type
1332
1334
  };
1333
1335
  }
@@ -1337,8 +1339,8 @@ class EXRLoader extends THREE.DataTextureLoader {
1337
1339
  }
1338
1340
  load(url, onLoad, onProgress, onError) {
1339
1341
  function onLoadCallback(texture, texData) {
1340
- if ("colorSpace" in texture)
1341
- texture.colorSpace = texData.encoding === 3001 ? "srgb" : "srgb-linear";
1342
+ if (hasColorSpace)
1343
+ texture.colorSpace = texData.colorSpace;
1342
1344
  else
1343
1345
  texture.encoding = texData.encoding;
1344
1346
  texture.minFilter = THREE.LinearFilter;
@@ -1,5 +1,6 @@
1
- import { DataTextureLoader, HalfFloatType, DataUtils, FloatType, RGBAFormat, RedFormat, LinearFilter } from "three";
1
+ import { Texture, DataTextureLoader, HalfFloatType, DataUtils, FloatType, RGBAFormat, RedFormat, LinearFilter } from "three";
2
2
  import { unzlibSync } from "fflate";
3
+ const hasColorSpace = "colorSpace" in /* @__PURE__ */ new Texture();
3
4
  class EXRLoader extends DataTextureLoader {
4
5
  constructor(manager) {
5
6
  super(manager);
@@ -1198,7 +1199,7 @@ class EXRLoader extends DataTextureLoader {
1198
1199
  uncompress: null,
1199
1200
  getter: null,
1200
1201
  format: null,
1201
- encoding: null
1202
+ [hasColorSpace ? "colorSpace" : "encoding"]: null
1202
1203
  };
1203
1204
  switch (EXRHeader2.compression) {
1204
1205
  case "NO_COMPRESSION":
@@ -1282,13 +1283,14 @@ class EXRLoader extends DataTextureLoader {
1282
1283
  break;
1283
1284
  }
1284
1285
  EXRDecoder2.bytesPerLine = EXRDecoder2.width * EXRDecoder2.inputSize * EXRDecoder2.channels;
1285
- if (EXRDecoder2.outputChannels == 4) {
1286
+ if (EXRDecoder2.outputChannels == 4)
1286
1287
  EXRDecoder2.format = RGBAFormat;
1287
- EXRDecoder2.encoding = 3e3;
1288
- } else {
1288
+ else
1289
1289
  EXRDecoder2.format = RedFormat;
1290
+ if (hasColorSpace)
1291
+ EXRDecoder2.colorSpace = "srgb-linear";
1292
+ else
1290
1293
  EXRDecoder2.encoding = 3e3;
1291
- }
1292
1294
  return EXRDecoder2;
1293
1295
  }
1294
1296
  const bufferDataView = new DataView(buffer);
@@ -1325,7 +1327,7 @@ class EXRLoader extends DataTextureLoader {
1325
1327
  height: EXRDecoder.height,
1326
1328
  data: EXRDecoder.byteArray,
1327
1329
  format: EXRDecoder.format,
1328
- encoding: EXRDecoder.encoding,
1330
+ [hasColorSpace ? "colorSpace" : "encoding"]: EXRDecoder[hasColorSpace ? "colorSpace" : "encoding"],
1329
1331
  type: this.type
1330
1332
  };
1331
1333
  }
@@ -1335,8 +1337,8 @@ class EXRLoader extends DataTextureLoader {
1335
1337
  }
1336
1338
  load(url, onLoad, onProgress, onError) {
1337
1339
  function onLoadCallback(texture, texData) {
1338
- if ("colorSpace" in texture)
1339
- texture.colorSpace = texData.encoding === 3001 ? "srgb" : "srgb-linear";
1340
+ if (hasColorSpace)
1341
+ texture.colorSpace = texData.colorSpace;
1340
1342
  else
1341
1343
  texture.encoding = texData.encoding;
1342
1344
  texture.minFilter = LinearFilter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-stdlib",
3
- "version": "2.23.7",
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