@xeokit/xeokit-sdk 2.4.2-beta-11 → 2.4.2-beta-12

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.
@@ -17783,7 +17783,6 @@ const Renderer$1 = function (scene, options) {
17783
17783
 
17784
17784
  let worldPos = null;
17785
17785
  let worldNormal = null;
17786
- let pickable = null;
17787
17786
 
17788
17787
  const middleX = snapRadiusInPixels;
17789
17788
  const middleY = snapRadiusInPixels;
@@ -17813,7 +17812,7 @@ const Renderer$1 = function (scene, options) {
17813
17812
  + (pickPickableResultMiddleXY[2] << 16)
17814
17813
  + (pickPickableResultMiddleXY[3] << 24);
17815
17814
 
17816
- pickable = pickIDs.items[pickID];
17815
+ pickIDs.items[pickID];
17817
17816
  }
17818
17817
 
17819
17818
  // result 2) hi-precision snapped (to vertex/edge) world position
@@ -17909,6 +17908,8 @@ const Renderer$1 = function (scene, options) {
17909
17908
  snappedCanvasPos = scene.camera.projectWorldPos(snappedWorldPos);
17910
17909
  }
17911
17910
 
17911
+ const snappedEntity = (snappedPickable && snappedPickable.delegatePickedEntity) ? snappedPickable.delegatePickedEntity() : snappedPickable;
17912
+
17912
17913
  return {
17913
17914
  snapType,
17914
17915
  snappedToVertex: snapType === "vertex",
@@ -17918,8 +17919,8 @@ const Renderer$1 = function (scene, options) {
17918
17919
  snappedWorldPos,
17919
17920
  snappedWorldNormal,
17920
17921
  snappedCanvasPos,
17921
- snappedEntity: snappedPickable,
17922
- entity: pickable
17922
+ snappedEntity,
17923
+ entity: snappedEntity
17923
17924
  };
17924
17925
  };
17925
17926
 
@@ -17779,7 +17779,6 @@ const Renderer$1 = function (scene, options) {
17779
17779
 
17780
17780
  let worldPos = null;
17781
17781
  let worldNormal = null;
17782
- let pickable = null;
17783
17782
 
17784
17783
  const middleX = snapRadiusInPixels;
17785
17784
  const middleY = snapRadiusInPixels;
@@ -17809,7 +17808,7 @@ const Renderer$1 = function (scene, options) {
17809
17808
  + (pickPickableResultMiddleXY[2] << 16)
17810
17809
  + (pickPickableResultMiddleXY[3] << 24);
17811
17810
 
17812
- pickable = pickIDs.items[pickID];
17811
+ pickIDs.items[pickID];
17813
17812
  }
17814
17813
 
17815
17814
  // result 2) hi-precision snapped (to vertex/edge) world position
@@ -17905,6 +17904,8 @@ const Renderer$1 = function (scene, options) {
17905
17904
  snappedCanvasPos = scene.camera.projectWorldPos(snappedWorldPos);
17906
17905
  }
17907
17906
 
17907
+ const snappedEntity = (snappedPickable && snappedPickable.delegatePickedEntity) ? snappedPickable.delegatePickedEntity() : snappedPickable;
17908
+
17908
17909
  return {
17909
17910
  snapType,
17910
17911
  snappedToVertex: snapType === "vertex",
@@ -17914,8 +17915,8 @@ const Renderer$1 = function (scene, options) {
17914
17915
  snappedWorldPos,
17915
17916
  snappedWorldNormal,
17916
17917
  snappedCanvasPos,
17917
- snappedEntity: snappedPickable,
17918
- entity: pickable
17918
+ snappedEntity,
17919
+ entity: snappedEntity
17919
17920
  };
17920
17921
  };
17921
17922
 
@@ -4451,10 +4451,10 @@ drawable.setPickMatrices(pickViewMatrix,pickProjMatrix);}}}}// a) init z-buffer
4451
4451
  gl.drawBuffers([gl.COLOR_ATTACHMENT0,gl.COLOR_ATTACHMENT1,gl.COLOR_ATTACHMENT2]);var layerParamsSurface=snapInitDepthBuf(frameCtx);// b) snap-pick
4452
4452
  var layerParamsSnap=[];frameCtx.snapPickLayerParams=layerParamsSnap;gl.depthMask(false);gl.drawBuffers([gl.COLOR_ATTACHMENT0]);if(snapToVertex&&snapToEdge){frameCtx.snapMode="edge";snapPickDrawSnapDepths(frameCtx);frameCtx.snapMode="vertex";frameCtx.snapPickLayerNumber++;snapPickDrawSnapDepths(frameCtx);}else{frameCtx.snapMode=snapToVertex?"vertex":"edge";snapPickDrawSnapDepths(frameCtx);}gl.depthMask(true);// Read and decode the snapped coordinates
