@kitware/vtk.js 25.14.1 → 25.14.2

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.
@@ -1,3 +1,5 @@
1
+ // This is used to access the underlying 3D context
2
+ var GET_UNDERLYING_CONTEXT = '__getUnderlyingContext';
1
3
  function createContextProxyHandler() {
2
4
  var cache = new Map();
3
5
  var getParameterHandler = {
@@ -41,6 +43,9 @@ function createContextProxyHandler() {
41
43
 
42
44
  return {
43
45
  get: function get(gl, prop, receiver) {
46
+ if (prop === GET_UNDERLYING_CONTEXT) return function () {
47
+ return gl;
48
+ };
44
49
  var value = Reflect.get(gl, prop, gl);
45
50
 
46
51
  if (value instanceof Function) {
@@ -62,4 +67,4 @@ var ContextProxy = {
62
67
  createContextProxyHandler: createContextProxyHandler
63
68
  };
64
69
 
65
- export { createContextProxyHandler, ContextProxy as default };
70
+ export { GET_UNDERLYING_CONTEXT, createContextProxyHandler, ContextProxy as default };
@@ -12,7 +12,7 @@ import vtkTextureUnitManager from './TextureUnitManager.js';
12
12
  import vtkViewNodeFactory from './ViewNodeFactory.js';
13
13
  import vtkRenderPass from '../SceneGraph/RenderPass.js';
14
14
  import vtkRenderWindowViewNode from '../SceneGraph/RenderWindowViewNode.js';
15
- import { createContextProxyHandler } from './RenderWindow/ContextProxy.js';
15
+ import { createContextProxyHandler, GET_UNDERLYING_CONTEXT } from './RenderWindow/ContextProxy.js';
16
16
 
17
17
  var vtkDebugMacro = macro.vtkDebugMacro,
18
18
  vtkErrorMacro = macro.vtkErrorMacro;
@@ -310,7 +310,8 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
310
310
  return gl.makeXRCompatible();
311
311
 
312
312
  case 6:
313
- glLayer = new global.XRWebGLLayer(model.xrSession, gl);
313
+ glLayer = new global.XRWebGLLayer(model.xrSession, // constructor needs unproxied context
314
+ gl[GET_UNDERLYING_CONTEXT]());
314
315
  publicAPI.setSize(glLayer.framebufferWidth, glLayer.framebufferHeight);
315
316
  model.xrSession.updateRenderState({
316
317
  baseLayer: glLayer
@@ -178,7 +178,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
178
178
 
179
179
  if (model.zBufferTexture !== null) {
180
180
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Dec', ['uniform sampler2D zBufferTexture;', 'uniform float vpWidth;', 'uniform float vpHeight;']).result;
181
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', ['vec4 depthVec = texture2D(zBufferTexture, vec2(gl_FragCoord.x / vpWidth, gl_FragCoord.y/vpHeight));', 'float zdepth = (depthVec.r*256.0 + depthVec.g)/257.0;', 'zdepth = zdepth * 2.0 - 1.0;', 'zdepth = -2.0 * camFar * camNear / (zdepth*(camFar-camNear)-(camFar+camNear)) - camNear;', 'zdepth = -zdepth/rayDir.z;', 'dists.y = min(zdepth,dists.y);']).result;
181
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', ['vec4 depthVec = texture2D(zBufferTexture, vec2(gl_FragCoord.x / vpWidth, gl_FragCoord.y/vpHeight));', 'float zdepth = (depthVec.r*256.0 + depthVec.g)/257.0;', 'zdepth = zdepth * 2.0 - 1.0;', 'if (cameraParallel == 0) {', 'zdepth = -2.0 * camFar * camNear / (zdepth*(camFar-camNear)-(camFar+camNear)) - camNear;}', 'else {', 'zdepth = (zdepth + 1.0) * 0.5 * (camFar - camNear);}\n', 'zdepth = -zdepth/rayDir.z;', 'dists.y = min(zdepth,dists.y);']).result;
182
182
  } // Set the BlendMode approach
183
183
 
184
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "25.14.1",
3
+ "version": "25.14.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",