@antv/g 5.16.7 → 5.16.9
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/dist/index.umd.js +108 -107
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -7528,10 +7528,10 @@
|
|
|
7528
7528
|
// return `${value}${unitOrName}`;
|
|
7529
7529
|
// },
|
|
7530
7530
|
// );
|
|
7531
|
-
var getOrCreateUnitValue=function getOrCreateUnitValue(value,unitOrName){if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}return new CSSUnitValue(value,unitOrName);};var canvasMap={};var defaultCanvasIdCounter=0;/**
|
|
7531
|
+
var getOrCreateUnitValue=function getOrCreateUnitValue(value,unitOrName){if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}return new CSSUnitValue(value,unitOrName);};var PECENTAGE_50=new CSSUnitValue(50,'%');var canvasMap={};var defaultCanvasIdCounter=0;/**
|
|
7532
7532
|
* destroy existed canvas with the same id
|
|
7533
7533
|
*/function cleanExistedCanvas(container,canvas){if(container){var id=typeof container==='string'?container:container.id||defaultCanvasIdCounter++;if(canvasMap[id]){canvasMap[id].destroy();}canvasMap[id]=canvas;}}var isBrowser=typeof window!=='undefined'&&typeof window.document!=='undefined';function sortByZIndex(o1,o2){var zIndex1=Number(o1.parsedStyle.zIndex);var zIndex2=Number(o2.parsedStyle.zIndex);if(zIndex1===zIndex2){// return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
|
|
7534
|
-
var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$
|
|
7534
|
+
var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$parsedStyle;var clipPath=(_el$parsedStyle=el.parsedStyle)===null||_el$parsedStyle===void 0?void 0:_el$parsedStyle.clipPath;if(clipPath)return el;el=el.parentElement;}while(el!==null);return null;}var PX_SUFFIX='px';function setDOMSize($el,width,height){if(isBrowser&&$el.style){$el.style.width=width+PX_SUFFIX;$el.style.height=height+PX_SUFFIX;}}function getStyle($el,property){if(isBrowser){return document.defaultView.getComputedStyle($el,null).getPropertyValue(property);}}function getWidth($el){var width=getStyle($el,'width');if(width==='auto'){return $el.offsetWidth;}return parseFloat(width);}function getHeight($el){var height=getStyle($el,'height');if(height==='auto'){return $el.offsetHeight;}return parseFloat(height);}var ERROR_MSG_METHOD_NOT_IMPLEMENTED='Method not implemented.';var ERROR_MSG_USE_DOCUMENT_ELEMENT='Use document.documentElement instead.';var ERROR_MSG_APPEND_DESTROYED_ELEMENT='Cannot append a destroyed element.';// borrow from hammer.js
|
|
7535
7535
|
var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'};function copyVec3(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a;}function subVec3(o,a,b){o[0]=a[0]-b[0];o[1]=a[1]-b[1];o[2]=a[2]-b[2];return o;}function addVec3(o,a,b){o[0]=a[0]+b[0];o[1]=a[1]+b[1];o[2]=a[2]+b[2];return o;}function scaleVec3(o,a,b){o[0]=a[0]*b;o[1]=a[1]*b;o[2]=a[2]*b;return o;}function maxVec3(o,a,b){o[0]=Math.max(a[0],b[0]);o[1]=Math.max(a[1],b[1]);o[2]=Math.max(a[2],b[2]);return o;}function minVec3(o,a,b){o[0]=Math.min(a[0],b[0]);o[1]=Math.min(a[1],b[1]);o[2]=Math.min(a[2],b[2]);return o;}function getAngle$1(angle){if(angle===undefined){return 0;}else if(angle>360||angle<-360){return angle%360;}return angle;}function createVec3(x,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(Array.isArray(x)&&x.length===3){return clone$1(x);}if(isNumber(x)){return fromValues$2(x,y,z);}return fromValues$2(x[0],x[1]||y,x[2]||z);}function deg2rad(deg){return deg*(Math.PI/180);}function rad2deg(rad){return rad*(180/Math.PI);}function grad2deg(grads){grads=grads%400;if(grads<0){grads+=400;}return grads/400*360;}function deg2turn(deg){return deg/360;}function turn2deg(turn){return 360*turn;}function getEulerFromQuat(out,quat){var x=quat[0];var y=quat[1];var z=quat[2];var w=quat[3];var x2=x*x;var y2=y*y;var z2=z*z;var w2=w*w;var unit=x2+y2+z2+w2;var test=x*w-y*z;if(test>0.499995*unit){// TODO: Use glmatrix.EPSILON
|
|
7536
7536
|
// singularity at the north pole
|
|
7537
7537
|
out[0]=Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else if(test<-0.499995*unit){//TODO: Use glmatrix.EPSILON
|
|
@@ -7781,8 +7781,7 @@
|
|
|
7781
7781
|
// const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
|
|
7782
7782
|
var fontSizeString=isNumber(fontSize)&&fontSize+"px"||'16px';// Clean-up fontFamily property by quoting each font name
|
|
7783
7783
|
// this will support font names with spaces
|
|
7784
|
-
//
|
|
7785
|
-
var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
|
|
7784
|
+
var fontFamilies=fontFamily.split(',');for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
|
|
7786
7785
|
var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
|
|
7787
7786
|
if(!stringRegExp.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}/**
|
|
7788
7787
|
* Thanks for following contributor of codes
|
|
@@ -7816,87 +7815,7 @@
|
|
|
7816
7815
|
var g=parseGradient$1(colorStr);if(g){return g;}// constants
|
|
7817
7816
|
var color$1=color(colorStr);var rgba=[0,0,0,0];if(color$1!==null){rgba[0]=color$1.r||0;rgba[1]=color$1.g||0;rgba[2]=color$1.b||0;rgba[3]=color$1.opacity;}// return new CSSRGB(...rgba);
|
|
7818
7817
|
return getOrCreateRGBA.apply(void 0,rgba);});function mergeColors(left,right){// only support constant value, exclude gradient & pattern
|
|
7819
|
-
if(!isCSSRGB(left)||!isCSSRGB(right)){return;}return [[Number(left.r),Number(left.g),Number(left.b),Number(left.alpha)],[Number(right.r),Number(right.g),Number(right.b),Number(right.alpha)],function(color){var rgba=color.slice();if(rgba[3]){for(var i=0;i<3;i++){rgba[i]=Math.round(clamp(rgba[i],0,255));}}rgba[3]=clamp(rgba[3],0,1);return "rgba("+rgba.join(',')+")";}];}/**
|
|
7820
|
-
* Axis-Aligned Bounding Box
|
|
7821
|
-
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
7822
|
-
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
7823
|
-
*/var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};// center: vec3 = vec3.create();
|
|
7824
|
-
// halfExtents: vec3 = vec3.create();
|
|
7825
|
-
// min: vec3 = vec3.create();
|
|
7826
|
-
// max: vec3 = vec3.create();
|
|
7827
|
-
function AABB(center,halfExtents){if(center===void 0){center=[0,0,0];}if(halfExtents===void 0){halfExtents=[0,0,0];}this.center=[0,0,0];this.halfExtents=[0,0,0];this.min=[0,0,0];this.max=[0,0,0];this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){copyVec3(this.center,center);copyVec3(this.halfExtents,halfExtents);subVec3(this.min,this.center,this.halfExtents);addVec3(this.max,this.center,this.halfExtents);// vec3.copy(this.center, center);
|
|
7828
|
-
// vec3.copy(this.halfExtents, halfExtents);
|
|
7829
|
-
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
7830
|
-
// vec3.add(this.max, this.center, this.halfExtents);
|
|
7831
|
-
};_proto.setMinMax=function setMinMax(min,max){// vec3.add(this.center, max, min);
|
|
7832
|
-
// vec3.scale(this.center, this.center, 0.5);
|
|
7833
|
-
// vec3.sub(this.halfExtents, max, min);
|
|
7834
|
-
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
7835
|
-
// vec3.copy(this.min, min);
|
|
7836
|
-
// vec3.copy(this.max, max);
|
|
7837
|
-
addVec3(this.center,max,min);scaleVec3(this.center,this.center,0.5);subVec3(this.halfExtents,max,min);scaleVec3(this.halfExtents,this.halfExtents,0.5);copyVec3(this.min,min);copyVec3(this.max,max);};_proto.getMin=function getMin(){return this.min;};_proto.getMax=function getMax(){return this.max;};_proto.add=function add(aabb){if(AABB.isEmpty(aabb)){return;}if(AABB.isEmpty(this)){this.setMinMax(aabb.getMin(),aabb.getMax());return;}var tc=this.center;var tcx=tc[0];var tcy=tc[1];var tcz=tc[2];var th=this.halfExtents;var thx=th[0];var thy=th[1];var thz=th[2];var tminx=tcx-thx;var tmaxx=tcx+thx;var tminy=tcy-thy;var tmaxy=tcy+thy;var tminz=tcz-thz;var tmaxz=tcz+thz;var oc=aabb.center;var ocx=oc[0];var ocy=oc[1];var ocz=oc[2];var oh=aabb.halfExtents;var ohx=oh[0];var ohy=oh[1];var ohz=oh[2];var ominx=ocx-ohx;var omaxx=ocx+ohx;var ominy=ocy-ohy;var omaxy=ocy+ohy;var ominz=ocz-ohz;var omaxz=ocz+ohz;if(ominx<tminx){tminx=ominx;}if(omaxx>tmaxx){tmaxx=omaxx;}if(ominy<tminy){tminy=ominy;}if(omaxy>tmaxy){tmaxy=omaxy;}if(ominz<tminz){tminz=ominz;}if(omaxz>tmaxz){tmaxz=omaxz;}tc[0]=(tminx+tmaxx)*0.5;tc[1]=(tminy+tmaxy)*0.5;tc[2]=(tminz+tmaxz)*0.5;th[0]=(tmaxx-tminx)*0.5;th[1]=(tmaxy-tminy)*0.5;th[2]=(tmaxz-tminz)*0.5;this.min[0]=tminx;this.min[1]=tminy;this.min[2]=tminz;this.max[0]=tmaxx;this.max[1]=tmaxy;this.max[2]=tmaxz;};_proto.setFromTransformedAABB=function setFromTransformedAABB(aabb,m){var bc=this.center;var br=this.halfExtents;var ac=aabb.center;var ar=aabb.halfExtents;var mx0=m[0];var mx1=m[4];var mx2=m[8];var my0=m[1];var my1=m[5];var my2=m[9];var mz0=m[2];var mz1=m[6];var mz2=m[10];var mx0a=Math.abs(mx0);var mx1a=Math.abs(mx1);var mx2a=Math.abs(mx2);var my0a=Math.abs(my0);var my1a=Math.abs(my1);var my2a=Math.abs(my2);var mz0a=Math.abs(mz0);var mz1a=Math.abs(mz1);var mz2a=Math.abs(mz2);bc[0]=m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2];bc[1]=m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2];bc[2]=m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2];// vec3.set(
|
|
7838
|
-
// bc,
|
|
7839
|
-
// m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
|
|
7840
|
-
// m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
|
|
7841
|
-
// m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
|
|
7842
|
-
// );
|
|
7843
|
-
br[0]=mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2];br[1]=my0a*ar[0]+my1a*ar[1]+my2a*ar[2];br[2]=mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2];// vec3.set(
|
|
7844
|
-
// br,
|
|
7845
|
-
// mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
|
|
7846
|
-
// my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
|
|
7847
|
-
// mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
|
|
7848
|
-
// );
|
|
7849
|
-
// this.min = vec3.sub(this.min, bc, br);
|
|
7850
|
-
// this.max = vec3.add(this.max, bc, br);
|
|
7851
|
-
subVec3(this.min,bc,br);addVec3(this.max,bc,br);};_proto.intersects=function intersects(aabb){var aMax=this.getMax();var aMin=this.getMin();var bMax=aabb.getMax();var bMin=aabb.getMin();return aMin[0]<=bMax[0]&&aMax[0]>=bMin[0]&&aMin[1]<=bMax[1]&&aMax[1]>=bMin[1]&&aMin[2]<=bMax[2]&&aMax[2]>=bMin[2];};_proto.intersection=function intersection(aabb){if(!this.intersects(aabb)){return null;}var intersection=new AABB();// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
7852
|
-
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
7853
|
-
var min=maxVec3([0,0,0],this.getMin(),aabb.getMin());var max=minVec3([0,0,0],this.getMax(),aabb.getMax());intersection.setMinMax(min,max);return intersection;}// containsPoint(point: vec3) {
|
|
7854
|
-
// const min = this.getMin();
|
|
7855
|
-
// const max = this.getMax();
|
|
7856
|
-
// return !(
|
|
7857
|
-
// point[0] < min[0] ||
|
|
7858
|
-
// point[0] > max[0] ||
|
|
7859
|
-
// point[1] < min[1] ||
|
|
7860
|
-
// point[1] > max[1] ||
|
|
7861
|
-
// point[2] < min[2] ||
|
|
7862
|
-
// point[2] > max[2]
|
|
7863
|
-
// );
|
|
7864
|
-
// }
|
|
7865
|
-
/**
|
|
7866
|
-
* get n-vertex
|
|
7867
|
-
* @param plane plane of CullingVolume
|
|
7868
|
-
*/;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.min);// return vec3.copy(vec3.create(), this.min);
|
|
7869
|
-
}else if(plane.pnVertexFlag===0x110){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
7870
|
-
}else if(plane.pnVertexFlag===0x101){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
7871
|
-
}else if(plane.pnVertexFlag===0x100){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
7872
|
-
}else if(plane.pnVertexFlag===0x011){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
7873
|
-
}else if(plane.pnVertexFlag===0x010){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
7874
|
-
}else if(plane.pnVertexFlag===0x001){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
7875
|
-
}else {return [this.max[0],this.max[1],this.max[2]];// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
7876
|
-
}}/**
|
|
7877
|
-
* get p-vertex
|
|
7878
|
-
* @param plane plane of CullingVolume
|
|
7879
|
-
*/;_proto.getPositiveFarPoint=function getPositiveFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.max);// return vec3.copy(vec3.create(), this.max);
|
|
7880
|
-
}else if(plane.pnVertexFlag===0x110){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
7881
|
-
}else if(plane.pnVertexFlag===0x101){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
7882
|
-
}else if(plane.pnVertexFlag===0x100){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
7883
|
-
}else if(plane.pnVertexFlag===0x011){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
7884
|
-
}else if(plane.pnVertexFlag===0x010){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
7885
|
-
}else if(plane.pnVertexFlag===0x001){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
7886
|
-
}else {return [this.min[0],this.min[1],this.min[2]];// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
7887
|
-
}};return AABB;}();var Plane=/*#__PURE__*/function(){/**
|
|
7888
|
-
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
7889
|
-
*/function Plane(distance,normal){this.distance=void 0;this.normal=void 0;this.pnVertexFlag=void 0;this.distance=distance||0;this.normal=normal||fromValues$2(0,1,0);this.updatePNVertexFlag();}var _proto=Plane.prototype;_proto.updatePNVertexFlag=function updatePNVertexFlag(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0);};_proto.distanceToPoint=function distanceToPoint(point){return dot(point,this.normal)-this.distance;};_proto.normalize=function normalize(){var invLen=1/len(this.normal);scale$1(this.normal,this.normal,invLen);this.distance*=invLen;};_proto.intersectsLine=function intersectsLine(start,end,point){var d0=this.distanceToPoint(start);var d1=this.distanceToPoint(end);var t=d0/(d0-d1);var intersects=t>=0&&t<=1;if(intersects&&point){lerp(point,start,end,t);}return intersects;};return Plane;}();(function(Mask){Mask[Mask["OUTSIDE"]=4294967295]="OUTSIDE";Mask[Mask["INSIDE"]=0]="INSIDE";Mask[Mask["INDETERMINATE"]=2147483647]="INDETERMINATE";})(exports.Mask||(exports.Mask={}));var Frustum=/*#__PURE__*/function(){function Frustum(planes){this.planes=[];if(planes){this.planes=planes;}else {for(var i=0;i<6;i++){this.planes.push(new Plane());}}}/**
|
|
7890
|
-
* extract 6 planes from projectionMatrix
|
|
7891
|
-
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
7892
|
-
*/var _proto=Frustum.prototype;_proto.extractFromVPMatrix=function extractFromVPMatrix(projectionMatrix){// @ts-ignore
|
|
7893
|
-
var m0=projectionMatrix[0],m1=projectionMatrix[1],m2=projectionMatrix[2],m3=projectionMatrix[3],m4=projectionMatrix[4],m5=projectionMatrix[5],m6=projectionMatrix[6],m7=projectionMatrix[7],m8=projectionMatrix[8],m9=projectionMatrix[9],m10=projectionMatrix[10],m11=projectionMatrix[11],m12=projectionMatrix[12],m13=projectionMatrix[13],m14=projectionMatrix[14],m15=projectionMatrix[15];// right
|
|
7894
|
-
set$1(this.planes[0].normal,m3-m0,m7-m4,m11-m8);this.planes[0].distance=m15-m12;// left
|
|
7895
|
-
set$1(this.planes[1].normal,m3+m0,m7+m4,m11+m8);this.planes[1].distance=m15+m12;// bottom
|
|
7896
|
-
set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
|
|
7897
|
-
set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
|
|
7898
|
-
set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
|
|
7899
|
-
set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();function parseDimension(unitRegExp,string){if(isNil(string)){return getOrCreateUnitValue(0,'px');}string=(""+string).trim().toLowerCase();if(isFinite(Number(string))){if('px'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'px');}else if('deg'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'deg');}}var matchedUnits=[];string=string.replace(unitRegExp,function(match){matchedUnits.push(match);return 'U'+match;});var taggedUnitRegExp='U('+unitRegExp.source+')';return matchedUnits.map(function(unit){return getOrCreateUnitValue(Number(string.replace(new RegExp('U'+unit,'g'),'').replace(new RegExp(taggedUnitRegExp,'g'),'*0')),unit);})[0];}/**
|
|
7818
|
+
if(!isCSSRGB(left)||!isCSSRGB(right)){return;}return [[Number(left.r),Number(left.g),Number(left.b),Number(left.alpha)],[Number(right.r),Number(right.g),Number(right.b),Number(right.alpha)],function(color){var rgba=color.slice();if(rgba[3]){for(var i=0;i<3;i++){rgba[i]=Math.round(clamp(rgba[i],0,255));}}rgba[3]=clamp(rgba[3],0,1);return "rgba("+rgba.join(',')+")";}];}function parseDimension(unitRegExp,string){if(isNil(string)){return getOrCreateUnitValue(0,'px');}string=(""+string).trim().toLowerCase();if(isFinite(Number(string))){if('px'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'px');}else if('deg'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'deg');}}var matchedUnits=[];string=string.replace(unitRegExp,function(match){matchedUnits.push(match);return 'U'+match;});var taggedUnitRegExp='U('+unitRegExp.source+')';return matchedUnits.map(function(unit){return getOrCreateUnitValue(Number(string.replace(new RegExp('U'+unit,'g'),'').replace(new RegExp(taggedUnitRegExp,'g'),'*0')),unit);})[0];}/**
|
|
7900
7819
|
* <length>
|
|
7901
7820
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
|
|
7902
7821
|
* length with only absolute unit, eg. 1px
|
|
@@ -7949,8 +7868,8 @@
|
|
|
7949
7868
|
// },
|
|
7950
7869
|
// ];
|
|
7951
7870
|
// }
|
|
7952
|
-
function convertPercentUnit(valueWithUnit,vec3Index,target){if(valueWithUnit.unit===exports.UnitType.kPixels){return Number(valueWithUnit.value);}else if(valueWithUnit.unit===exports.UnitType.kPercentage&&target){var bounds=target.nodeName===exports.Shape.GROUP?target.getLocalBounds():// : target.getGeometryBounds();
|
|
7953
|
-
target.geometry.contentBounds;
|
|
7871
|
+
function convertPercentUnit(valueWithUnit,vec3Index,target){if(valueWithUnit.value===0){return 0;}if(valueWithUnit.unit===exports.UnitType.kPixels){return Number(valueWithUnit.value);}else if(valueWithUnit.unit===exports.UnitType.kPercentage&&target){var bounds=target.nodeName===exports.Shape.GROUP?target.getLocalBounds():// : target.getGeometryBounds();
|
|
7872
|
+
target.geometry.contentBounds;return valueWithUnit.value/100*bounds.halfExtents[vec3Index]*2;}return 0;}var parseParam=function parseParam(css){return parseDimension(/deg|rad|grad|turn|px|%/g,css);};var supportedFilters=['blur','brightness','drop-shadow','contrast','grayscale','sepia','saturate','hue-rotate','invert'];function parseFilter(filterStr){if(filterStr===void 0){filterStr='';}filterStr=filterStr.toLowerCase().trim();if(filterStr==='none'){return [];}var filterRegExp=/\s*([\w-]+)\(([^)]*)\)/g;var result=[];var match;var prevLastIndex=0;while(match=filterRegExp.exec(filterStr)){if(match.index!==prevLastIndex){return [];}prevLastIndex=match.index+match[0].length;if(supportedFilters.indexOf(match[1])>-1){result.push({name:match[1],params:match[2].split(' ').map(function(p){return parseParam(p)||parseColor(p);})});}if(filterRegExp.lastIndex===filterStr.length){return result;}}return [];}function numberToString(x){// scale(0.00000001) -> scale(0)
|
|
7954
7873
|
// return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
|
|
7955
7874
|
return x.toString();}/**
|
|
7956
7875
|
* parse string or number to CSSUnitValue(numeric)
|
|
@@ -8073,7 +7992,87 @@
|
|
|
8073
7992
|
cloned.style.isMarker=true;}return cloned;};return CSSPropertyMarker;}();var CSSPropertyNumber=/*#__PURE__*/function(){function CSSPropertyNumber(){this.mixer=mergeNumbers;this.parser=parseNumber;this.parserWithCSSDisabled=null;}var _proto=CSSPropertyNumber.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyNumber;}();var CSSPropertyOffsetDistance=/*#__PURE__*/function(){function CSSPropertyOffsetDistance(){this.parser=parseNumber;this.parserWithCSSDisabled=null;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOffsetDistance.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};_proto.postProcessor=function postProcessor(object){var _object$parsedStyle=object.parsedStyle,offsetPath=_object$parsedStyle.offsetPath,offsetDistance=_object$parsedStyle.offsetDistance;if(!offsetPath){return;}var nodeName=offsetPath.nodeName;if(nodeName===exports.Shape.LINE||nodeName===exports.Shape.PATH||nodeName===exports.Shape.POLYLINE){// set position in world space
|
|
8074
7993
|
var point=offsetPath.getPoint(offsetDistance);if(point){object.parsedStyle.defX=point.x;object.parsedStyle.defY=point.y;object.setLocalPosition(point.x,point.y);}}};return CSSPropertyOffsetDistance;}();/**
|
|
8075
7994
|
* opacity
|
|
8076
|
-
*/var CSSPropertyOpacity=/*#__PURE__*/function(){function CSSPropertyOpacity(){this.parser=parseNumber;this.parserWithCSSDisabled=null;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOpacity.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyOpacity;}()
|
|
7995
|
+
*/var CSSPropertyOpacity=/*#__PURE__*/function(){function CSSPropertyOpacity(){this.parser=parseNumber;this.parserWithCSSDisabled=null;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOpacity.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyOpacity;}();/**
|
|
7996
|
+
* Axis-Aligned Bounding Box
|
|
7997
|
+
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
7998
|
+
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
7999
|
+
*/var AABB=/*#__PURE__*/function(){function AABB(){this.center=[0,0,0];this.halfExtents=[0,0,0];this.min=[0,0,0];this.max=[0,0,0];}AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};var _proto=AABB.prototype;// center: vec3 = vec3.create();
|
|
8000
|
+
// halfExtents: vec3 = vec3.create();
|
|
8001
|
+
// min: vec3 = vec3.create();
|
|
8002
|
+
// max: vec3 = vec3.create();
|
|
8003
|
+
_proto.update=function update(center,halfExtents){copyVec3(this.center,center);copyVec3(this.halfExtents,halfExtents);subVec3(this.min,this.center,this.halfExtents);addVec3(this.max,this.center,this.halfExtents);// vec3.copy(this.center, center);
|
|
8004
|
+
// vec3.copy(this.halfExtents, halfExtents);
|
|
8005
|
+
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
8006
|
+
// vec3.add(this.max, this.center, this.halfExtents);
|
|
8007
|
+
};_proto.setMinMax=function setMinMax(min,max){// vec3.add(this.center, max, min);
|
|
8008
|
+
// vec3.scale(this.center, this.center, 0.5);
|
|
8009
|
+
// vec3.sub(this.halfExtents, max, min);
|
|
8010
|
+
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
8011
|
+
// vec3.copy(this.min, min);
|
|
8012
|
+
// vec3.copy(this.max, max);
|
|
8013
|
+
addVec3(this.center,max,min);scaleVec3(this.center,this.center,0.5);subVec3(this.halfExtents,max,min);scaleVec3(this.halfExtents,this.halfExtents,0.5);copyVec3(this.min,min);copyVec3(this.max,max);};_proto.getMin=function getMin(){return this.min;};_proto.getMax=function getMax(){return this.max;};_proto.add=function add(aabb){if(AABB.isEmpty(aabb)){return;}if(AABB.isEmpty(this)){this.setMinMax(aabb.getMin(),aabb.getMax());return;}var tc=this.center;var tcx=tc[0];var tcy=tc[1];var tcz=tc[2];var th=this.halfExtents;var thx=th[0];var thy=th[1];var thz=th[2];var tminx=tcx-thx;var tmaxx=tcx+thx;var tminy=tcy-thy;var tmaxy=tcy+thy;var tminz=tcz-thz;var tmaxz=tcz+thz;var oc=aabb.center;var ocx=oc[0];var ocy=oc[1];var ocz=oc[2];var oh=aabb.halfExtents;var ohx=oh[0];var ohy=oh[1];var ohz=oh[2];var ominx=ocx-ohx;var omaxx=ocx+ohx;var ominy=ocy-ohy;var omaxy=ocy+ohy;var ominz=ocz-ohz;var omaxz=ocz+ohz;if(ominx<tminx){tminx=ominx;}if(omaxx>tmaxx){tmaxx=omaxx;}if(ominy<tminy){tminy=ominy;}if(omaxy>tmaxy){tmaxy=omaxy;}if(ominz<tminz){tminz=ominz;}if(omaxz>tmaxz){tmaxz=omaxz;}tc[0]=(tminx+tmaxx)*0.5;tc[1]=(tminy+tmaxy)*0.5;tc[2]=(tminz+tmaxz)*0.5;th[0]=(tmaxx-tminx)*0.5;th[1]=(tmaxy-tminy)*0.5;th[2]=(tmaxz-tminz)*0.5;this.min[0]=tminx;this.min[1]=tminy;this.min[2]=tminz;this.max[0]=tmaxx;this.max[1]=tmaxy;this.max[2]=tmaxz;};_proto.setFromTransformedAABB=function setFromTransformedAABB(aabb,m){var bc=this.center;var br=this.halfExtents;var ac=aabb.center;var ar=aabb.halfExtents;var mx0=m[0];var mx1=m[4];var mx2=m[8];var my0=m[1];var my1=m[5];var my2=m[9];var mz0=m[2];var mz1=m[6];var mz2=m[10];var mx0a=Math.abs(mx0);var mx1a=Math.abs(mx1);var mx2a=Math.abs(mx2);var my0a=Math.abs(my0);var my1a=Math.abs(my1);var my2a=Math.abs(my2);var mz0a=Math.abs(mz0);var mz1a=Math.abs(mz1);var mz2a=Math.abs(mz2);bc[0]=m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2];bc[1]=m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2];bc[2]=m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2];// vec3.set(
|
|
8014
|
+
// bc,
|
|
8015
|
+
// m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
|
|
8016
|
+
// m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
|
|
8017
|
+
// m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
|
|
8018
|
+
// );
|
|
8019
|
+
br[0]=mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2];br[1]=my0a*ar[0]+my1a*ar[1]+my2a*ar[2];br[2]=mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2];// vec3.set(
|
|
8020
|
+
// br,
|
|
8021
|
+
// mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
|
|
8022
|
+
// my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
|
|
8023
|
+
// mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
|
|
8024
|
+
// );
|
|
8025
|
+
// this.min = vec3.sub(this.min, bc, br);
|
|
8026
|
+
// this.max = vec3.add(this.max, bc, br);
|
|
8027
|
+
subVec3(this.min,bc,br);addVec3(this.max,bc,br);};_proto.intersects=function intersects(aabb){var aMax=this.getMax();var aMin=this.getMin();var bMax=aabb.getMax();var bMin=aabb.getMin();return aMin[0]<=bMax[0]&&aMax[0]>=bMin[0]&&aMin[1]<=bMax[1]&&aMax[1]>=bMin[1]&&aMin[2]<=bMax[2]&&aMax[2]>=bMin[2];};_proto.intersection=function intersection(aabb){if(!this.intersects(aabb)){return null;}var intersection=new AABB();// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
8028
|
+
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
8029
|
+
var min=maxVec3([0,0,0],this.getMin(),aabb.getMin());var max=minVec3([0,0,0],this.getMax(),aabb.getMax());intersection.setMinMax(min,max);return intersection;}// containsPoint(point: vec3) {
|
|
8030
|
+
// const min = this.getMin();
|
|
8031
|
+
// const max = this.getMax();
|
|
8032
|
+
// return !(
|
|
8033
|
+
// point[0] < min[0] ||
|
|
8034
|
+
// point[0] > max[0] ||
|
|
8035
|
+
// point[1] < min[1] ||
|
|
8036
|
+
// point[1] > max[1] ||
|
|
8037
|
+
// point[2] < min[2] ||
|
|
8038
|
+
// point[2] > max[2]
|
|
8039
|
+
// );
|
|
8040
|
+
// }
|
|
8041
|
+
/**
|
|
8042
|
+
* get n-vertex
|
|
8043
|
+
* @param plane plane of CullingVolume
|
|
8044
|
+
*/;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.min);// return vec3.copy(vec3.create(), this.min);
|
|
8045
|
+
}else if(plane.pnVertexFlag===0x110){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
8046
|
+
}else if(plane.pnVertexFlag===0x101){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
8047
|
+
}else if(plane.pnVertexFlag===0x100){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
8048
|
+
}else if(plane.pnVertexFlag===0x011){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
8049
|
+
}else if(plane.pnVertexFlag===0x010){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
8050
|
+
}else if(plane.pnVertexFlag===0x001){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
8051
|
+
}else {return [this.max[0],this.max[1],this.max[2]];// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
8052
|
+
}}/**
|
|
8053
|
+
* get p-vertex
|
|
8054
|
+
* @param plane plane of CullingVolume
|
|
8055
|
+
*/;_proto.getPositiveFarPoint=function getPositiveFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.max);// return vec3.copy(vec3.create(), this.max);
|
|
8056
|
+
}else if(plane.pnVertexFlag===0x110){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
8057
|
+
}else if(plane.pnVertexFlag===0x101){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
8058
|
+
}else if(plane.pnVertexFlag===0x100){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
8059
|
+
}else if(plane.pnVertexFlag===0x011){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
8060
|
+
}else if(plane.pnVertexFlag===0x010){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
8061
|
+
}else if(plane.pnVertexFlag===0x001){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
8062
|
+
}else {return [this.min[0],this.min[1],this.min[2]];// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
8063
|
+
}};return AABB;}();var Plane=/*#__PURE__*/function(){/**
|
|
8064
|
+
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
8065
|
+
*/function Plane(distance,normal){this.distance=void 0;this.normal=void 0;this.pnVertexFlag=void 0;this.distance=distance||0;this.normal=normal||fromValues$2(0,1,0);this.updatePNVertexFlag();}var _proto=Plane.prototype;_proto.updatePNVertexFlag=function updatePNVertexFlag(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0);};_proto.distanceToPoint=function distanceToPoint(point){return dot(point,this.normal)-this.distance;};_proto.normalize=function normalize(){var invLen=1/len(this.normal);scale$1(this.normal,this.normal,invLen);this.distance*=invLen;};_proto.intersectsLine=function intersectsLine(start,end,point){var d0=this.distanceToPoint(start);var d1=this.distanceToPoint(end);var t=d0/(d0-d1);var intersects=t>=0&&t<=1;if(intersects&&point){lerp(point,start,end,t);}return intersects;};return Plane;}();(function(Mask){Mask[Mask["OUTSIDE"]=4294967295]="OUTSIDE";Mask[Mask["INSIDE"]=0]="INSIDE";Mask[Mask["INDETERMINATE"]=2147483647]="INDETERMINATE";})(exports.Mask||(exports.Mask={}));var Frustum=/*#__PURE__*/function(){function Frustum(planes){this.planes=[];if(planes){this.planes=planes;}else {for(var i=0;i<6;i++){this.planes.push(new Plane());}}}/**
|
|
8066
|
+
* extract 6 planes from projectionMatrix
|
|
8067
|
+
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
8068
|
+
*/var _proto=Frustum.prototype;_proto.extractFromVPMatrix=function extractFromVPMatrix(projectionMatrix){// @ts-ignore
|
|
8069
|
+
var m0=projectionMatrix[0],m1=projectionMatrix[1],m2=projectionMatrix[2],m3=projectionMatrix[3],m4=projectionMatrix[4],m5=projectionMatrix[5],m6=projectionMatrix[6],m7=projectionMatrix[7],m8=projectionMatrix[8],m9=projectionMatrix[9],m10=projectionMatrix[10],m11=projectionMatrix[11],m12=projectionMatrix[12],m13=projectionMatrix[13],m14=projectionMatrix[14],m15=projectionMatrix[15];// right
|
|
8070
|
+
set$1(this.planes[0].normal,m3-m0,m7-m4,m11-m8);this.planes[0].distance=m15-m12;// left
|
|
8071
|
+
set$1(this.planes[1].normal,m3+m0,m7+m4,m11+m8);this.planes[1].distance=m15+m12;// bottom
|
|
8072
|
+
set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
|
|
8073
|
+
set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
|
|
8074
|
+
set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
|
|
8075
|
+
set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();var CSSPropertyPath=/*#__PURE__*/function(){function CSSPropertyPath(){this.parser=parsePath;this.parserWithCSSDisabled=parsePath;this.mixer=mergePaths;}var _proto=CSSPropertyPath.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset
|
|
8077
8076
|
if(parsed instanceof CSSKeywordValue&&parsed.value==='unset'){return {absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Rectangle(0,0,0,0)};}return parsed;};/**
|
|
8078
8077
|
* update local position
|
|
8079
8078
|
*/_proto.postProcessor=function postProcessor(object,attributes){if(object.nodeName===exports.Shape.PATH&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;}var _proto=CSSPropertyPoints.prototype;/**
|
|
@@ -8327,7 +8326,7 @@
|
|
|
8327
8326
|
// scaling: vec3.fromValues(1, 1, 1),
|
|
8328
8327
|
// worldTransform: mat4.create(),
|
|
8329
8328
|
// origin: vec3.fromValues(0, 0, 0),
|
|
8330
|
-
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:
|
|
8329
|
+
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={dirty:false,contentBounds:undefined,renderBounds:undefined};_this.rBushNode={aabb:undefined};_this.id=void 0;_this.name=void 0;_this.namespaceURI='g';_this.scrollLeft=0;_this.scrollTop=0;_this.clientTop=0;_this.clientLeft=0;_this.destroyed=false;_this.style={};_this.computedStyle=runtime.enableCSSParsing?{anchor:unsetKeywordValue,opacity:unsetKeywordValue,fillOpacity:unsetKeywordValue,strokeOpacity:unsetKeywordValue,fill:unsetKeywordValue,stroke:unsetKeywordValue,transform:unsetKeywordValue,transformOrigin:unsetKeywordValue,visibility:unsetKeywordValue,pointerEvents:unsetKeywordValue,lineWidth:unsetKeywordValue,lineCap:unsetKeywordValue,lineJoin:unsetKeywordValue,increasedLineWidthForHitTesting:unsetKeywordValue,fontSize:unsetKeywordValue,fontFamily:unsetKeywordValue,fontStyle:unsetKeywordValue,fontWeight:unsetKeywordValue,fontVariant:unsetKeywordValue,textAlign:unsetKeywordValue,textBaseline:unsetKeywordValue,textTransform:unsetKeywordValue,zIndex:unsetKeywordValue,filter:unsetKeywordValue,shadowType:unsetKeywordValue}:null;_this.parsedStyle={// opacity: '',
|
|
8331
8330
|
// fillOpacity: '',
|
|
8332
8331
|
// strokeOpacity: '',
|
|
8333
8332
|
// transformOrigin: '',
|
|
@@ -8636,14 +8635,14 @@
|
|
|
8636
8635
|
*/;_proto.move=function move(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
|
|
8637
8636
|
* Use `this.style.zIndex` instead.
|
|
8638
8637
|
* @deprecated
|
|
8639
|
-
*/;_proto.setZIndex=function setZIndex(zIndex){this.style.zIndex=zIndex;return this;};_createClass(DisplayObject,[{key:"interactive",get:function get(){return this.isInteractive();},set:function set(b){this.style.pointerEvents=b?'auto':'none';}}]);return DisplayObject;}(Element);var _excluded=["style"];var Circle=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Circle,_DisplayObject);function Circle(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded);return _DisplayObject.call(this,_extends({type:exports.Shape.CIRCLE,style:runtime.enableCSSParsing?_extends({cx:'',cy:'',r:''},style):_extends({},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[
|
|
8638
|
+
*/;_proto.setZIndex=function setZIndex(zIndex){this.style.zIndex=zIndex;return this;};_createClass(DisplayObject,[{key:"interactive",get:function get(){return this.isInteractive();},set:function set(b){this.style.pointerEvents=b?'auto':'none';}}]);return DisplayObject;}(Element);var _excluded=["style"];var Circle=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Circle,_DisplayObject);function Circle(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded);return _DisplayObject.call(this,_extends({type:exports.Shape.CIRCLE,style:runtime.enableCSSParsing?_extends({cx:'',cy:'',r:''},style):_extends({},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[PECENTAGE_50,PECENTAGE_50]}},rest))||this;}return Circle;}(DisplayObject);var _excluded$1=["style"];/**
|
|
8640
8639
|
* shadow root
|
|
8641
8640
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
8642
8641
|
*/var CustomElement=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(CustomElement,_DisplayObject);// static get observedAttributes(): string[] {
|
|
8643
8642
|
// return [];
|
|
8644
8643
|
// }
|
|
8645
8644
|
// private shadowNodes: DisplayObject[] = [];
|
|
8646
|
-
function CustomElement(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$1);_this=_DisplayObject.call(this,_extends({style:runtime.enableCSSParsing?_extends({x:'',y:''},style):_extends({},style)},rest))||this;_this.isCustomElement=true;return _this;}return CustomElement;}(DisplayObject);var pool={};var htmlPool=[];var DisplayObjectPool=/*#__PURE__*/function(){function DisplayObjectPool(){}var _proto=DisplayObjectPool.prototype;_proto.getByEntity=function getByEntity(entity){return pool[entity];};_proto.getAll=function getAll(){return Object.keys(pool).map(function(entity){return pool[entity];});};_proto.add=function add(entity,groupOrShape){pool[entity]=groupOrShape;if(groupOrShape.nodeName===exports.Shape.HTML){htmlPool.push(groupOrShape);}};_proto.remove=function remove(entity){var existed=pool[entity];if(existed){delete pool[entity];if(existed.nodeName===exports.Shape.HTML){var index=htmlPool.indexOf(existed);htmlPool.splice(index,1);}}};_proto.getHTMLs=function getHTMLs(){return htmlPool;};return DisplayObjectPool;}();var _excluded$2=["style"];var Ellipse=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Ellipse,_DisplayObject);function Ellipse(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$2);return _DisplayObject.call(this,_extends({type:exports.Shape.ELLIPSE,style:runtime.enableCSSParsing?_extends({cx:'',cy:'',rx:'',ry:''},style):_extends({},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[
|
|
8645
|
+
function CustomElement(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$1);_this=_DisplayObject.call(this,_extends({style:runtime.enableCSSParsing?_extends({x:'',y:''},style):_extends({},style)},rest))||this;_this.isCustomElement=true;return _this;}return CustomElement;}(DisplayObject);var pool={};var htmlPool=[];var DisplayObjectPool=/*#__PURE__*/function(){function DisplayObjectPool(){}var _proto=DisplayObjectPool.prototype;_proto.getByEntity=function getByEntity(entity){return pool[entity];};_proto.getAll=function getAll(){return Object.keys(pool).map(function(entity){return pool[entity];});};_proto.add=function add(entity,groupOrShape){pool[entity]=groupOrShape;if(groupOrShape.nodeName===exports.Shape.HTML){htmlPool.push(groupOrShape);}};_proto.remove=function remove(entity){var existed=pool[entity];if(existed){delete pool[entity];if(existed.nodeName===exports.Shape.HTML){var index=htmlPool.indexOf(existed);htmlPool.splice(index,1);}}};_proto.getHTMLs=function getHTMLs(){return htmlPool;};return DisplayObjectPool;}();var _excluded$2=["style"];var Ellipse=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Ellipse,_DisplayObject);function Ellipse(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$2);return _DisplayObject.call(this,_extends({type:exports.Shape.ELLIPSE,style:runtime.enableCSSParsing?_extends({cx:'',cy:'',rx:'',ry:''},style):_extends({},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[PECENTAGE_50,PECENTAGE_50]}},rest))||this;}return Ellipse;}(DisplayObject);var _excluded$3=["style"];/**
|
|
8647
8646
|
* its attributes are inherited by its children.
|
|
8648
8647
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
|
|
8649
8648
|
*
|
|
@@ -8723,7 +8722,7 @@
|
|
|
8723
8722
|
// }
|
|
8724
8723
|
/**
|
|
8725
8724
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
|
|
8726
|
-
*/var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;return ((_this$parsedStyle$met=this.parsedStyle.metrics)===null||_this$parsedStyle$met===void 0?void 0:_this$parsedStyle$met.maxLineWidth)||0;}// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
8725
|
+
*/var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;this.forceUpdateGeometry();return ((_this$parsedStyle$met=this.parsedStyle.metrics)===null||_this$parsedStyle$met===void 0?void 0:_this$parsedStyle$met.maxLineWidth)||0;}// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
8727
8726
|
// throw new Error('Method not implemented.');
|
|
8728
8727
|
// }
|
|
8729
8728
|
// getExtentOfChar(charnum: number): DOMRect {
|
|
@@ -8744,7 +8743,7 @@
|
|
|
8744
8743
|
// selectSubString(charnum: number, nchars: number): void {
|
|
8745
8744
|
// throw new Error('Method not implemented.');
|
|
8746
8745
|
// }
|
|
8747
|
-
;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;return ((_this$parsedStyle$met2=this.parsedStyle.metrics)===null||_this$parsedStyle$met2===void 0?void 0:_this$parsedStyle$met2.lineMetrics)||[];};_proto.isOverflowing=function isOverflowing(){return !!this.parsedStyle.isOverflowing;};return Text;}(DisplayObject);/**
|
|
8746
|
+
;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;this.forceUpdateGeometry();return ((_this$parsedStyle$met2=this.parsedStyle.metrics)===null||_this$parsedStyle$met2===void 0?void 0:_this$parsedStyle$met2.lineMetrics)||[];};_proto.isOverflowing=function isOverflowing(){this.forceUpdateGeometry();return !!this.parsedStyle.isOverflowing;};_proto.forceUpdateGeometry=function forceUpdateGeometry(){if(!this.parsedStyle.metrics){runtime.styleValueRegistry.updateGeometry(this);}};return Text;}(DisplayObject);/**
|
|
8748
8747
|
* Blink used them in code generation(css_properties.json5)
|
|
8749
8748
|
*/var BUILT_IN_PROPERTIES=[{/**
|
|
8750
8749
|
* used in CSS Layout API
|
|
@@ -8921,9 +8920,7 @@
|
|
|
8921
8920
|
return usedValue;}}return;};_proto.recalc=function recalc(object){var properties=unresolvedProperties.get(object);if(properties&&properties.length){var attributes={};properties.forEach(function(property){attributes[property]=object.attributes[property];});this.processProperties(object,attributes);unresolvedProperties.delete(object);}}/**
|
|
8922
8921
|
* update geometry when relative props changed,
|
|
8923
8922
|
* eg. r of Circle, width/height of Rect
|
|
8924
|
-
*/;_proto.updateGeometry=function updateGeometry(object){var geometryUpdater=runtime.geometryUpdaterFactory[
|
|
8925
|
-
// @see https://github.com/antvis/g/issues/957
|
|
8926
|
-
var flipY=width<0;var flipX=height<0;// init with content box
|
|
8923
|
+
*/;_proto.updateGeometry=function updateGeometry(object){var nodeName=object.nodeName;var geometryUpdater=runtime.geometryUpdaterFactory[nodeName];if(geometryUpdater){var geometry=object.geometry;if(!geometry.contentBounds){geometry.contentBounds=new AABB();}if(!geometry.renderBounds){geometry.renderBounds=new AABB();}var parsedStyle=object.parsedStyle;var _geometryUpdater$upda=geometryUpdater.update(parsedStyle,object),width=_geometryUpdater$upda.width,height=_geometryUpdater$upda.height,_geometryUpdater$upda2=_geometryUpdater$upda.depth,depth=_geometryUpdater$upda2===void 0?0:_geometryUpdater$upda2,_geometryUpdater$upda3=_geometryUpdater$upda.offsetX,offsetX=_geometryUpdater$upda3===void 0?0:_geometryUpdater$upda3,_geometryUpdater$upda4=_geometryUpdater$upda.offsetY,offsetY=_geometryUpdater$upda4===void 0?0:_geometryUpdater$upda4,_geometryUpdater$upda5=_geometryUpdater$upda.offsetZ,offsetZ=_geometryUpdater$upda5===void 0?0:_geometryUpdater$upda5;// init with content box
|
|
8927
8924
|
var halfExtents=[Math.abs(width)/2,Math.abs(height)/2,depth/2];// const halfExtents = vec3.set(
|
|
8928
8925
|
// tmpVec3a,
|
|
8929
8926
|
// Math.abs(width) / 2,
|
|
@@ -8932,7 +8929,7 @@
|
|
|
8932
8929
|
// );
|
|
8933
8930
|
// anchor is center by default, don't account for lineWidth here
|
|
8934
8931
|
var stroke=parsedStyle.stroke,lineWidth=parsedStyle.lineWidth,increasedLineWidthForHitTesting=parsedStyle.increasedLineWidthForHitTesting,shadowType=parsedStyle.shadowType,shadowColor=parsedStyle.shadowColor,_parsedStyle$filter=parsedStyle.filter,filter=_parsedStyle$filter===void 0?[]:_parsedStyle$filter,transformOrigin=parsedStyle.transformOrigin;var anchor=parsedStyle.anchor;// <Text> use textAlign & textBaseline instead of anchor
|
|
8935
|
-
if(
|
|
8932
|
+
if(nodeName===exports.Shape.TEXT){delete parsedStyle.anchor;}var center=[(1-(anchor&&anchor[0]||0)*2)*width/2+offsetX,(1-(anchor&&anchor[1]||0)*2)*height/2+offsetY,(1-(anchor&&anchor[2]||0)*2)*halfExtents[2]+offsetZ];// const center = vec3.set(
|
|
8936
8933
|
// tmpVec3b,
|
|
8937
8934
|
// ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
|
|
8938
8935
|
// ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
|
|
@@ -8940,7 +8937,7 @@
|
|
|
8940
8937
|
// );
|
|
8941
8938
|
// update geometry's AABB
|
|
8942
8939
|
geometry.contentBounds.update(center,halfExtents);// @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
|
|
8943
|
-
var expansion=
|
|
8940
|
+
var expansion=nodeName===exports.Shape.POLYLINE||nodeName===exports.Shape.POLYGON||nodeName===exports.Shape.PATH?Math.SQRT2:0.5;// if (lineCap?.value === 'square') {
|
|
8944
8941
|
// expansion = Math.SQRT1_2;
|
|
8945
8942
|
// }
|
|
8946
8943
|
// if (lineJoin?.value === 'miter' && expansion < Math.SQRT2 * miterLimit) {
|
|
@@ -8956,9 +8953,13 @@
|
|
|
8956
8953
|
// );
|
|
8957
8954
|
}geometry.renderBounds.update(center,halfExtents);// account for shadow, only support constant value now
|
|
8958
8955
|
if(shadowColor&&shadowType&&shadowType!=='inner'){var _geometry$renderBound=geometry.renderBounds,min=_geometry$renderBound.min,max=_geometry$renderBound.max;var shadowBlur=parsedStyle.shadowBlur,shadowOffsetX=parsedStyle.shadowOffsetX,shadowOffsetY=parsedStyle.shadowOffsetY;var shadowBlurInPixels=shadowBlur||0;var shadowOffsetXInPixels=shadowOffsetX||0;var shadowOffsetYInPixels=shadowOffsetY||0;var shadowLeft=min[0]-shadowBlurInPixels+shadowOffsetXInPixels;var shadowRight=max[0]+shadowBlurInPixels+shadowOffsetXInPixels;var shadowTop=min[1]-shadowBlurInPixels+shadowOffsetYInPixels;var shadowBottom=max[1]+shadowBlurInPixels+shadowOffsetYInPixels;min[0]=Math.min(min[0],shadowLeft);max[0]=Math.max(max[0],shadowRight);min[1]=Math.min(min[1],shadowTop);max[1]=Math.max(max[1],shadowBottom);geometry.renderBounds.setMinMax(min,max);}// account for filter, eg. blur(5px), drop-shadow()
|
|
8959
|
-
filter.forEach(function(_ref){var name=_ref.name,params=_ref.params;if(name==='blur'){var blurRadius=params[0].value;geometry.renderBounds.update(geometry.renderBounds.center,addVec3(geometry.renderBounds.halfExtents,geometry.renderBounds.halfExtents,[blurRadius,blurRadius,0]));}else if(name==='drop-shadow'){var _shadowOffsetX=params[0].value;var _shadowOffsetY=params[1].value;var _shadowBlur=params[2].value;var _geometry$renderBound2=geometry.renderBounds,_min=_geometry$renderBound2.min,_max=_geometry$renderBound2.max;var _shadowLeft=_min[0]-_shadowBlur+_shadowOffsetX;var _shadowRight=_max[0]+_shadowBlur+_shadowOffsetX;var _shadowTop=_min[1]-_shadowBlur+_shadowOffsetY;var _shadowBottom=_max[1]+_shadowBlur+_shadowOffsetY;_min[0]=Math.min(_min[0],_shadowLeft);_max[0]=Math.max(_max[0],_shadowRight);_min[1]=Math.min(_min[1],_shadowTop);_max[1]=Math.max(_max[1],_shadowBottom);geometry.renderBounds.setMinMax(_min,_max);}});anchor=parsedStyle.anchor;geometry.dirty=false;//
|
|
8960
|
-
|
|
8961
|
-
//
|
|
8956
|
+
filter.forEach(function(_ref){var name=_ref.name,params=_ref.params;if(name==='blur'){var blurRadius=params[0].value;geometry.renderBounds.update(geometry.renderBounds.center,addVec3(geometry.renderBounds.halfExtents,geometry.renderBounds.halfExtents,[blurRadius,blurRadius,0]));}else if(name==='drop-shadow'){var _shadowOffsetX=params[0].value;var _shadowOffsetY=params[1].value;var _shadowBlur=params[2].value;var _geometry$renderBound2=geometry.renderBounds,_min=_geometry$renderBound2.min,_max=_geometry$renderBound2.max;var _shadowLeft=_min[0]-_shadowBlur+_shadowOffsetX;var _shadowRight=_max[0]+_shadowBlur+_shadowOffsetX;var _shadowTop=_min[1]-_shadowBlur+_shadowOffsetY;var _shadowBottom=_max[1]+_shadowBlur+_shadowOffsetY;_min[0]=Math.min(_min[0],_shadowLeft);_max[0]=Math.max(_max[0],_shadowRight);_min[1]=Math.min(_min[1],_shadowTop);_max[1]=Math.max(_max[1],_shadowBottom);geometry.renderBounds.setMinMax(_min,_max);}});anchor=parsedStyle.anchor;geometry.dirty=false;// if (nodeName === Shape.RECT) {
|
|
8957
|
+
// account for negative width / height of Rect
|
|
8958
|
+
// @see https://github.com/antvis/g/issues/957
|
|
8959
|
+
var flipY=width<0;var flipX=height<0;// } else {
|
|
8960
|
+
// }
|
|
8961
|
+
// set transform origin
|
|
8962
|
+
var usedOriginXValue=(flipY?-1:1)*(transformOrigin?convertPercentUnit(transformOrigin[0],0,object):0);var usedOriginYValue=(flipX?-1:1)*(transformOrigin?convertPercentUnit(transformOrigin[1],1,object):0);usedOriginXValue=usedOriginXValue-(flipY?-1:1)*(anchor&&anchor[0]||0)*geometry.contentBounds.halfExtents[0]*2;usedOriginYValue=usedOriginYValue-(flipX?-1:1)*(anchor&&anchor[1]||0)*geometry.contentBounds.halfExtents[1]*2;object.setOrigin(usedOriginXValue,usedOriginYValue);// FIXME setOrigin may have already dirtified to root.
|
|
8962
8963
|
// runtime.sceneGraphService.dirtifyToRoot(object);
|
|
8963
8964
|
}};_proto.isPropertyInheritable=function isPropertyInheritable(name){var metadata=propertyMetadataCache[name];if(!metadata){return false;}return metadata.inh;};return DefaultStyleValueRegistry;}();/**
|
|
8964
8965
|
* Different type of cameras, eg. simple camera used in 2D scene or
|
|
@@ -9254,7 +9255,7 @@
|
|
|
9254
9255
|
* same as pivot in Pixi.js
|
|
9255
9256
|
*
|
|
9256
9257
|
* @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
|
|
9257
|
-
*/;_proto.setOrigin=function setOrigin(element,origin,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof origin==='number'){origin=
|
|
9258
|
+
*/;_proto.setOrigin=function setOrigin(element,origin,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof origin==='number'){origin=[origin,y,z];}var transform=element.transformable;if(origin[0]===transform.origin[0]&&origin[1]===transform.origin[1]&&origin[2]===transform.origin[2]){return;}var originVec=transform.origin;// const delta = vec3.subtract(vec3.create(), origin, originVec);
|
|
9258
9259
|
// vec3.add(transform.localPosition, transform.localPosition, delta);
|
|
9259
9260
|
// update origin
|
|
9260
9261
|
originVec[0]=origin[0];originVec[1]=origin[1];originVec[2]=origin[2]||0;this.dirtifyLocal(element,transform);}/**
|
|
@@ -9296,7 +9297,7 @@
|
|
|
9296
9297
|
var aabb=this.getTransformedGeometryBounds(element,render,existedAABB);// merge children's aabbs
|
|
9297
9298
|
var children=element.childNodes;children.forEach(function(child){var childBounds=_this4.getBounds(child,render);if(childBounds){if(!aabb){aabb=existedAABB||new AABB();aabb.update(childBounds.center,childBounds.halfExtents);}else {aabb.add(childBounds);}}});if(render){// FIXME: account for clip path
|
|
9298
9299
|
var clipped=findClosestClipPathTarget(element);if(clipped){// use bounds under world space
|
|
9299
|
-
var clipPathBounds=clipped.
|
|
9300
|
+
var clipPathBounds=clipped.parsedStyle.clipPath.getBounds(render);if(!aabb){aabb=clipPathBounds;}else if(clipPathBounds){aabb=clipPathBounds.intersection(aabb);}}}if(!aabb){aabb=new AABB();}if(aabb){if(render){renderable.renderBounds=aabb;}else {renderable.bounds=aabb;}}if(render){renderable.renderBoundsDirty=false;}else {renderable.boundsDirty=false;}return aabb;}/**
|
|
9300
9301
|
* account for children in local space
|
|
9301
9302
|
*/;_proto.getLocalBounds=function getLocalBounds(element){if(element.parentNode){var parentInvert=create$1();if(element.parentNode.transformable){parentInvert=invert(create$1(),this.getWorldTransform(element.parentNode));}var bounds=this.getBounds(element);if(!AABB.isEmpty(bounds)){var localBounds=new AABB();localBounds.setFromTransformedAABB(bounds,parentInvert);return localBounds;}}return this.getBounds(element);};_proto.getBoundingClientRect=function getBoundingClientRect(element){var _element$ownerDocumen,_element$ownerDocumen2;var aabb;var bounds=this.getGeometryBounds(element);if(!AABB.isEmpty(bounds)){aabb=new AABB();// apply transformation to aabb
|
|
9302
9303
|
aabb.setFromTransformedAABB(bounds,this.getWorldTransform(element));}// calc context's offset
|
|
@@ -9394,15 +9395,15 @@
|
|
|
9394
9395
|
* @see https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/README.md
|
|
9395
9396
|
*
|
|
9396
9397
|
* also provide some extra events such as `drag`
|
|
9397
|
-
*/var EventPlugin=/*#__PURE__*/function(){function EventPlugin(){var _this=this;this.autoPreventDefault=false;this.rootPointerEvent=new FederatedPointerEvent(null);this.rootWheelEvent=new FederatedWheelEvent(null);this.context=void 0;this.onPointerMove=function(nativeEvent){var _this$context$renderi,_this$context$renderi2;var canvas=(_this$context$renderi=_this.context.renderingContext.root)===null||_this$context$renderi===void 0?void 0:(_this$context$renderi2=_this$context$renderi.ownerDocument)===null||_this$context$renderi2===void 0?void 0:_this$context$renderi2.defaultView;if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var normalizedEvents=_this.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator=_createForOfIteratorHelperLoose(normalizedEvents),_step;!(_step=_iterator()).done;){var normalizedEvent=_step.value;var event=_this.bootstrapEvent(_this.rootPointerEvent,normalizedEvent,canvas);_this.context.eventService.mapEvent(event);}_this.setCursor(_this.context.eventService.cursor);};}var _proto=EventPlugin.prototype;_proto.apply=function apply(context){var _this2=this;this.context=context;var renderingService=context.renderingService;var canvas=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(position){var _yield$_this2$context,picked;return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _this2.context.renderingService.hooks.pick.promise({position:position,picked:[],topmost:true// we only concern the topmost element
|
|
9398
|
-
});case 2:_yield$_this2$context=_context.sent;picked=_yield$_this2$context.picked;return _context.abrupt("return",picked[0]||null);case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());renderingService.hooks.pointerWheel.tap(EventPlugin.tag,function(nativeEvent){var wheelEvent=_this2.normalizeWheelEvent(nativeEvent);_this2.context.eventService.mapEvent(wheelEvent);});renderingService.hooks.pointerDown.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var events=_this2.normalizeToPointerEvent(nativeEvent,canvas);if(_this2.autoPreventDefault&&events[0].isNormalized){var cancelable=nativeEvent.cancelable||!('cancelable'in nativeEvent);if(cancelable){nativeEvent.preventDefault();}}for(var _iterator2=_createForOfIteratorHelperLoose(events),_step2;!(_step2=_iterator2()).done;){var event=_step2.value;var federatedEvent=_this2.bootstrapEvent(_this2.rootPointerEvent,event,canvas);_this2.context.eventService.mapEvent(federatedEvent);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerUp.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;// account for element in SVG
|
|
9398
|
+
*/var EventPlugin=/*#__PURE__*/function(){function EventPlugin(){var _this=this;this.autoPreventDefault=false;this.rootPointerEvent=new FederatedPointerEvent(null);this.rootWheelEvent=new FederatedWheelEvent(null);this.context=void 0;this.onPointerMove=function(nativeEvent){var _this$context$renderi,_this$context$renderi2;var canvas=(_this$context$renderi=_this.context.renderingContext.root)===null||_this$context$renderi===void 0?void 0:(_this$context$renderi2=_this$context$renderi.ownerDocument)===null||_this$context$renderi2===void 0?void 0:_this$context$renderi2.defaultView;if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var normalizedEvents=_this.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator=_createForOfIteratorHelperLoose(normalizedEvents),_step;!(_step=_iterator()).done;){var normalizedEvent=_step.value;var event=_this.bootstrapEvent(_this.rootPointerEvent,normalizedEvent,canvas,nativeEvent);_this.context.eventService.mapEvent(event);}_this.setCursor(_this.context.eventService.cursor);};}var _proto=EventPlugin.prototype;_proto.apply=function apply(context){var _this2=this;this.context=context;var renderingService=context.renderingService;var canvas=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(position){var _yield$_this2$context,picked;return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _this2.context.renderingService.hooks.pick.promise({position:position,picked:[],topmost:true// we only concern the topmost element
|
|
9399
|
+
});case 2:_yield$_this2$context=_context.sent;picked=_yield$_this2$context.picked;return _context.abrupt("return",picked[0]||null);case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());renderingService.hooks.pointerWheel.tap(EventPlugin.tag,function(nativeEvent){var wheelEvent=_this2.normalizeWheelEvent(nativeEvent);_this2.context.eventService.mapEvent(wheelEvent);});renderingService.hooks.pointerDown.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var events=_this2.normalizeToPointerEvent(nativeEvent,canvas);if(_this2.autoPreventDefault&&events[0].isNormalized){var cancelable=nativeEvent.cancelable||!('cancelable'in nativeEvent);if(cancelable){nativeEvent.preventDefault();}}for(var _iterator2=_createForOfIteratorHelperLoose(events),_step2;!(_step2=_iterator2()).done;){var event=_step2.value;var federatedEvent=_this2.bootstrapEvent(_this2.rootPointerEvent,event,canvas,nativeEvent);_this2.context.eventService.mapEvent(federatedEvent);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerUp.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;// account for element in SVG
|
|
9399
9400
|
var $element=_this2.context.contextService.getDomElement();var outside='outside';try{outside=$element&&nativeEvent.target&&nativeEvent.target!==$element&&$element.contains&&!$element.contains(nativeEvent.target)?'outside':'';}catch(e){// nativeEvent.target maybe not Node, such as Window
|
|
9400
9401
|
// @see https://github.com/antvis/G/issues/1235
|
|
9401
|
-
}var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator3=_createForOfIteratorHelperLoose(normalizedEvents),_step3;!(_step3=_iterator3()).done;){var normalizedEvent=_step3.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas);event.type+=outside;_this2.context.eventService.mapEvent(event);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerMove.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOver.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOut.tap(EventPlugin.tag,this.onPointerMove);};_proto.getViewportXY=function getViewportXY(nativeEvent){var x;var y;/**
|
|
9402
|
+
}var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator3=_createForOfIteratorHelperLoose(normalizedEvents),_step3;!(_step3=_iterator3()).done;){var normalizedEvent=_step3.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas,nativeEvent);event.type+=outside;_this2.context.eventService.mapEvent(event);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerMove.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOver.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOut.tap(EventPlugin.tag,this.onPointerMove);};_proto.getViewportXY=function getViewportXY(nativeEvent){var x;var y;/**
|
|
9402
9403
|
* Should account for CSS Transform applied on container.
|
|
9403
9404
|
* @see https://github.com/antvis/G/issues/1161
|
|
9404
9405
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/offsetX
|
|
9405
|
-
*/var offsetX=nativeEvent.offsetX,offsetY=nativeEvent.offsetY,clientX=nativeEvent.clientX,clientY=nativeEvent.clientY;if(this.context.config.supportsCSSTransform&&!isNil(offsetX)&&!isNil(offsetY)){x=offsetX;y=offsetY;}else {var point=this.context.eventService.client2Viewport(new Point(clientX,clientY));x=point.x;y=point.y;}return {x:x,y:y};};_proto.bootstrapEvent=function bootstrapEvent(event,
|
|
9406
|
+
*/var offsetX=nativeEvent.offsetX,offsetY=nativeEvent.offsetY,clientX=nativeEvent.clientX,clientY=nativeEvent.clientY;if(this.context.config.supportsCSSTransform&&!isNil(offsetX)&&!isNil(offsetY)){x=offsetX;y=offsetY;}else {var point=this.context.eventService.client2Viewport(new Point(clientX,clientY));x=point.x;y=point.y;}return {x:x,y:y};};_proto.bootstrapEvent=function bootstrapEvent(event,normalizedEvent,view,nativeEvent){event.view=view;event.originalEvent=null;event.nativeEvent=nativeEvent;event.pointerId=normalizedEvent.pointerId;event.width=normalizedEvent.width;event.height=normalizedEvent.height;event.isPrimary=normalizedEvent.isPrimary;event.pointerType=normalizedEvent.pointerType;event.pressure=normalizedEvent.pressure;event.tangentialPressure=normalizedEvent.tangentialPressure;event.tiltX=normalizedEvent.tiltX;event.tiltY=normalizedEvent.tiltY;event.twist=normalizedEvent.twist;this.transferMouseData(event,normalizedEvent);var _this$getViewportXY=this.getViewportXY(normalizedEvent),x=_this$getViewportXY.x,y=_this$getViewportXY.y;event.viewport.x=x;event.viewport.y=y;var _this$context$eventSe=this.context.eventService.viewport2Canvas(event.viewport),canvasX=_this$context$eventSe.x,canvasY=_this$context$eventSe.y;event.canvas.x=canvasX;event.canvas.y=canvasY;event.global.copyFrom(event.canvas);event.offset.copyFrom(event.canvas);event.isTrusted=nativeEvent.isTrusted;if(event.type==='pointerleave'){event.type='pointerout';}if(event.type.startsWith('mouse')){event.type=event.type.replace('mouse','pointer');}if(event.type.startsWith('touch')){event.type=TOUCH_TO_POINTER[event.type]||event.type;}return event;};_proto.normalizeWheelEvent=function normalizeWheelEvent(nativeEvent){var event=this.rootWheelEvent;this.transferMouseData(event,nativeEvent);event.deltaMode=nativeEvent.deltaMode;event.deltaX=nativeEvent.deltaX;event.deltaY=nativeEvent.deltaY;event.deltaZ=nativeEvent.deltaZ;var _this$getViewportXY2=this.getViewportXY(nativeEvent),x=_this$getViewportXY2.x,y=_this$getViewportXY2.y;event.viewport.x=x;event.viewport.y=y;var _this$context$eventSe2=this.context.eventService.viewport2Canvas(event.viewport),canvasX=_this$context$eventSe2.x,canvasY=_this$context$eventSe2.y;event.canvas.x=canvasX;event.canvas.y=canvasY;event.global.copyFrom(event.canvas);event.offset.copyFrom(event.canvas);event.nativeEvent=nativeEvent;event.type=nativeEvent.type;return event;}/**
|
|
9406
9407
|
* Transfers base & mouse event data from the nativeEvent to the federated event.
|
|
9407
9408
|
*/;_proto.transferMouseData=function transferMouseData(event,nativeEvent){event.isTrusted=nativeEvent.isTrusted;event.srcElement=nativeEvent.srcElement;event.timeStamp=performance.now();event.type=nativeEvent.type;event.altKey=nativeEvent.altKey;event.metaKey=nativeEvent.metaKey;event.shiftKey=nativeEvent.shiftKey;event.ctrlKey=nativeEvent.ctrlKey;event.button=nativeEvent.button;event.buttons=nativeEvent.buttons;event.client.x=nativeEvent.clientX;event.client.y=nativeEvent.clientY;event.movement.x=nativeEvent.movementX;event.movement.y=nativeEvent.movementY;event.page.x=nativeEvent.pageX;event.page.y=nativeEvent.pageY;event.screen.x=nativeEvent.screenX;event.screen.y=nativeEvent.screenY;event.relatedTarget=null;};_proto.setCursor=function setCursor(cursor){this.context.contextService.applyCursorStyle(cursor||this.context.config.cursor||'default');};_proto.normalizeToPointerEvent=function normalizeToPointerEvent(event,canvas){var normalizedEvents=[];if(canvas.isTouchEvent(event)){for(var i=0;i<event.changedTouches.length;i++){var touch=event.changedTouches[i];// use changedTouches instead of touches since touchend has no touches
|
|
9408
9409
|
// @see https://stackoverflow.com/a/10079076
|