@xeokit/xeokit-sdk 2.4.0-alpha-37 → 2.4.0-alpha-39

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.
@@ -16496,7 +16496,7 @@ class RenderBuffer {
16496
16496
 
16497
16497
  read(pickX, pickY, glFormat = null, glType = null, arrayType = Uint8Array, arrayMultiplier = 4) {
16498
16498
  const x = pickX;
16499
- const y = (this.buffer.height || this.gl.drawingBufferHeight) - 1 - pickY;
16499
+ const y = (this.buffer.height || this.gl.drawingBufferHeight) - pickY;
16500
16500
  const pix = new arrayType(arrayMultiplier);
16501
16501
  const gl = this.gl;
16502
16502
  gl.readPixels(x, y, 1, 1, glFormat || gl.RGBA, glType || gl.UNSIGNED_BYTE, pix, 0);
@@ -52500,11 +52500,8 @@ const pickTriangleSurface = (function () {
52500
52500
 
52501
52501
  // Attempt to ray-pick the triangle in local space
52502
52502
 
52503
- let canvasPos;
52504
-
52505
52503
  if (pickResult.canvasPos) {
52506
- canvasPos = pickResult.canvasPos;
52507
- math.canvasPosToLocalRay(canvas.canvas, pickViewMatrix, pickProjMatrix, mesh.worldMatrix, canvasPos, localRayOrigin, localRayDir);
52504
+ math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
52508
52505
 
52509
52506
  } else if (pickResult.origin && pickResult.direction) {
52510
52507
  math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
@@ -52535,6 +52532,12 @@ const pickTriangleSurface = (function () {
52535
52532
  worldPos[1] = tempVec4b[1];
52536
52533
  worldPos[2] = tempVec4b[2];
52537
52534
 
52535
+ if (pickResult.canvasPos && mesh.origin) {
52536
+ worldPos[0] += mesh.origin[0];
52537
+ worldPos[1] += mesh.origin[1];
52538
+ worldPos[2] += mesh.origin[2];
52539
+ }
52540
+
52538
52541
  pickResult.worldPos = worldPos;
52539
52542
 
52540
52543
  // Get View-space cartesian coordinates of the ray-triangle intersection
@@ -16492,7 +16492,7 @@ class RenderBuffer {
16492
16492
 
16493
16493
  read(pickX, pickY, glFormat = null, glType = null, arrayType = Uint8Array, arrayMultiplier = 4) {
16494
16494
  const x = pickX;
16495
- const y = (this.buffer.height || this.gl.drawingBufferHeight) - 1 - pickY;
16495
+ const y = (this.buffer.height || this.gl.drawingBufferHeight) - pickY;
16496
16496
  const pix = new arrayType(arrayMultiplier);
16497
16497
  const gl = this.gl;
16498
16498
  gl.readPixels(x, y, 1, 1, glFormat || gl.RGBA, glType || gl.UNSIGNED_BYTE, pix, 0);
@@ -52496,11 +52496,8 @@ const pickTriangleSurface = (function () {
52496
52496
 
52497
52497
  // Attempt to ray-pick the triangle in local space
52498
52498
 
52499
- let canvasPos;
52500
-
52501
52499
  if (pickResult.canvasPos) {
52502
- canvasPos = pickResult.canvasPos;
52503
- math.canvasPosToLocalRay(canvas.canvas, pickViewMatrix, pickProjMatrix, mesh.worldMatrix, canvasPos, localRayOrigin, localRayDir);
52500
+ math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
52504
52501
 
52505
52502
  } else if (pickResult.origin && pickResult.direction) {
52506
52503
  math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
@@ -52531,6 +52528,12 @@ const pickTriangleSurface = (function () {
52531
52528
  worldPos[1] = tempVec4b[1];
52532
52529
  worldPos[2] = tempVec4b[2];
52533
52530
 
52531
+ if (pickResult.canvasPos && mesh.origin) {
52532
+ worldPos[0] += mesh.origin[0];
52533
+ worldPos[1] += mesh.origin[1];
52534
+ worldPos[2] += mesh.origin[2];
52535
+ }
52536
+
52534
52537
  pickResult.worldPos = worldPos;
52535
52538
 
52536
52539
  // Get View-space cartesian coordinates of the ray-triangle intersection
@@ -4375,7 +4375,7 @@ program.bindTexture(this._uOcclusionTexture,occlusionTexture,1);this._aUV.bindAr
4375
4375
  */},{key:"_touch",value:function _touch(){var internalformat=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var width;var height;/**
4376
4376
  * @type {WebGL2RenderingContext}
4377
4377
  */var gl=this.gl;if(this.size){width=this.size[0];height=this.size[1];}else{width=gl.drawingBufferWidth;height=gl.drawingBufferHeight;}if(this.buffer){if(this.buffer.width===width&&this.buffer.height===height){return;}else{gl.deleteTexture(this.buffer.texture);gl.deleteFramebuffer(this.buffer.framebuf);gl.deleteRenderbuffer(this.buffer.renderbuf);}}var colorTexture=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,colorTexture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);if(!internalformat){gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,width,height,0,gl.RGBA,gl.UNSIGNED_BYTE,null);}else{gl.texStorage2D(gl.TEXTURE_2D,1,internalformat,width,height);}var depthTexture;if(this._hasDepthTexture){depthTexture=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,depthTexture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);gl.texImage2D(gl.TEXTURE_2D,0,gl.DEPTH_COMPONENT32F,width,height,0,gl.DEPTH_COMPONENT,gl.FLOAT,null);}var renderbuf=gl.createRenderbuffer();gl.bindRenderbuffer(gl.RENDERBUFFER,renderbuf);gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_COMPONENT32F,width,height);var framebuf=gl.createFramebuffer();gl.bindFramebuffer(gl.FRAMEBUFFER,framebuf);gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0,gl.TEXTURE_2D,colorTexture,0);if(this._hasDepthTexture){gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.DEPTH_ATTACHMENT,gl.TEXTURE_2D,depthTexture,0);}else{gl.framebufferRenderbuffer(gl.FRAMEBUFFER,gl.DEPTH_ATTACHMENT,gl.RENDERBUFFER,renderbuf);}gl.bindTexture(gl.TEXTURE_2D,null);gl.bindRenderbuffer(gl.RENDERBUFFER,null);gl.bindFramebuffer(gl.FRAMEBUFFER,null);// Verify framebuffer is OK
4378
- gl.bindFramebuffer(gl.FRAMEBUFFER,framebuf);if(!gl.isFramebuffer(framebuf)){throw"Invalid framebuffer";}gl.bindFramebuffer(gl.FRAMEBUFFER,null);var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);switch(status){case gl.FRAMEBUFFER_COMPLETE:break;case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw"Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw"Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw"Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case gl.FRAMEBUFFER_UNSUPPORTED:throw"Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED";default:throw"Incomplete framebuffer: "+status;}this.buffer={framebuf:framebuf,renderbuf:renderbuf,texture:colorTexture,depthTexture:depthTexture,width:width,height:height};this.bound=false;}},{key:"clear",value:function clear(){if(!this.bound){throw"Render buffer not bound";}var gl=this.gl;gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);}},{key:"read",value:function read(pickX,pickY){var glFormat=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var glType=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var arrayType=arguments.length>4&&arguments[4]!==undefined?arguments[4]:Uint8Array;var arrayMultiplier=arguments.length>5&&arguments[5]!==undefined?arguments[5]:4;var x=pickX;var y=(this.buffer.height||this.gl.drawingBufferHeight)-1-pickY;var pix=new arrayType(arrayMultiplier);var gl=this.gl;gl.readPixels(x,y,1,1,glFormat||gl.RGBA,glType||gl.UNSIGNED_BYTE,pix,0);return pix;}},{key:"readArray",value:function readArray(){var glFormat=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var glType=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var arrayType=arguments.length>2&&arguments[2]!==undefined?arguments[2]:Uint8Array;var arrayMultiplier=arguments.length>3&&arguments[3]!==undefined?arguments[3]:4;var pix=new arrayType(this.buffer.width*this.buffer.height*arrayMultiplier);var gl=this.gl;gl.readPixels(0,0,this.buffer.width,this.buffer.height,glFormat||gl.RGBA,glType||gl.UNSIGNED_BYTE,pix,0);return pix;}/**
4378
+ gl.bindFramebuffer(gl.FRAMEBUFFER,framebuf);if(!gl.isFramebuffer(framebuf)){throw"Invalid framebuffer";}gl.bindFramebuffer(gl.FRAMEBUFFER,null);var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);switch(status){case gl.FRAMEBUFFER_COMPLETE:break;case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw"Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw"Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw"Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case gl.FRAMEBUFFER_UNSUPPORTED:throw"Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED";default:throw"Incomplete framebuffer: "+status;}this.buffer={framebuf:framebuf,renderbuf:renderbuf,texture:colorTexture,depthTexture:depthTexture,width:width,height:height};this.bound=false;}},{key:"clear",value:function clear(){if(!this.bound){throw"Render buffer not bound";}var gl=this.gl;gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);}},{key:"read",value:function read(pickX,pickY){var glFormat=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var glType=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var arrayType=arguments.length>4&&arguments[4]!==undefined?arguments[4]:Uint8Array;var arrayMultiplier=arguments.length>5&&arguments[5]!==undefined?arguments[5]:4;var x=pickX;var y=(this.buffer.height||this.gl.drawingBufferHeight)-pickY;var pix=new arrayType(arrayMultiplier);var gl=this.gl;gl.readPixels(x,y,1,1,glFormat||gl.RGBA,glType||gl.UNSIGNED_BYTE,pix,0);return pix;}},{key:"readArray",value:function readArray(){var glFormat=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var glType=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var arrayType=arguments.length>2&&arguments[2]!==undefined?arguments[2]:Uint8Array;var arrayMultiplier=arguments.length>3&&arguments[3]!==undefined?arguments[3]:4;var pix=new arrayType(this.buffer.width*this.buffer.height*arrayMultiplier);var gl=this.gl;gl.readPixels(0,0,this.buffer.width,this.buffer.height,glFormat||gl.RGBA,glType||gl.UNSIGNED_BYTE,pix,0);return pix;}/**
4379
4379
  * Returns an HTMLCanvas containing the contents of the RenderBuffer as an image.
4380
4380
  *
4381
4381
  * - The HTMLCanvas has a CanvasRenderingContext2D.
@@ -12746,11 +12746,11 @@ var _i250=primIndex;// Indicates the first triangle index in the indices array
12746
12746
  var indices=geometry.indices;// Indices into geometry arrays, not into shared VertexBufs
12747
12747
  var _positions4=geometry.positions;var ia3;var ib3;var ic3;if(indices){var ia=indices[_i250+0];var ib=indices[_i250+1];var ic=indices[_i250+2];triangleVertices[0]=ia;triangleVertices[1]=ib;triangleVertices[2]=ic;pickResult.indices=triangleVertices;ia3=ia*3;ib3=ib*3;ic3=ic*3;}else{ia3=_i250*3;ib3=ia3+3;ic3=ib3+3;}positionA[0]=_positions4[ia3+0];positionA[1]=_positions4[ia3+1];positionA[2]=_positions4[ia3+2];positionB[0]=_positions4[ib3+0];positionB[1]=_positions4[ib3+1];positionB[2]=_positions4[ib3+2];positionC[0]=_positions4[ic3+0];positionC[1]=_positions4[ic3+1];positionC[2]=_positions4[ic3+2];if(geometry.compressGeometry){// Decompress vertex positions
12748
12748
  var positionsDecodeMatrix=geometry.positionsDecodeMatrix;if(positionsDecodeMatrix){geometryCompressionUtils.decompressPosition(positionA,positionsDecodeMatrix,positionA);geometryCompressionUtils.decompressPosition(positionB,positionsDecodeMatrix,positionB);geometryCompressionUtils.decompressPosition(positionC,positionsDecodeMatrix,positionC);}}// Attempt to ray-pick the triangle in local space
12749
- var _canvasPos2;if(pickResult.canvasPos){_canvasPos2=pickResult.canvasPos;math.canvasPosToLocalRay(_canvas2.canvas,pickViewMatrix,pickProjMatrix,mesh.worldMatrix,_canvasPos2,localRayOrigin,localRayDir);}else if(pickResult.origin&&pickResult.direction){math.worldRayToLocalRay(mesh.worldMatrix,pickResult.origin,pickResult.direction,localRayOrigin,localRayDir);}math.normalizeVec3(localRayDir);math.rayPlaneIntersect(localRayOrigin,localRayDir,positionA,positionB,positionC,position);// Get Local-space cartesian coordinates of the ray-triangle intersection
12749
+ if(pickResult.canvasPos){math.canvasPosToLocalRay(_canvas2.canvas,mesh.origin?createRTCViewMat(pickViewMatrix,mesh.origin):pickViewMatrix,pickProjMatrix,mesh.worldMatrix,pickResult.canvasPos,localRayOrigin,localRayDir);}else if(pickResult.origin&&pickResult.direction){math.worldRayToLocalRay(mesh.worldMatrix,pickResult.origin,pickResult.direction,localRayOrigin,localRayDir);}math.normalizeVec3(localRayDir);math.rayPlaneIntersect(localRayOrigin,localRayDir,positionA,positionB,positionC,position);// Get Local-space cartesian coordinates of the ray-triangle intersection
12750
12750
  pickResult.localPos=position;pickResult.position=position;// Get interpolated World-space coordinates
12751
12751
  // Need to transform homogeneous coords
12752
12752
  tempVec4a[0]=position[0];tempVec4a[1]=position[1];tempVec4a[2]=position[2];tempVec4a[3]=1;// Get World-space cartesian coordinates of the ray-triangle intersection
12753
- math.transformVec4(mesh.worldMatrix,tempVec4a,tempVec4b);worldPos[0]=tempVec4b[0];worldPos[1]=tempVec4b[1];worldPos[2]=tempVec4b[2];pickResult.worldPos=worldPos;// Get View-space cartesian coordinates of the ray-triangle intersection
12753
+ math.transformVec4(mesh.worldMatrix,tempVec4a,tempVec4b);worldPos[0]=tempVec4b[0];worldPos[1]=tempVec4b[1];worldPos[2]=tempVec4b[2];if(pickResult.canvasPos&&mesh.origin){worldPos[0]+=mesh.origin[0];worldPos[1]+=mesh.origin[1];worldPos[2]+=mesh.origin[2];}pickResult.worldPos=worldPos;// Get View-space cartesian coordinates of the ray-triangle intersection
12754
12754
  math.transformVec4(camera.matrix,tempVec4b,tempVec4c);viewPos[0]=tempVec4c[0];viewPos[1]=tempVec4c[1];viewPos[2]=tempVec4c[2];pickResult.viewPos=viewPos;// Get barycentric coordinates of the ray-triangle intersection
12755
12755
  math.cartesianToBarycentric(position,positionA,positionB,positionC,bary);pickResult.bary=bary;// Get interpolated normal vector
12756
12756
  var normals=geometry.normals;if(normals){if(geometry.compressGeometry){// Decompress vertex normals