4453
4453
  var snapPickResultArray=vertexPickBuffer.readArray(gl.RGBA_INTEGER,gl.INT,Int32Array,4);var snapPickNormalResultArray=vertexPickBuffer.readArray(gl.RGBA_INTEGER,gl.INT,Int32Array,4,1);var snapPickIdResultArray=vertexPickBuffer.readArray(gl.RGBA_INTEGER,gl.UNSIGNED_INT,Uint32Array,4,2);vertexPickBuffer.unbind();// result 1) regular hi-precision world position
4454
- var worldPos=null;var worldNormal=null;var pickable=null;var middleX=snapRadiusInPixels;var middleY=snapRadiusInPixels;var middleIndex=middleX*4+middleY*vertexPickBuffer.size[0]*4;var pickResultMiddleXY=snapPickResultArray.slice(middleIndex,middleIndex+4);var pickNormalResultMiddleXY=snapPickNormalResultArray.slice(middleIndex,middleIndex+4);var pickPickableResultMiddleXY=snapPickIdResultArray.slice(middleIndex,middleIndex+4);if(pickResultMiddleXY[3]!==0){var pickedLayerParmasSurface=layerParamsSurface[Math.abs(pickResultMiddleXY[3])%layerParamsSurface.length];var _origin2=pickedLayerParmasSurface.origin;var _scale=pickedLayerParmasSurface.coordinateScale;worldPos=[pickResultMiddleXY[0]*_scale[0]+_origin2[0],pickResultMiddleXY[1]*_scale[1]+_origin2[1],pickResultMiddleXY[2]*_scale[2]+_origin2[2]];worldNormal=math.normalizeVec3([pickNormalResultMiddleXY[0]/math.MAX_INT,pickNormalResultMiddleXY[1]/math.MAX_INT,pickNormalResultMiddleXY[2]/math.MAX_INT]);var pickID=pickPickableResultMiddleXY[0]+(pickPickableResultMiddleXY[1]<<8)+(pickPickableResultMiddleXY[2]<<16)+(pickPickableResultMiddleXY[3]<<24);pickable=pickIDs.items[pickID];}// result 2) hi-precision snapped (to vertex/edge) world position
4454
+ var worldPos=null;var worldNormal=null;var middleX=snapRadiusInPixels;var middleY=snapRadiusInPixels;var middleIndex=middleX*4+middleY*vertexPickBuffer.size[0]*4;var pickResultMiddleXY=snapPickResultArray.slice(middleIndex,middleIndex+4);var pickNormalResultMiddleXY=snapPickNormalResultArray.slice(middleIndex,middleIndex+4);var pickPickableResultMiddleXY=snapPickIdResultArray.slice(middleIndex,middleIndex+4);if(pickResultMiddleXY[3]!==0){var pickedLayerParmasSurface=layerParamsSurface[Math.abs(pickResultMiddleXY[3])%layerParamsSurface.length];var _origin2=pickedLayerParmasSurface.origin;var _scale=pickedLayerParmasSurface.coordinateScale;worldPos=[pickResultMiddleXY[0]*_scale[0]+_origin2[0],pickResultMiddleXY[1]*_scale[1]+_origin2[1],pickResultMiddleXY[2]*_scale[2]+_origin2[2]];worldNormal=math.normalizeVec3([pickNormalResultMiddleXY[0]/math.MAX_INT,pickNormalResultMiddleXY[1]/math.MAX_INT,pickNormalResultMiddleXY[2]/math.MAX_INT]);var pickID=pickPickableResultMiddleXY[0]+(pickPickableResultMiddleXY[1]<<8)+(pickPickableResultMiddleXY[2]<<16)+(pickPickableResultMiddleXY[3]<<24);pickIDs.items[pickID];}// result 2) hi-precision snapped (to vertex/edge) world position
4455
4455
  var snapPickResult=[];for(var _i69=0;_i69<snapPickResultArray.length;_i69+=4){if(snapPickResultArray[_i69+3]>0){var pixelNumber=Math.floor(_i69/4);var w=vertexPickBuffer.size[0];var x=pixelNumber%w-Math.floor(w/2);var y=Math.floor(pixelNumber/w)-Math.floor(w/2);var dist=Math.sqrt(Math.pow(x,2)+Math.pow(y,2));snapPickResult.push({x:x,y:y,dist:dist,isVertex:snapToVertex&&snapToEdge?snapPickResultArray[_i69+3]>layerParamsSnap.length/2:snapToVertex,result:[snapPickResultArray[_i69+0],snapPickResultArray[_i69+1],snapPickResultArray[_i69+2],snapPickResultArray[_i69+3]],normal:[snapPickNormalResultArray[_i69+0],snapPickNormalResultArray[_i69+1],snapPickNormalResultArray[_i69+2],snapPickNormalResultArray[_i69+3]],id:[snapPickIdResultArray[_i69+0],snapPickIdResultArray[_i69+1],snapPickIdResultArray[_i69+2],snapPickIdResultArray[_i69+3]]});}}var snappedWorldPos=null;var snappedWorldNormal=null;var snappedPickable=null;var snapType=null;if(snapPickResult.length>0){// vertex snap first, then edge snap
4456
4456
  snapPickResult.sort(function(a,b){if(a.isVertex!==b.isVertex){return a.isVertex?-1:1;}else{return a.dist-b.dist;}});snapType=snapPickResult[0].isVertex?"vertex":"edge";var snapPick=snapPickResult[0].result;var snapPickNormal=snapPickResult[0].normal;var snapPickId=snapPickResult[0].id;var pickedLayerParmas=layerParamsSnap[snapPick[3]];var _origin3=pickedLayerParmas.origin;var _scale2=pickedLayerParmas.coordinateScale;snappedWorldNormal=math.normalizeVec3([snapPickNormal[0]/math.MAX_INT,snapPickNormal[1]/math.MAX_INT,snapPickNormal[2]/math.MAX_INT]);snappedWorldPos=[snapPick[0]*_scale2[0]+_origin3[0],snapPick[1]*_scale2[1]+_origin3[1],snapPick[2]*_scale2[2]+_origin3[2]];snappedPickable=pickIDs.items[snapPickId[0]+(snapPickId[1]<<8)+(snapPickId[2]<<16)+(snapPickId[3]<<24)];}if(null===worldPos&&null==snappedWorldPos){// If neither regular pick or snap pick, return null
4457
- return null;}var snappedCanvasPos=null;if(null!==snappedWorldPos){snappedCanvasPos=scene.camera.projectWorldPos(snappedWorldPos);}return{snapType:snapType,snappedToVertex:snapType==="vertex",snappedToEdge:snapType==="edge",worldPos:worldPos,worldNormal:worldNormal,snappedWorldPos:snappedWorldPos,snappedWorldNormal:snappedWorldNormal,snappedCanvasPos:snappedCanvasPos,snappedEntity:snappedPickable,entity:pickable};};function unpackDepth(depthZ){var vec=[depthZ[0]/256.0,depthZ[1]/256.0,depthZ[2]/256.0,depthZ[3]/256.0];var bitShift=[1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0];return math.dotVec4(vec,bitShift);}function gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
4457
+ return null;}var snappedCanvasPos=null;if(null!==snappedWorldPos){snappedCanvasPos=scene.camera.projectWorldPos(snappedWorldPos);}var snappedEntity=snappedPickable&&snappedPickable.delegatePickedEntity?snappedPickable.delegatePickedEntity():snappedPickable;return{snapType:snapType,snappedToVertex:snapType==="vertex",snappedToEdge:snapType==="edge",worldPos:worldPos,worldNormal:worldNormal,snappedWorldPos:snappedWorldPos,snappedWorldNormal:snappedWorldNormal,snappedCanvasPos:snappedCanvasPos,snappedEntity:snappedEntity,entity:snappedEntity};};function unpackDepth(depthZ){var vec=[depthZ[0]/256.0,depthZ[1]/256.0,depthZ[2]/256.0,depthZ[3]/256.0];var bitShift=[1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0];return math.dotVec4(vec,bitShift);}function gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
4458
4458
  frameCtx.pickOrigin=pickResult.origin;frameCtx.pickViewMatrix=pickViewMatrix;frameCtx.pickProjMatrix=pickProjMatrix;frameCtx.pickClipPos=[getClipPosX(canvasPos[0]*resolutionScale,gl.drawingBufferWidth),getClipPosY(canvasPos[1]*resolutionScale,gl.drawingBufferHeight)];var pickNormalBuffer=renderBufferManager.getRenderBuffer("pick-normal",{size:[3,3]});pickNormalBuffer.bind(gl.RGBA32I);gl.viewport(0,0,pickNormalBuffer.size[0],pickNormalBuffer.size[1]);gl.enable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);gl.clear(gl.DEPTH_BUFFER_BIT);gl.clearBufferiv(gl.COLOR,0,new Int32Array([0,0,0,0]));pickable.drawPickNormals(frameCtx);// Draw color-encoded fragment World-space normals
4459
4459
  var pix=pickNormalBuffer.read(1,1,gl.RGBA_INTEGER,gl.INT,Int32Array,4);pickNormalBuffer.unbind();var worldNormal=[pix[0]/math.MAX_INT,pix[1]/math.MAX_INT,pix[2]/math.MAX_INT];math.normalizeVec3(worldNormal);pickResult.worldNormal=worldNormal;}/**
4460
4460
  * Adds a {@link Marker} for occlusion testing.