@antv/g 5.16.4 → 5.16.6
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 +49 -31
- package/dist/index.umd.min.js +1 -1
- package/package.json +8 -8
package/dist/index.umd.js
CHANGED
|
@@ -7530,9 +7530,9 @@
|
|
|
7530
7530
|
// );
|
|
7531
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;/**
|
|
7532
7532
|
* destroy existed canvas with the same id
|
|
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.
|
|
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
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$style;var clipPath=(_el$style=el.style)===null||_el$style===void 0?void 0:_el$style.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
|
-
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(
|
|
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
|
|
7538
7538
|
// singularity at the south pole
|
|
@@ -7808,7 +7808,7 @@
|
|
|
7808
7808
|
// } else if (type === 'repeating-radial-gradient') {
|
|
7809
7809
|
}});}// legacy format, should be deprecated later
|
|
7810
7810
|
var type=colorStr[0];if(colorStr[1]==='('||colorStr[2]==='('){if(type==='l'){var arr=regexLG.exec(colorStr);if(arr){var _arr$2$match;var steps=((_arr$2$match=arr[2].match(regexColorStop))===null||_arr$2$match===void 0?void 0:_arr$2$match.map(function(stop){return stop.split(':');}))||[];return [new CSSGradientValue(exports.GradientType.LinearGradient,{angle:getOrCreateUnitValue(parseFloat(arr[1]),'deg'),steps:steps.map(function(_ref2){var offset=_ref2[0],color=_ref2[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})})];}}else if(type==='r'){var parsedRadialGradient=parseRadialGradient(colorStr);if(parsedRadialGradient){if(isString(parsedRadialGradient)){colorStr=parsedRadialGradient;}else {return [new CSSGradientValue(exports.GradientType.RadialGradient,parsedRadialGradient)];}}}else if(type==='p'){return parsePattern(colorStr);}}});function parseRadialGradient(gradientStr){var arr=regexRG.exec(gradientStr);if(arr){var _arr$4$match;var steps=((_arr$4$match=arr[4].match(regexColorStop))===null||_arr$4$match===void 0?void 0:_arr$4$match.map(function(stop){return stop.split(':');}))||[];return {cx:getOrCreateUnitValue(50,'%'),cy:getOrCreateUnitValue(50,'%'),steps:steps.map(function(_ref3){var offset=_ref3[0],color=_ref3[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})};}return null;}function parsePattern(patternStr){var arr=regexPR.exec(patternStr);if(arr){var repetition=arr[1];var src=arr[2];switch(repetition){case'a':repetition='repeat';break;case'x':repetition='repeat-x';break;case'y':repetition='repeat-y';break;case'n':repetition='no-repeat';break;default:repetition='no-repeat';}return {image:src,// @ts-ignore
|
|
7811
|
-
repetition:repetition};}return null;}function isCSSGradientValue(object){return !!object.type&&!!object.value;}function isPattern(object){return
|
|
7811
|
+
repetition:repetition};}return null;}function isCSSGradientValue(object){return !!object.type&&!!object.value;}function isPattern(object){return object&&!!object.image;}function isCSSRGB(object){return object&&!isNil(object.r)&&!isNil(object.g)&&!isNil(object.b);}/**
|
|
7812
7812
|
* @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
|
|
7813
7813
|
*/var parseColor=memoize(function(colorStr){if(isPattern(colorStr)){return _extends({repetition:'repeat'},colorStr);}if(isNil(colorStr)){colorStr='';}if(colorStr==='transparent'){// transparent black
|
|
7814
7814
|
return transparentColor;}else if(colorStr==='currentColor'){// @see https://github.com/adobe-webplatform/Snap.svg/issues/526
|
|
@@ -7929,8 +7929,8 @@
|
|
|
7929
7929
|
// rightValue = convertAngleUnit(right);
|
|
7930
7930
|
// unit = 'deg';
|
|
7931
7931
|
// }
|
|
7932
|
-
return [leftValue,rightValue,function(value){if(nonNegative){value=Math.max(value,0);}return value+unit;}];}function convertAngleUnit(value){var deg=0;if(value.unit===exports.UnitType.kDegrees){deg=value.value;}else if(value.unit===exports.UnitType.kRadians){deg=rad2deg(Number(value.value));}else if(value.unit===exports.UnitType.kTurns){deg=turn2deg(Number(value.value));}return deg;}function parseDimensionArrayFormat(string,size){var parsed;if(
|
|
7933
|
-
parsed=string.map(function(segment){return Number(segment);});}if(size===2){if(parsed.length===1){return [parsed[0],parsed[0]];}else {return [parsed[0],parsed[1]];}}else {if(parsed.length===1){return [parsed[0],parsed[0],parsed[0],parsed[0]];}else if(parsed.length===2){return [parsed[0],parsed[1],parsed[0],parsed[1]];}else if(parsed.length===3){return [parsed[0],parsed[1],parsed[2],parsed[1]];}else {return [parsed[0],parsed[1],parsed[2],parsed[3]];}}}function parseDimensionArray(string){if(isString(string)){// "1px 2px 3px"
|
|
7932
|
+
return [leftValue,rightValue,function(value){if(nonNegative){value=Math.max(value,0);}return value+unit;}];}function convertAngleUnit(value){var deg=0;if(value.unit===exports.UnitType.kDegrees){deg=value.value;}else if(value.unit===exports.UnitType.kRadians){deg=rad2deg(Number(value.value));}else if(value.unit===exports.UnitType.kTurns){deg=turn2deg(Number(value.value));}return deg;}function parseDimensionArrayFormat(string,size){var parsed;if(Array.isArray(string)){// [1, '2px', 3]
|
|
7933
|
+
parsed=string.map(function(segment){return Number(segment);});}else if(isString(string)){parsed=string.split(' ').map(function(segment){return Number(segment);});}else if(isNumber(string)){parsed=[string];}if(size===2){if(parsed.length===1){return [parsed[0],parsed[0]];}else {return [parsed[0],parsed[1]];}}else {if(parsed.length===1){return [parsed[0],parsed[0],parsed[0],parsed[0]];}else if(parsed.length===2){return [parsed[0],parsed[1],parsed[0],parsed[1]];}else if(parsed.length===3){return [parsed[0],parsed[1],parsed[2],parsed[1]];}else {return [parsed[0],parsed[1],parsed[2],parsed[3]];}}}function parseDimensionArray(string){if(isString(string)){// "1px 2px 3px"
|
|
7934
7934
|
return string.split(' ').map(function(segment){return parseLengthOrPercentage(segment);});}else {// [1, '2px', 3]
|
|
7935
7935
|
return string.map(function(segment){return parseLengthOrPercentage(segment.toString());});}}// export function mergeDimensionList(
|
|
7936
7936
|
// left: CSSUnitValue[],
|
|
@@ -7949,7 +7949,8 @@
|
|
|
7949
7949
|
// },
|
|
7950
7950
|
// ];
|
|
7951
7951
|
// }
|
|
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();
|
|
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;var size=0;if(!AABB.isEmpty(bounds)){size=bounds.halfExtents[vec3Index]*2;}return Number(valueWithUnit.value)/100*size;}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)
|
|
7953
7954
|
// return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
|
|
7954
7955
|
return x.toString();}/**
|
|
7955
7956
|
* parse string or number to CSSUnitValue(numeric)
|
|
@@ -8326,7 +8327,7 @@
|
|
|
8326
8327
|
// scaling: vec3.fromValues(1, 1, 1),
|
|
8327
8328
|
// worldTransform: mat4.create(),
|
|
8328
8329
|
// origin: vec3.fromValues(0, 0, 0),
|
|
8329
|
-
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:create$1(),localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:create$1(),origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={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: '',
|
|
8330
|
+
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:create$1(),localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:create$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: '',
|
|
8330
8331
|
// fillOpacity: '',
|
|
8331
8332
|
// strokeOpacity: '',
|
|
8332
8333
|
// transformOrigin: '',
|
|
@@ -8591,10 +8592,10 @@
|
|
|
8591
8592
|
*/;_proto.setLocalMatrix=function setLocalMatrix(mat){var _decompose2=decompose(mat),tx=_decompose2[0],ty=_decompose2[1],scalingX=_decompose2[2],scalingY=_decompose2[3],angle=_decompose2[4];this.setLocalEulerAngles(angle).setLocalPosition(tx,ty).setLocalScale(scalingX,scalingY);}/**
|
|
8592
8593
|
* Use `visibility: visible` instead.
|
|
8593
8594
|
* @deprecated
|
|
8594
|
-
*/;_proto.show=function show(){this.style.visibility='visible';}/**
|
|
8595
|
+
*/;_proto.show=function show(){if(runtime.enableCSSParsing){this.style.visibility='visible';}else {this.forEach(function(object){object.style.visibility='visible';});}}/**
|
|
8595
8596
|
* Use `visibility: hidden` instead.
|
|
8596
8597
|
* @deprecated
|
|
8597
|
-
*/;_proto.hide=function hide(){this.style.visibility='hidden';}/**
|
|
8598
|
+
*/;_proto.hide=function hide(){if(runtime.enableCSSParsing){this.style.visibility='hidden';}else {this.forEach(function(object){object.style.visibility='hidden';});}}/**
|
|
8598
8599
|
* Use `childElementCount` instead.
|
|
8599
8600
|
* @deprecated
|
|
8600
8601
|
*/;_proto.getCount=function getCount(){return this.childElementCount;}/**
|
|
@@ -8792,7 +8793,7 @@
|
|
|
8792
8793
|
// n: 'whiteSpace',
|
|
8793
8794
|
// l: true,
|
|
8794
8795
|
// },
|
|
8795
|
-
{n:'markerStart',syntax:exports.PropertySyntax.MARKER},{n:'markerEnd',syntax:exports.PropertySyntax.MARKER},{n:'markerMid',syntax:exports.PropertySyntax.MARKER},{n:'markerStartOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'},{n:'markerEndOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'}];var propertyMetadataCache={};var unresolvedProperties=new WeakMap();// const uniqueAttributeSet = new Set<string>();
|
|
8796
|
+
{n:'markerStart',syntax:exports.PropertySyntax.MARKER},{n:'markerEnd',syntax:exports.PropertySyntax.MARKER},{n:'markerMid',syntax:exports.PropertySyntax.MARKER},{n:'markerStartOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'},{n:'markerEndOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'}];var GEOMETRY_ATTRIBUTE_NAMES=BUILT_IN_PROPERTIES.filter(function(n){return !!n.l;}).map(function(n){return n.n;});var propertyMetadataCache={};var unresolvedProperties=new WeakMap();// const uniqueAttributeSet = new Set<string>();
|
|
8796
8797
|
// const tmpVec3a = vec3.create();
|
|
8797
8798
|
// const tmpVec3b = vec3.create();
|
|
8798
8799
|
// const tmpVec3c = vec3.create();
|
|
@@ -8815,7 +8816,7 @@
|
|
|
8815
8816
|
attributes.path=attributes.d;}if(attributes.strokeDasharray){attributes.lineDash=attributes.strokeDasharray;}if(attributes.strokeWidth){attributes.lineWidth=attributes.strokeWidth;}// @ts-ignore
|
|
8816
8817
|
if(attributes.textAnchor){// @ts-ignore
|
|
8817
8818
|
attributes.textAlign=attributes.textAnchor;}Object.assign(object.attributes,attributes);var _attributeNames=Object.keys(attributes);// clipPath
|
|
8818
|
-
var oldClipPath=object.parsedStyle.clipPath;var oldOffsetPath=object.parsedStyle.offsetPath;object.parsedStyle=Object.assign(object.parsedStyle,attributes);if(attributes.fill){object.parsedStyle.fill=parseColor(attributes.fill);}if(attributes.stroke){object.parsedStyle.stroke=parseColor(attributes.stroke);}if(attributes.shadowColor){object.parsedStyle.shadowColor=parseColor(attributes.shadowColor);}if(attributes.filter){object.parsedStyle.filter=parseFilter(attributes.filter);}// Rect
|
|
8819
|
+
var oldClipPath=object.parsedStyle.clipPath;var oldOffsetPath=object.parsedStyle.offsetPath;object.parsedStyle=Object.assign(object.parsedStyle,attributes);var _needUpdateGeometry=!!options.forceUpdateGeometry;if(!_needUpdateGeometry){for(var i=0;i<GEOMETRY_ATTRIBUTE_NAMES.length;i++){if(GEOMETRY_ATTRIBUTE_NAMES[i]in attributes){_needUpdateGeometry=true;break;}}}if(attributes.fill){object.parsedStyle.fill=parseColor(attributes.fill);}if(attributes.stroke){object.parsedStyle.stroke=parseColor(attributes.stroke);}if(attributes.shadowColor){object.parsedStyle.shadowColor=parseColor(attributes.shadowColor);}if(attributes.filter){object.parsedStyle.filter=parseFilter(attributes.filter);}// Rect
|
|
8819
8820
|
// @ts-ignore
|
|
8820
8821
|
if(!isNil(attributes.radius)){// @ts-ignore
|
|
8821
8822
|
object.parsedStyle.radius=parseDimensionArrayFormat(// @ts-ignore
|
|
@@ -8856,7 +8857,7 @@
|
|
|
8856
8857
|
!isNil(attributes.y2)||// @ts-ignore
|
|
8857
8858
|
!isNil(attributes.z2))){runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.zIndex)){runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object,_attributeNames);}// @ts-ignore
|
|
8858
8859
|
if(attributes.path){runtime.CSSPropertySyntaxFactory['<path>'].postProcessor(object,_attributeNames);}// @ts-ignore
|
|
8859
|
-
if(attributes.points){runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.offsetDistance)){runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,_attributeNames);}if(attributes.transform){runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,_attributeNames);}
|
|
8860
|
+
if(attributes.points){runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.offsetDistance)){runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,_attributeNames);}if(attributes.transform){runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,_attributeNames);}if(_needUpdateGeometry){object.geometry.dirty=true;runtime.sceneGraphService.dirtifyToRoot(object);}return;}var _options=options,skipUpdateAttribute=_options.skipUpdateAttribute,skipParse=_options.skipParse,forceUpdateGeometry=_options.forceUpdateGeometry,usedAttributes=_options.usedAttributes;var needUpdateGeometry=forceUpdateGeometry;var attributeNames=Object.keys(attributes);attributeNames.forEach(function(attributeName){var _propertyMetadataCach;var name=formatAttributeName(attributeName);if(!skipUpdateAttribute){object.attributes[name]=attributes[attributeName];}if(!needUpdateGeometry&&((_propertyMetadataCach=propertyMetadataCache[name])===null||_propertyMetadataCach===void 0?void 0:_propertyMetadataCach.l)){needUpdateGeometry=true;}});if(!skipParse){attributeNames.forEach(function(name){object.computedStyle[name]=_this2.parseProperty(name,object.attributes[name],object);});}// let hasUnresolvedProperties = false;
|
|
8860
8861
|
// parse according to priority
|
|
8861
8862
|
// path 50
|
|
8862
8863
|
// points 50
|
|
@@ -8887,7 +8888,7 @@
|
|
|
8887
8888
|
// return;
|
|
8888
8889
|
// }
|
|
8889
8890
|
// update geometry
|
|
8890
|
-
if(needUpdateGeometry){
|
|
8891
|
+
if(needUpdateGeometry){object.geometry.dirty=true;runtime.sceneGraphService.dirtifyToRoot(object);}attributeNames.forEach(function(name){if(name in object.parsedStyle){_this2.postProcessProperty(name,object,attributeNames);}});if(runtime.enableCSSParsing&&object.children.length){attributeNames.forEach(function(name){if(name in object.parsedStyle&&_this2.isPropertyInheritable(name)){// update children's inheritable
|
|
8891
8892
|
object.children.forEach(function(child){child.internalSetAttribute(name,null,{skipUpdateAttribute:true,skipParse:true});});}});}}/**
|
|
8892
8893
|
* string -> parsed value
|
|
8893
8894
|
*/;_proto.parseProperty=function parseProperty(name,value,object){var metadata=propertyMetadataCache[name];var computed=value;if(value===''||isNil(value)){value='unset';}if(value==='unset'||value==='initial'||value==='inherit'){// computed = new CSSKeywordValue(value);
|
|
@@ -8956,7 +8957,10 @@
|
|
|
8956
8957
|
}geometry.renderBounds.update(center,halfExtents);// account for shadow, only support constant value now
|
|
8957
8958
|
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()
|
|
8958
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;// set transform origin
|
|
8959
|
-
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);
|
|
8960
|
+
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);geometry.dirty=false;// console.log('calc geometry', object);
|
|
8961
|
+
// FIXME setOrigin may have already dirtified to root.
|
|
8962
|
+
// runtime.sceneGraphService.dirtifyToRoot(object);
|
|
8963
|
+
}};_proto.isPropertyInheritable=function isPropertyInheritable(name){var metadata=propertyMetadataCache[name];if(!metadata){return false;}return metadata.inh;};return DefaultStyleValueRegistry;}();/**
|
|
8960
8964
|
* Different type of cameras, eg. simple camera used in 2D scene or
|
|
8961
8965
|
* advanced camera which can do actions & switch between landmarks.
|
|
8962
8966
|
*/(function(CameraType){/**
|
|
@@ -9064,12 +9068,13 @@
|
|
|
9064
9068
|
this._getDistance();}/**
|
|
9065
9069
|
* 重新计算视距
|
|
9066
9070
|
*/;_proto._getDistance=function _getDistance(){this.distanceVector=subtract$1(create$2(),this.focalPoint,this.position);this.distance=length(this.distanceVector);this.dollyingStep=this.distance/100;};_proto._getOrthoMatrix=function _getOrthoMatrix(){if(this.projectionMode!==exports.CameraProjectionMode.ORTHOGRAPHIC){return;}var position=this.position;var rotZ=setAxisAngle(create$4(),[0,0,1],-this.roll*Math.PI/180);fromRotationTranslationScaleOrigin(this.orthoMatrix,rotZ,fromValues$2((this.rright-this.left)/2-position[0],(this.top-this.bottom)/2-position[1],0),fromValues$2(this.zoom,this.zoom,1),position);};_proto.triggerUpdate=function triggerUpdate(){if(this.enableUpdate){// update frustum
|
|
9067
|
-
var viewMatrix=this.getViewTransform();var vpMatrix=multiply(create$1(),this.getPerspective(),viewMatrix);this.getFrustum().extractFromVPMatrix(vpMatrix);this.eventEmitter.emit(CameraEvent.UPDATED);}};_proto.rotate=function rotate(azimuth,elevation,roll){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.pan=function pan(tx,ty){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.dolly=function dolly(value){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.createLandmark=function createLandmark(name,params){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.gotoLandmark=function gotoLandmark(name,options){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};return Camera;}();var CircleUpdater=/*#__PURE__*/function(){function CircleUpdater(){}var _proto=CircleUpdater.prototype;_proto.update=function update(parsedStyle,object){var r=parsedStyle.r;var width=r*2;var height=r*2;return {width:width,height:height};};return CircleUpdater;}();var EllipseUpdater=/*#__PURE__*/function(){function EllipseUpdater(){}var _proto=EllipseUpdater.prototype;_proto.update=function update(parsedStyle,object){var rx=parsedStyle.rx,ry=parsedStyle.ry;var width=rx*2;var height=ry*2;return {width:width,height:height};};return EllipseUpdater;}();var LineUpdater=/*#__PURE__*/function(){function LineUpdater(){}var _proto=LineUpdater.prototype;_proto.update=function update(parsedStyle){var x1=parsedStyle.x1,y1=parsedStyle.y1,x2=parsedStyle.x2,y2=parsedStyle.y2;var minX=Math.min(x1,x2);var maxX=Math.max(x1,x2);var minY=Math.min(y1,y2);var maxY=Math.max(y1,y2);var width=maxX-minX;var height=maxY-minY;return {width:width,height:height};};return LineUpdater;}();var PathUpdater=/*#__PURE__*/function(){function PathUpdater(){}var _proto=PathUpdater.prototype;_proto.update=function update(parsedStyle){var path=parsedStyle.path;var _path$rect=path.rect,width=_path$rect.width,height=_path$rect.height;return {width:width,height:height};};return PathUpdater;}();var PolylineUpdater=/*#__PURE__*/function(){function PolylineUpdater(){}var _proto=PolylineUpdater.prototype;_proto.update=function update(parsedStyle){var points=parsedStyle.points.points;// FIXME: account for miter lineJoin
|
|
9071
|
+
var viewMatrix=this.getViewTransform();var vpMatrix=multiply(create$1(),this.getPerspective(),viewMatrix);this.getFrustum().extractFromVPMatrix(vpMatrix);this.eventEmitter.emit(CameraEvent.UPDATED);}};_proto.rotate=function rotate(azimuth,elevation,roll){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.pan=function pan(tx,ty){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.dolly=function dolly(value){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.createLandmark=function createLandmark(name,params){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.gotoLandmark=function gotoLandmark(name,options){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.cancelLandmarkAnimation=function cancelLandmarkAnimation(){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};return Camera;}();var CircleUpdater=/*#__PURE__*/function(){function CircleUpdater(){}var _proto=CircleUpdater.prototype;_proto.update=function update(parsedStyle,object){var r=parsedStyle.r;var width=r*2;var height=r*2;return {width:width,height:height};};return CircleUpdater;}();var EllipseUpdater=/*#__PURE__*/function(){function EllipseUpdater(){}var _proto=EllipseUpdater.prototype;_proto.update=function update(parsedStyle,object){var rx=parsedStyle.rx,ry=parsedStyle.ry;var width=rx*2;var height=ry*2;return {width:width,height:height};};return EllipseUpdater;}();var LineUpdater=/*#__PURE__*/function(){function LineUpdater(){}var _proto=LineUpdater.prototype;_proto.update=function update(parsedStyle){var x1=parsedStyle.x1,y1=parsedStyle.y1,x2=parsedStyle.x2,y2=parsedStyle.y2;var minX=Math.min(x1,x2);var maxX=Math.max(x1,x2);var minY=Math.min(y1,y2);var maxY=Math.max(y1,y2);var width=maxX-minX;var height=maxY-minY;return {width:width,height:height};};return LineUpdater;}();var PathUpdater=/*#__PURE__*/function(){function PathUpdater(){}var _proto=PathUpdater.prototype;_proto.update=function update(parsedStyle){var path=parsedStyle.path;var _path$rect=path.rect,width=_path$rect.width,height=_path$rect.height;return {width:width,height:height};};return PathUpdater;}();var PolylineUpdater=/*#__PURE__*/function(){function PolylineUpdater(){}var _proto=PolylineUpdater.prototype;_proto.update=function update(parsedStyle){var points=parsedStyle.points.points;// FIXME: account for miter lineJoin
|
|
9068
9072
|
var minX=Math.min.apply(Math,points.map(function(point){return point[0];}));var maxX=Math.max.apply(Math,points.map(function(point){return point[0];}));var minY=Math.min.apply(Math,points.map(function(point){return point[1];}));var maxY=Math.max.apply(Math,points.map(function(point){return point[1];}));var width=maxX-minX;var height=maxY-minY;return {width:width,height:height};};return PolylineUpdater;}();var RectUpdater=/*#__PURE__*/function(){function RectUpdater(){}var _proto=RectUpdater.prototype;_proto.update=function update(parsedStyle,object){var img=parsedStyle.img,_parsedStyle$width=parsedStyle.width,width=_parsedStyle$width===void 0?0:_parsedStyle$width,_parsedStyle$height=parsedStyle.height,height=_parsedStyle$height===void 0?0:_parsedStyle$height;var contentWidth=width;var contentHeight=height;// resize with HTMLImageElement's size
|
|
9069
9073
|
if(img&&!isString(img)){if(!contentWidth){contentWidth=img.width;parsedStyle.width=contentWidth;}if(!contentHeight){contentHeight=img.height;parsedStyle.height=contentHeight;}}return {width:contentWidth,height:contentHeight};};return RectUpdater;}();var TextUpdater=/*#__PURE__*/function(){function TextUpdater(globalRuntime){this.globalRuntime=void 0;this.globalRuntime=globalRuntime;}var _proto=TextUpdater.prototype;_proto.isReadyToMeasure=function isReadyToMeasure(parsedStyle,object){var text=parsedStyle.text,textAlign=parsedStyle.textAlign,textBaseline=parsedStyle.textBaseline,fontSize=parsedStyle.fontSize,fontStyle=parsedStyle.fontStyle,fontWeight=parsedStyle.fontWeight,fontVariant=parsedStyle.fontVariant,lineWidth=parsedStyle.lineWidth;return text&&fontSize&&fontStyle&&fontWeight&&fontVariant&&textAlign&&textBaseline&&!isNil(lineWidth);};_proto.update=function update(parsedStyle,object){var _object$ownerDocument,_object$ownerDocument2;var text=parsedStyle.text,textAlign=parsedStyle.textAlign,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,dx=parsedStyle.dx,dy=parsedStyle.dy;var _ref=(object===null||object===void 0?void 0:(_object$ownerDocument=object.ownerDocument)===null||_object$ownerDocument===void 0?void 0:(_object$ownerDocument2=_object$ownerDocument.defaultView)===null||_object$ownerDocument2===void 0?void 0:_object$ownerDocument2.getConfig())||{},offscreenCanvas=_ref.offscreenCanvas;if(!this.isReadyToMeasure(parsedStyle,object)){parsedStyle.metrics={font:'',width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]};return {width:0,height:0,x:0,y:0,offsetX:0,offsetY:0};}var metrics=this.globalRuntime.textService.measureText(text,parsedStyle,offscreenCanvas);parsedStyle.metrics=metrics;var width=metrics.width,height=metrics.height,lineHeight=metrics.lineHeight,fontProperties=metrics.fontProperties;// anchor is left-top by default
|
|
9070
9074
|
var halfExtents=[width/2,height/2,0];// default 'left'
|
|
9071
9075
|
var anchor=[0,1];var lineXOffset=0;if(textAlign==='center'||textAlign==='middle'){lineXOffset=lineWidth/2;anchor=[0.5,1];}else if(textAlign==='right'||textAlign==='end'){lineXOffset=lineWidth;anchor=[1,1];}var lineYOffset=0;if(textBaseline==='middle'){// eslint-disable-next-line prefer-destructuring
|
|
9072
|
-
lineYOffset=halfExtents[1];}else if(textBaseline==='top'||textBaseline==='hanging'){lineYOffset=halfExtents[1]*2;}else if(textBaseline==='alphabetic'){
|
|
9076
|
+
lineYOffset=halfExtents[1];}else if(textBaseline==='top'||textBaseline==='hanging'){lineYOffset=halfExtents[1]*2;}else if(textBaseline==='alphabetic'){// prevent calling getImageData for ascent metrics
|
|
9077
|
+
lineYOffset=runtime.enableCSSParsing?lineHeight-fontProperties.ascent:0;}else if(textBaseline==='bottom'||textBaseline==='ideographic'){lineYOffset=0;}// TODO: ideographic & bottom
|
|
9073
9078
|
if(dx){lineXOffset+=dx;}if(dy){lineYOffset+=dy;}// update anchor
|
|
9074
9079
|
parsedStyle.anchor=[anchor[0],anchor[1],0];return {width:halfExtents[0]*2,height:halfExtents[1]*2,offsetX:lineXOffset,offsetY:lineYOffset};};return TextUpdater;}();var PROPAGATION_LIMIT=2048;var EventService=/*#__PURE__*/function(){function EventService(globalRuntime,context){var _this=this;this.globalRuntime=void 0;this.context=void 0;this.rootTarget=void 0;this.emitter=new eventemitter3();this.cursor='default';this.mappingTable={};this.mappingState={trackingData:{}};this.eventPool=new Map();this.pickHandler=void 0;this.tmpMatrix=create$1();this.tmpVec3=create$2();this.onPointerDown=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(from){var e,isRightButton,trackingData;return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _this.createPointerEvent(from);case 2:e=_context.sent;_this.dispatchEvent(e,'pointerdown');if(e.pointerType==='touch'){_this.dispatchEvent(e,'touchstart');}else if(e.pointerType==='mouse'||e.pointerType==='pen'){isRightButton=e.button===2;_this.dispatchEvent(e,isRightButton?'rightdown':'mousedown');}trackingData=_this.trackingData(from.pointerId);trackingData.pressTargetsByButton[from.button]=e.composedPath();_this.freeEvent(e);case 8:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}();this.onPointerUp=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(from){var now,e,isRightButton,trackingData,pressTarget,clickTarget,currentTarget,_isRightButton,_e$detail,clickEvent,clickHistory;return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:// if (!(from instanceof FederatedPointerEvent)) {
|
|
9075
9080
|
// return;
|
|
@@ -9283,7 +9288,7 @@
|
|
|
9283
9288
|
this.pendingEvents.push([element,{affectChildren:affectChildren}]);};_proto.updateDisplayObjectDependency=function updateDisplayObjectDependency(name,oldPath,newPath,object){// clear ref to old clip path
|
|
9284
9289
|
if(oldPath&&oldPath!==newPath){var oldDependencyMap=this.displayObjectDependencyMap.get(oldPath);if(oldDependencyMap&&oldDependencyMap[name]){var index=oldDependencyMap[name].indexOf(object);oldDependencyMap[name].splice(index,1);}}if(newPath){var newDependencyMap=this.displayObjectDependencyMap.get(newPath);if(!newDependencyMap){this.displayObjectDependencyMap.set(newPath,{});newDependencyMap=this.displayObjectDependencyMap.get(newPath);}if(!newDependencyMap[name]){newDependencyMap[name]=[];}newDependencyMap[name].push(object);}};_proto.informDependentDisplayObjects=function informDependentDisplayObjects(object){var _this3=this;var dependencyMap=this.displayObjectDependencyMap.get(object);if(dependencyMap){Object.keys(dependencyMap).forEach(function(name){dependencyMap[name].forEach(function(target){_this3.dirtifyToRoot(target,true);target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,target,_this3,_this3,name,MutationEvent.MODIFICATION,_this3,_this3));if(target.isCustomElement&&target.isConnected){if(target.attributeChangedCallback){target.attributeChangedCallback(name,_this3,_this3);}}});});}};_proto.getPosition=function getPosition(element){var transform=element.transformable;return getTranslation(transform.position,this.getWorldTransform(element,transform));};_proto.getRotation=function getRotation$1(element){var transform=element.transformable;return getRotation(transform.rotation,this.getWorldTransform(element,transform));};_proto.getScale=function getScale(element){var transform=element.transformable;return getScaling(transform.scaling,this.getWorldTransform(element,transform));};_proto.getWorldTransform=function getWorldTransform(element,transform){if(transform===void 0){transform=element.transformable;}if(!transform.localDirtyFlag&&!transform.dirtyFlag){return transform.worldTransform;}if(element.parentNode&&element.parentNode.transformable){this.getWorldTransform(element.parentNode);}this.sync(element,transform);return transform.worldTransform;};_proto.getLocalPosition=function getLocalPosition(element){return element.transformable.localPosition;};_proto.getLocalRotation=function getLocalRotation(element){return element.transformable.localRotation;};_proto.getLocalScale=function getLocalScale(element){return element.transformable.localScale;};_proto.getLocalSkew=function getLocalSkew(element){return element.transformable.localSkew;};_proto.getLocalTransform=function getLocalTransform(element){var transform=element.transformable;if(transform.localDirtyFlag){this.calcLocalTransform(transform);transform.localDirtyFlag=false;}return transform.localTransform;};_proto.setLocalTransform=function setLocalTransform(element,transform){var t=getTranslation(create$2(),transform);var r=getRotation(create$4(),transform);var s=getScaling(create$2(),transform);this.setLocalScale(element,s);this.setLocalPosition(element,t);this.setLocalRotation(element,r);};_proto.resetLocalTransform=function resetLocalTransform(element){this.setLocalScale(element,[1,1,1]);this.setLocalPosition(element,[0,0,0]);this.setLocalEulerAngles(element,[0,0,0]);this.setLocalSkew(element,[0,0]);};_proto.getTransformedGeometryBounds=function getTransformedGeometryBounds(element,render,existedAABB){if(render===void 0){render=false;}var bounds=this.getGeometryBounds(element,render);if(!AABB.isEmpty(bounds)){var aabb=existedAABB||new AABB();aabb.setFromTransformedAABB(bounds,this.getWorldTransform(element));return aabb;}else {return null;}}/**
|
|
9285
9290
|
* won't account for children
|
|
9286
|
-
*/;_proto.getGeometryBounds=function getGeometryBounds(element,render){if(render===void 0){render=false;}var geometry=element.geometry;var bounds=render?geometry.renderBounds:geometry.contentBounds||null;// return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
|
|
9291
|
+
*/;_proto.getGeometryBounds=function getGeometryBounds(element,render){if(render===void 0){render=false;}var geometry=element.geometry;if(geometry.dirty){runtime.styleValueRegistry.updateGeometry(element);}var bounds=render?geometry.renderBounds:geometry.contentBounds||null;// return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
|
|
9287
9292
|
return bounds||new AABB();}/**
|
|
9288
9293
|
* account for children in world space
|
|
9289
9294
|
*/;_proto.getBounds=function getBounds(element,render){var _this4=this;if(render===void 0){render=false;}var renderable=element.renderable;if(!renderable.boundsDirty&&!render&&renderable.bounds){return renderable.bounds;}if(!renderable.renderBoundsDirty&&render&&renderable.renderBounds){return renderable.renderBounds;}// reuse existed if possible
|
|
@@ -9313,9 +9318,9 @@
|
|
|
9313
9318
|
canvas.width=width;// @ts-ignore
|
|
9314
9319
|
canvas.height=height;context.fillStyle='#f00';context.fillRect(0,0,width,height);context.font=font;context.textBaseline='alphabetic';context.fillStyle='#000';context.fillText(metricsString,0,baseline);var imagedata=context.getImageData(0,0,width||1,height||1).data;var pixels=imagedata.length;var line=width*4;var i=0;var idx=0;var stop=false;// ascent. scan from top to bottom until we find a non red pixel
|
|
9315
9320
|
for(i=0;i<baseline;++i){for(var j=0;j<line;j+=4){if(imagedata[idx+j]!==255){stop=true;break;}}if(!stop){idx+=line;}else {break;}}properties.ascent=baseline-i;idx=pixels-line;stop=false;// descent. scan from bottom to top until we find a non red pixel
|
|
9316
|
-
for(i=height;i>baseline;--i){for(var _j=0;_j<line;_j+=4){if(imagedata[idx+_j]!==255){stop=true;break;}}if(!stop){idx-=line;}else {break;}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;this.fontMetricsCache[font]=properties;return properties;};_proto.measureText=function measureText(text,parsedStyle,offscreenCanvas){var fontSize=parsedStyle.fontSize,wordWrap=parsedStyle.wordWrap,strokeHeight=parsedStyle.lineHeight,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,textAlign=parsedStyle.textAlign,letterSpacing=parsedStyle.letterSpacing,textPath=parsedStyle.textPath,textPathSide=parsedStyle.textPathSide,textPathStartOffset=parsedStyle.textPathStartOffset,_parsedStyle$leading=parsedStyle.leading,leading=_parsedStyle$leading===void 0?0:_parsedStyle$leading;var font=toFontString(parsedStyle);var fontProperties=this.measureFont(font,offscreenCanvas);// fallback in case UA disallow canvas data extraction
|
|
9321
|
+
for(i=height;i>baseline;--i){for(var _j=0;_j<line;_j+=4){if(imagedata[idx+_j]!==255){stop=true;break;}}if(!stop){idx-=line;}else {break;}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;this.fontMetricsCache[font]=properties;return properties;};_proto.measureText=function measureText(text,parsedStyle,offscreenCanvas){var fontSize=parsedStyle.fontSize,wordWrap=parsedStyle.wordWrap,strokeHeight=parsedStyle.lineHeight,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,textAlign=parsedStyle.textAlign,letterSpacing=parsedStyle.letterSpacing,textPath=parsedStyle.textPath,textPathSide=parsedStyle.textPathSide,textPathStartOffset=parsedStyle.textPathStartOffset,_parsedStyle$leading=parsedStyle.leading,leading=_parsedStyle$leading===void 0?0:_parsedStyle$leading;var font=toFontString(parsedStyle);var fontProperties;if(runtime.enableCSSParsing){fontProperties=this.measureFont(font,offscreenCanvas);// fallback in case UA disallow canvas data extraction
|
|
9317
9322
|
// (toDataURI, getImageData functions)
|
|
9318
|
-
if(fontProperties.fontSize===0){fontProperties.fontSize=fontSize;fontProperties.ascent=fontSize;}var context=this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;// no overflowing by default
|
|
9323
|
+
if(fontProperties.fontSize===0){fontProperties.fontSize=fontSize;fontProperties.ascent=fontSize;}}else {fontProperties={fontSize:fontSize};}var context=this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;// no overflowing by default
|
|
9319
9324
|
parsedStyle.isOverflowing=false;var outputText=wordWrap?this.wordWrap(text,parsedStyle,offscreenCanvas):text;var lines=outputText.split(/(?:\r\n|\r|\n)/);var lineWidths=new Array(lines.length);var maxLineWidth=0;// account for textPath
|
|
9320
9325
|
if(textPath){var totalPathLength=textPath.getTotalLength();// const startingPoint = textPath.getPoint(0);
|
|
9321
9326
|
for(var i=0;i<lines.length;i++){var width=context.measureText(lines[i]).width+(lines[i].length-1)*letterSpacing;// for (
|
|
@@ -9430,23 +9435,32 @@
|
|
|
9430
9435
|
// 使用 p-vertex 和 n-vertex 加速,避免进行平面和 aabb 全部顶点的相交检测
|
|
9431
9436
|
var _planes$k=planes[k],normal=_planes$k.normal,distance=_planes$k.distance;if(dot(normal,aabb.getPositiveFarPoint(planes[k]))+distance<0){return exports.Mask.OUTSIDE;}if(dot(normal,aabb.getNegativeFarPoint(planes[k]))+distance<0){// 和当前面相交,对应位置为1,继续检测下一个面
|
|
9432
9437
|
mask|=flag;}}return mask;};return FrustumCullingStrategy;}();var PrepareRendererPlugin=/*#__PURE__*/function(){function PrepareRendererPlugin(){this.rBush=void 0;this.toSync=new Set();}var _proto=PrepareRendererPlugin.prototype;// private isFirstTimeRendering = true;
|
|
9438
|
+
// private syncing = false;
|
|
9433
9439
|
_proto.apply=function apply(context){var _this=this;var renderingService=context.renderingService,renderingContext=context.renderingContext,rBushRoot=context.rBushRoot;var canvas=renderingContext.root.ownerDocument.defaultView;this.rBush=rBushRoot;var handleAttributeChanged=function handleAttributeChanged(e){var object=e.target;object.renderable.dirty=true;renderingService.dirtify();};var handleBoundsChanged=function handleBoundsChanged(e){var affectChildren=e.detail.affectChildren;var object=e.target;if(affectChildren){object.forEach(function(node){_this.toSync.add(node);});}var p=object;while(p){if(p.renderable){_this.toSync.add(p);}p=p.parentElement;}// this.pushToSync(e.composedPath().slice(0, -2) as DisplayObject[]);
|
|
9434
9440
|
renderingService.dirtify();};var handleMounted=function handleMounted(e){var object=e.target;if(runtime.enableCSSParsing){// recalc style values
|
|
9435
9441
|
runtime.styleValueRegistry.recalc(object);}runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};var handleUnmounted=function handleUnmounted(e){var object=e.target;var rBushNode=object.rBushNode;if(rBushNode.aabb){_this.rBush.remove(rBushNode.aabb);}_this.toSync.delete(object);runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};renderingService.hooks.init.tapPromise(PrepareRendererPlugin.tag,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:canvas.addEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.addEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);case 4:case"end":return _context.stop();}}},_callee);})));renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag,function(){canvas.removeEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.removeEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);_this.toSync.clear();});renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag,function(){// if (this.isFirstTimeRendering) {
|
|
9436
|
-
// // @see https://github.com/antvis/G/issues/1117
|
|
9437
|
-
// setTimeout(() => this.syncRTree());
|
|
9438
9442
|
// this.isFirstTimeRendering = false;
|
|
9443
|
+
// this.syncing = true;
|
|
9444
|
+
// // @see https://github.com/antvis/G/issues/1117
|
|
9445
|
+
// setTimeout(() => {
|
|
9446
|
+
// this.syncRTree();
|
|
9447
|
+
// console.log('fcp...');
|
|
9448
|
+
// });
|
|
9439
9449
|
// } else {
|
|
9440
|
-
//
|
|
9450
|
+
// console.log('next...');
|
|
9451
|
+
_this.syncRTree();// }
|
|
9452
|
+
});};_proto.syncRTree=function syncRTree(){var _this2=this;// if (this.syncing) {
|
|
9453
|
+
// return;
|
|
9441
9454
|
// }
|
|
9442
|
-
|
|
9455
|
+
// bounds changed, need re-inserting its children
|
|
9443
9456
|
var bulk=[];Array.from(this.toSync)// some objects may be removed since last frame
|
|
9444
9457
|
.filter(function(object){return object.isConnected;}).forEach(function(node){var rBushNode=node.rBushNode;// clear dirty node
|
|
9445
9458
|
if(rBushNode&&rBushNode.aabb){_this2.rBush.remove(rBushNode.aabb);}var renderBounds=node.getRenderBounds();if(renderBounds){var _renderBounds$getMin=renderBounds.getMin(),minX=_renderBounds$getMin[0],minY=_renderBounds$getMin[1];var _renderBounds$getMax=renderBounds.getMax(),maxX=_renderBounds$getMax[0],maxY=_renderBounds$getMax[1];if(!rBushNode.aabb){// @ts-ignore
|
|
9446
9459
|
rBushNode.aabb={};}rBushNode.aabb.id=node.entity;rBushNode.aabb.minX=minX;rBushNode.aabb.minY=minY;rBushNode.aabb.maxX=maxX;rBushNode.aabb.maxY=maxY;}if(rBushNode.aabb){// TODO: NaN occurs when width/height of Rect is 0
|
|
9447
9460
|
if(!isNaN(rBushNode.aabb.maxX)&&!isNaN(rBushNode.aabb.maxX)&&!isNaN(rBushNode.aabb.minX)&&!isNaN(rBushNode.aabb.minY)){bulk.push(rBushNode.aabb);}}});// use bulk inserting, which is ~2-3 times faster
|
|
9448
9461
|
// @see https://github.com/mourner/rbush#bulk-inserting-data
|
|
9449
|
-
this.rBush.load(bulk);bulk.length=0;this.toSync.clear()
|
|
9462
|
+
this.rBush.load(bulk);bulk.length=0;this.toSync.clear();// this.syncing = false;
|
|
9463
|
+
};return PrepareRendererPlugin;}();PrepareRendererPlugin.tag='Prepare';function isCanvas(value){return !!value.document;}(function(CanvasEvent){CanvasEvent["READY"]="ready";CanvasEvent["BEFORE_RENDER"]="beforerender";CanvasEvent["RERENDER"]="rerender";CanvasEvent["AFTER_RENDER"]="afterrender";CanvasEvent["BEFORE_DESTROY"]="beforedestroy";CanvasEvent["AFTER_DESTROY"]="afterdestroy";CanvasEvent["RESIZE"]="resize";CanvasEvent["DIRTY_RECTANGLE"]="dirtyrectangle";})(exports.CanvasEvent||(exports.CanvasEvent={}));var DEFAULT_CAMERA_Z=500;var DEFAULT_CAMERA_NEAR=0.1;var DEFAULT_CAMERA_FAR=1000;/**
|
|
9450
9464
|
* reuse custom event preventing from re-create them in every frame
|
|
9451
9465
|
*/var mountedEvent=new CustomEvent(exports.ElementEvent.MOUNTED);var unmountedEvent=new CustomEvent(exports.ElementEvent.UNMOUNTED);var beforeRenderEvent=new CustomEvent(exports.CanvasEvent.BEFORE_RENDER);var rerenderEvent=new CustomEvent(exports.CanvasEvent.RERENDER);var afterRenderEvent=new CustomEvent(exports.CanvasEvent.AFTER_RENDER);/**
|
|
9452
9466
|
* can be treated like Window in DOM
|
|
@@ -9657,7 +9671,13 @@
|
|
|
9657
9671
|
this.triggerUpdate();
|
|
9658
9672
|
return this;
|
|
9659
9673
|
};
|
|
9674
|
+
_proto.cancelLandmarkAnimation = function cancelLandmarkAnimation() {
|
|
9675
|
+
if (this.landmarkAnimationID !== undefined) {
|
|
9676
|
+
this.canvas.cancelAnimationFrame(this.landmarkAnimationID);
|
|
9677
|
+
}
|
|
9678
|
+
};
|
|
9660
9679
|
_proto.createLandmark = function createLandmark(name, params) {
|
|
9680
|
+
var _position$, _position$2, _focalPoint$, _focalPoint$2;
|
|
9661
9681
|
if (params === void 0) {
|
|
9662
9682
|
params = {};
|
|
9663
9683
|
}
|
|
@@ -9670,10 +9690,10 @@
|
|
|
9670
9690
|
zoom = _params.zoom;
|
|
9671
9691
|
var camera = new runtime.CameraContribution();
|
|
9672
9692
|
camera.setType(this.type, undefined);
|
|
9673
|
-
camera.setPosition(position[0], position[1]
|
|
9674
|
-
camera.setFocalPoint(focalPoint[0], focalPoint[1]
|
|
9675
|
-
camera.setRoll(roll
|
|
9676
|
-
camera.setZoom(zoom
|
|
9693
|
+
camera.setPosition(position[0], (_position$ = position[1]) !== null && _position$ !== void 0 ? _position$ : this.position[1], (_position$2 = position[2]) !== null && _position$2 !== void 0 ? _position$2 : this.position[2]);
|
|
9694
|
+
camera.setFocalPoint(focalPoint[0], (_focalPoint$ = focalPoint[1]) !== null && _focalPoint$ !== void 0 ? _focalPoint$ : this.focalPoint[1], (_focalPoint$2 = focalPoint[2]) !== null && _focalPoint$2 !== void 0 ? _focalPoint$2 : this.focalPoint[2]);
|
|
9695
|
+
camera.setRoll(roll !== null && roll !== void 0 ? roll : this.roll);
|
|
9696
|
+
camera.setZoom(zoom !== null && zoom !== void 0 ? zoom : this.zoom);
|
|
9677
9697
|
var landmark = {
|
|
9678
9698
|
name: name,
|
|
9679
9699
|
matrix: clone(camera.getWorldTransform()),
|
|
@@ -9725,9 +9745,7 @@
|
|
|
9725
9745
|
return;
|
|
9726
9746
|
}
|
|
9727
9747
|
// cancel ongoing animation
|
|
9728
|
-
|
|
9729
|
-
this.canvas.cancelAnimationFrame(this.landmarkAnimationID);
|
|
9730
|
-
}
|
|
9748
|
+
this.cancelLandmarkAnimation();
|
|
9731
9749
|
var destPosition = landmark.position;
|
|
9732
9750
|
var destFocalPoint = landmark.focalPoint;
|
|
9733
9751
|
var destZoom = landmark.zoom;
|