@xeokit/xeokit-sdk 2.6.98 → 2.6.100

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.98",
3
+ "version": "2.6.100",
4
4
  "description": "3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -323,6 +323,7 @@ class GLTFLoaderPlugin extends Plugin {
323
323
  * primitives. Only works while {@link DTX#enabled} is also ````true````.
324
324
  * @param {Boolean} [params.autoMetaModel] When supplied, creates a default MetaModel with a single MetaObject.
325
325
  * @param {Boolean} [params.globalizeObjectIds=false] Indicates whether to globalize each {@link Entity#id} and {@link MetaObject#id}, in case you need to prevent ID clashes with other models.
326
+ * @param {*} [params.parseOptions={}] Options to pass to loaders.gl parse method, eg. ````{ gltf: { excludeExtensions: { "KHR_texture_transform": false } } }````.
326
327
  * @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
327
328
  */
328
329
  load(params = {}) {
@@ -102,6 +102,7 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok, er
102
102
  const spinner = plugin.viewer.scene.canvas.spinner;
103
103
  spinner.processes++;
104
104
  parse(gltf, GLTFLoader, {
105
+ ...(options.parseOptions || { }),
105
106
  baseUri: options.basePath
106
107
  }).then((gltfData) => {
107
108
  const processedGLTF = postProcessGLTF(gltfData);
@@ -193,6 +193,7 @@ class NavCubePlugin extends Plugin {
193
193
 
194
194
  this._cubeSampler = new Texture(navCubeScene, {
195
195
  image: this._cubeTextureCanvas.getImage(),
196
+ maxAnisotropy: 4,
196
197
  flipY: true,
197
198
  wrapS: ClampToEdgeWrapping,
198
199
  wrapT: ClampToEdgeWrapping
@@ -103,6 +103,7 @@ class Texture extends Component {
103
103
  * @param {HTMLImageElement} [cfg.image=null] HTML Image object to load into this Texture. See the {@link Texture#image} property for more info.
104
104
  * @param {Number} [cfg.minFilter=LinearMipmapLinearFilter] How the texture is sampled when a texel covers less than one pixel.
105
105
  * Supported values are {@link LinearMipmapLinearFilter}, {@link LinearMipMapNearestFilter}, {@link NearestMipMapNearestFilter}, {@link NearestMipMapLinearFilter} and {@link LinearMipMapLinearFilter}.
106
+ * @param {Number} [cfg.maxAnisotropy=false] Max anisotropy to use for texture filtering (see EXT_texture_filter_anisotropic).
106
107
  * @param {Number} [cfg.magFilter=LinearFilter] How the texture is sampled when a texel covers more than one pixel. Supported values are {@link LinearFilter} and {@link NearestFilter}.
107
108
  * @param {Number} [cfg.wrapS=RepeatWrapping] Wrap parameter for texture coordinate *S*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
108
109
  * @param {Number} [cfg.wrapT=RepeatWrapping] Wrap parameter for texture coordinate *T*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}..
@@ -120,6 +121,7 @@ class Texture extends Component {
120
121
  texture: new Texture2D({gl: this.scene.canvas.gl}),
121
122
  matrix: math.identityMat4(),
122
123
  hasMatrix: (cfg.translate && (cfg.translate[0] !== 0 || cfg.translate[1] !== 0)) || (!!cfg.rotate) || (cfg.scale && (cfg.scale[0] !== 0 || cfg.scale[1] !== 0)),
124
+ maxAnisotropy: cfg.maxAnisotropy,
123
125
  minFilter: this._checkMinFilter(cfg.minFilter),
124
126
  magFilter: this._checkMagFilter(cfg.magFilter),
125
127
  wrapS: this._checkWrapS(cfg.wrapS),
@@ -253,6 +253,16 @@ const math = {
253
253
  return a;
254
254
  },
255
255
 
256
+ /**
257
+ * Returns true if the two 2-element vectors are the same.
258
+ * @param v1
259
+ * @param v2
260
+ * @returns {Boolean}
261
+ */
262
+ compareVec2(v1, v2) {
263
+ return (v1[0] === v2[0] && v1[1] === v2[1]);
264
+ },
265
+
256
266
  /**
257
267
  * Returns true if the two 3-element vectors are the same.
258
268
  * @param v1
@@ -350,6 +360,24 @@ const math = {
350
360
  return dest;
351
361
  },
352
362
 
363
+ /**
364
+ * Adds one two-element vector to another.
365
+ * @method addVec3
366
+ * @static
367
+ * @param {Array(Number)} u First vector
368
+ * @param {Array(Number)} v Second vector
369
+ * @param {Array(Number)} [dest] Destination vector
370
+ * @return {Array(Number)} dest if specified, u otherwise
371
+ */
372
+ addVec2(u, v, dest) {
373
+ if (!dest) {
374
+ dest = u;
375
+ }
376
+ dest[0] = u[0] + v[0];
377
+ dest[1] = u[1] + v[1];
378
+ return dest;
379
+ },
380
+
353
381
  /**
354
382
  * Adds one three-element vector to another.
355
383
  * @method addVec3
@@ -504,8 +532,26 @@ const math = {
504
532
  },
505
533
 
506
534
  /**
507
- * Multiplies one three-element vector by another.
508
- * @method mulVec3
535
+ * Multiplies one two-element vector by another.
536
+ * @method mulVec2
537
+ * @static
538
+ * @param {Array(Number)} u First vector
539
+ * @param {Array(Number)} v Second vector
540
+ * @param {Array(Number)} [dest] Destination vector
541
+ * @return {Array(Number)} dest if specified, u otherwise
542
+ */
543
+ mulVec2(u, v, dest) {
544
+ if (!dest) {
545
+ dest = u;
546
+ }
547
+ dest[0] = u[0] * v[0];
548
+ dest[1] = u[1] * v[1];
549
+ return dest;
550
+ },
551
+
552
+ /**
553
+ * Multiplies one four-element vector by another.
554
+ * @method mulVec4
509
555
  * @static
510
556
  * @param {Array(Number)} u First vector
511
557
  * @param {Array(Number)} v Second vector
@@ -108,6 +108,7 @@ class Texture2D {
108
108
  if (props.unpackAlignment !== undefined) {
109
109
  this.unpackAlignment = props.unpackAlignment;
110
110
  }
111
+ this.maxAnisotropy = props.maxAnisotropy;
111
112
  if (props.minFilter !== undefined) {
112
113
  this.minFilter = props.minFilter;
113
114
  }
@@ -140,6 +141,12 @@ class Texture2D {
140
141
  const bak4 = gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL);;
141
142
  gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
142
143
 
144
+ const anisoExt = this.maxAnisotropy && getExtension(gl, "EXT_texture_filter_anisotropic");
145
+ if (anisoExt) {
146
+ const max = gl.getParameter(anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
147
+ gl.texParameterf(gl.TEXTURE_2D, anisoExt.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(max, this.maxAnisotropy));
148
+ }
149
+
143
150
  const minFilter = convertConstant(gl, this.minFilter);
144
151
  gl.texParameteri(this.target, gl.TEXTURE_MIN_FILTER, minFilter);
145
152
 
@@ -83,6 +83,8 @@ export declare type LoadGLTFModel = {
83
83
  performance?: boolean;
84
84
  /** When true, generate a single MetaObject that represents the entire glTF model, and a MetaObject for each entity within it. */
85
85
  autoMetaModel?: boolean;
86
+ /** Options to pass to loaders.gl parse method, eg. ````{ gltf: { excludeExtensions: { "KHR_texture_transform": false } } }````. */
87
+ parseOptions?: any;
86
88
  };
87
89
 
88
90
  /**
@@ -7,6 +7,8 @@ export declare type TextureConfiguration = {
7
7
  src?: string;
8
8
  /** HTML Image object to load into this Texture. See the {@link Texture#image} property for more info. */
9
9
  image?: HTMLImageElement;
10
+ /** Max anisotropy to use for texture filtering (see EXT_texture_filter_anisotropic). */
11
+ maxAnisotropy?: number;
10
12
  /** How the texture is sampled when a texel covers less than one pixel. */
11
13
  minFilter?: "LinearFilter" | "LinearMipMapNearestFilter" | "NearestMipMapNearestFilter" | "NearestMipMapLinearFilter" | "LinearMipMapLinearFilter";
12
14
  /** How the texture is sampled when a texel covers more than one pixel. Supported values are {@link LinearFilter} and {@link NearestFilter}. */