@kitware/vtk.js 25.1.2 → 25.1.3

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.
@@ -98,6 +98,8 @@ function vtkWebGPUActor2D(publicAPI, model) {
98
98
 
99
99
  if (model.renderable.getCoordinateSystem() === CoordinateSystem.WORLD) {
100
100
  mat4.translate(model.keyMatrices.bcsc, model.keyMatrices.bcwc, [-center[0], -center[1], -center[2]]);
101
+ } else {
102
+ mat4.copy(model.keyMatrices.bcsc, model.keyMatrices.bcwc);
101
103
  }
102
104
 
103
105
  model.keyMatricesTime.modified();
@@ -65,7 +65,7 @@ function _getFormatForDataArray(dataArray) {
65
65
 
66
66
  case 3:
67
67
  // only 32bit types support x3
68
- if (!format.contains('32')) {
68
+ if (!format.includes('32')) {
69
69
  vtkErrorMacro("unsupported x3 type for ".concat(format));
70
70
  }
71
71
 
@@ -9,6 +9,7 @@ import vtkWebGPUBufferManager from './BufferManager.js';
9
9
  import vtkWebGPUShaderCache from './ShaderCache.js';
10
10
  import vtkWebGPUUniformBuffer from './UniformBuffer.js';
11
11
  import vtkWebGPUSimpleMapper from './SimpleMapper.js';
12
+ import vtkWebGPUTypes from './Types.js';
12
13
 
13
14
  var BufferUsage = vtkWebGPUBufferManager.BufferUsage,
14
15
  PrimitiveTypes = vtkWebGPUBufferManager.PrimitiveTypes;
@@ -223,15 +224,23 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
223
224
  publicAPI.replaceShaderTCoord = function (hash, pipeline, vertexInput) {
224
225
  if (!vertexInput.hasAttribute('tcoord')) return;
225
226
  var vDesc = pipeline.getShaderDescription('vertex');
226
- vDesc.addOutput('vec2<f32>', 'tcoordVS');
227
+ var tcoords = vertexInput.getBuffer('tcoord');
228
+ var numComp = vtkWebGPUTypes.getNumberOfComponentsFromBufferFormat(tcoords.getArrayInformation()[0].format);
227
229
  var code = vDesc.getCode();
230
+ vDesc.addOutput("vec".concat(numComp, "<f32>"), 'tcoordVS');
228
231
  code = vtkWebGPUShaderCache.substitute(code, '//VTK::TCoord::Impl', [' output.tcoordVS = tcoord;']).result;
229
232
  vDesc.setCode(code);
230
233
  var fDesc = pipeline.getShaderDescription('fragment');
231
234
  code = fDesc.getCode(); // todo handle multiple textures? Blend multiply ?
232
235
 
233
236
  if (model.textures.length) {
234
- code = vtkWebGPUShaderCache.substitute(code, '//VTK::TCoord::Impl', ['var tcolor: vec4<f32> = textureSample(Texture0, Texture0Sampler, input.tcoordVS);', 'computedColor = computedColor*tcolor;']).result;
237
+ var tdims = model.textures[0].getDimensions();
238
+
239
+ if (tdims === numComp) {
240
+ code = vtkWebGPUShaderCache.substitute(code, '//VTK::TCoord::Impl', ['var tcolor: vec4<f32> = textureSample(Texture0, Texture0Sampler, input.tcoordVS);', 'computedColor = computedColor*tcolor;']).result;
241
+ } else {
242
+ console.log("mismatched texture coord dimension ".concat(numComp, " with texture map dimension ").concat(tdims));
243
+ }
235
244
  }
236
245
 
237
246
  fDesc.setCode(code);
@@ -366,6 +375,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
366
375
 
367
376
 
368
377
  var usage = publicAPI.getUsage(representation, primType);
378
+ model._usesCellNormals = false;
369
379
 
370
380
  if (!model.is2D && ( // no lighting on Property2D
371
381
  usage === BufferUsage.Triangles || usage === BufferUsage.Strips)) {
@@ -387,6 +397,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
387
397
 
388
398
  vertexInput.addBuffer(_buff, ['normalMC']);
389
399
  } else if (primType === PrimitiveTypes.Triangles) {
400
+ model._usesCellNormals = true;
390
401
  _buffRequest2.hash = "PFN".concat(points.getMTime(), "I").concat(indexBuffer.getMTime(), "snorm8x4");
391
402
  _buffRequest2.dataArray = points;
392
403
  _buffRequest2.cells = cells;
@@ -548,7 +559,9 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
548
559
  }
549
560
 
550
561
  if (model.vertexInput.hasAttribute("tcoord")) {
551
- pipelineHash += "t";
562
+ var tcoords = model.vertexInput.getBuffer('tcoord');
563
+ var numComp = vtkWebGPUTypes.getNumberOfComponentsFromBufferFormat(tcoords.getArrayInformation()[0].format);
564
+ pipelineHash += "t".concat(numComp);
552
565
  }
553
566
 
554
567
  if (model.textures.length) {
@@ -556,6 +569,10 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
556
569
  }
557
570
  }
558
571
 
572
+ if (model._usesCellNormals) {
573
+ pipelineHash += "cn";
574
+ }
575
+
559
576
  if (model.SSBO) {
560
577
  pipelineHash += "ssbo";
561
578
  }
@@ -184,6 +184,10 @@ function vtkWebGPUTexture(publicAPI, model) {
184
184
  return tDetails.numComponents;
185
185
  };
186
186
 
187
+ publicAPI.getDimensions = function () {
188
+ return model.depth > 1 ? 3 : 2;
189
+ };
190
+
187
191
  publicAPI.resizeToMatch = function (tex) {
188
192
  if (tex.getWidth() !== model.width || tex.getHeight() !== model.height || tex.getDepth() !== model.depth) {
189
193
  model.width = tex.getWidth();
@@ -325,7 +325,7 @@ function getByteStrideFromBufferFormat(format) {
325
325
  var numComp = 1;
326
326
 
327
327
  if (format[format.length - 2] === 'x') {
328
- numComp = format[format.length - 1];
328
+ numComp = Number(format[format.length - 1]);
329
329
  }
330
330
 
331
331
  var sizeStart = numComp === 1 ? format.length - 1 : format.length - 3; // options are 8, 16, 32 resulting in 8, 6, 2 as the last char
@@ -350,7 +350,7 @@ function getNumberOfComponentsFromBufferFormat(format) {
350
350
  var numComp = 1;
351
351
 
352
352
  if (format[format.length - 2] === 'x') {
353
- numComp = format[format.length - 1];
353
+ numComp = Number(format[format.length - 1]);
354
354
  }
355
355
 
356
356
  return numComp;
@@ -421,7 +421,7 @@ function getByteStrideFromShaderFormat(format) {
421
421
  var numComp = 1;
422
422
 
423
423
  if (format.substring(0, 3) === 'vec') {
424
- numComp = format[3];
424
+ numComp = Number(format[3]);
425
425
  } else if (format.substring(0, 3) === 'mat') {
426
426
  numComp = format[3] * format[5];
427
427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "25.1.2",
3
+ "version": "25.1.3",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",