@antv/g 5.12.0 → 5.12.1
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/README.md +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +0 -1
- package/dist/index.js +0 -1
- package/dist/index.umd.js +73 -161
- package/dist/index.umd.min.js +2 -2
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
English | [简体中文](./README-zh_CN.md)
|
|
2
2
|
|
|
3
|
-
The graphics and event system is compatible with the DOM Element & Event API, and the animation system is compatible with the Web
|
|
3
|
+
The graphics and event system is compatible with the DOM Element & Event API, and the animation system is compatible with the Web Animations API, so it can be adapted to existing Web-side ecologies such as D3, Hammer.js gesture library, etc. at a very low cost.
|
|
4
4
|
|
|
5
5
|
The usage is as follows, providing the following core objects and APIs.
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,cAAc,CAAC;AACtB,OAAO,4BAA4B,CAAC;AAEpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC"}
|
package/dist/index.esm.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var gCameraApi = require('@antv/g-camera-api');
|
|
6
|
-
require('@antv/g-compat');
|
|
7
6
|
var gCssLayoutApi = require('@antv/g-css-layout-api');
|
|
8
7
|
var gCssTypedOmApi = require('@antv/g-css-typed-om-api');
|
|
9
8
|
var gDomMutationObserverApi = require('@antv/g-dom-mutation-observer-api');
|
package/dist/index.umd.js
CHANGED
|
@@ -6495,7 +6495,7 @@
|
|
|
6495
6495
|
* Axis-Aligned Bounding Box
|
|
6496
6496
|
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
6497
6497
|
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
6498
|
-
*/var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};function AABB(center,halfExtents){this.center=create$2();this.halfExtents=create$2();this.min=create$2();this.max=create$2();this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){
|
|
6498
|
+
*/var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};function AABB(center,halfExtents){if(center===void 0){center=[0,0,0];}if(halfExtents===void 0){halfExtents=[0,0,0];}this.center=create$2();this.halfExtents=create$2();this.min=create$2();this.max=create$2();this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){copy$1(this.center,center);copy$1(this.halfExtents,halfExtents);sub$1(this.min,this.center,this.halfExtents);add$1(this.max,this.center,this.halfExtents);};_proto.setMinMax=function setMinMax(min,max){add$1(this.center,max,min);scale$1(this.center,this.center,0.5);sub$1(this.halfExtents,max,min);scale$1(this.halfExtents,this.halfExtents,0.5);copy$1(this.min,min);copy$1(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);set$1(bc,m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2],m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2],m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2]);set$1(br,mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2],my0a*ar[0]+my1a*ar[1]+my2a*ar[2],mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2]);this.min=sub$1(this.min,bc,br);this.max=add$1(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();var min$1=max(create$2(),this.getMin(),aabb.getMin());var max$1=min(create$2(),this.getMax(),aabb.getMax());intersection.setMinMax(min$1,max$1);return intersection;};_proto.containsPoint=function containsPoint(point){var min=this.getMin();var max=this.getMax();return !(point[0]<min[0]||point[0]>max[0]||point[1]<min[1]||point[1]>max[1]||point[2]<min[2]||point[2]>max[2]);}/**
|
|
6499
6499
|
* get n-vertex
|
|
6500
6500
|
* @param plane plane of CullingVolume
|
|
6501
6501
|
*/;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copy$1(create$2(),this.min);}else if(plane.pnVertexFlag===0x110){return fromValues$2(this.min[0],this.min[1],this.max[2]);}else if(plane.pnVertexFlag===0x101){return fromValues$2(this.min[0],this.max[1],this.min[2]);}else if(plane.pnVertexFlag===0x100){return fromValues$2(this.min[0],this.max[1],this.max[2]);}else if(plane.pnVertexFlag===0x011){return fromValues$2(this.max[0],this.min[1],this.min[2]);}else if(plane.pnVertexFlag===0x010){return fromValues$2(this.max[0],this.min[1],this.max[2]);}else if(plane.pnVertexFlag===0x001){return fromValues$2(this.max[0],this.max[1],this.min[2]);}else {return fromValues$2(this.max[0],this.max[1],this.max[2]);}}/**
|
|
@@ -7588,14 +7588,14 @@
|
|
|
7588
7588
|
// return hook;
|
|
7589
7589
|
// }
|
|
7590
7590
|
// SyncWaterfallHook.prototype = null;
|
|
7591
|
-
var genericFontFamilies=['serif','sans-serif','monospace','cursive','fantasy','system-ui'];function toFontString(attributes){var fontSize=attributes.fontSize,fontFamily=attributes.fontFamily,fontStyle=attributes.fontStyle,fontVariant=attributes.fontVariant,fontWeight=attributes.fontWeight;// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
7591
|
+
var genericFontFamilies=['serif','sans-serif','monospace','cursive','fantasy','system-ui'];var stringRegExp=/([\"\'])[^\'\"]+\1/;function toFontString(attributes){var fontSize=attributes.fontSize,fontFamily=attributes.fontFamily,fontStyle=attributes.fontStyle,fontVariant=attributes.fontVariant,fontWeight=attributes.fontWeight;// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
7592
7592
|
// const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
|
|
7593
7593
|
var fontSizeString=isNumber(fontSize)&&fontSize+"px"||'16px';// Clean-up fontFamily property by quoting each font name
|
|
7594
7594
|
// this will support font names with spaces
|
|
7595
7595
|
// @ts-ignore
|
|
7596
7596
|
var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
|
|
7597
7597
|
var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
|
|
7598
|
-
if(
|
|
7598
|
+
if(!stringRegExp.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}/**
|
|
7599
7599
|
* Blink used them in code generation(css_properties.json5)
|
|
7600
7600
|
*/var BUILT_IN_PROPERTIES=[{/**
|
|
7601
7601
|
* used in CSS Layout API
|
|
@@ -7645,7 +7645,7 @@
|
|
|
7645
7645
|
// n: 'whiteSpace',
|
|
7646
7646
|
// l: true,
|
|
7647
7647
|
// },
|
|
7648
|
-
{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=
|
|
7648
|
+
{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();var priorityMap={};var sortAttributeNames=memoize(function(attributeNames){return attributeNames.sort(function(a,b){return priorityMap[a]-priorityMap[b];});});var tmpVec3a=create$2();var tmpVec3b=create$2();var tmpVec3c=create$2();var isPropertyResolved=function isPropertyResolved(object,name){var properties=unresolvedProperties.get(object);if(!properties||properties.length===0){return true;}return properties.includes(name);};var DefaultStyleValueRegistry=/*#__PURE__*/function(){/**
|
|
7649
7649
|
* need recalc later
|
|
7650
7650
|
*/ // dirty = false;
|
|
7651
7651
|
function DefaultStyleValueRegistry(){var _this=this;BUILT_IN_PROPERTIES.forEach(function(property){_this.registerMetadata(property);});}var _proto=DefaultStyleValueRegistry.prototype;_proto.registerMetadata=function registerMetadata(metadata){[metadata.n].concat(metadata.a||[]).forEach(function(name){propertyMetadataCache[name]=metadata;priorityMap[name]=metadata.p||0;});};_proto.unregisterMetadata=function unregisterMetadata(name){delete propertyMetadataCache[name];};_proto.getPropertySyntax=function getPropertySyntax(syntax){return runtime.CSSPropertySyntaxFactory[syntax];}/**
|
|
@@ -7687,7 +7687,7 @@
|
|
|
7687
7687
|
// return false;
|
|
7688
7688
|
return used;};_proto.postProcessProperty=function postProcessProperty(name,object){var metadata=propertyMetadataCache[name];if(metadata&&metadata.syntax){var handler=metadata.syntax&&this.getPropertySyntax(metadata.syntax);var propertyHandler=handler;if(propertyHandler&&propertyHandler.postProcessor){propertyHandler.postProcessor(object);}}}/**
|
|
7689
7689
|
* resolve later
|
|
7690
|
-
*/;_proto.addUnresolveProperty=function addUnresolveProperty(object,name){if(!
|
|
7690
|
+
*/;_proto.addUnresolveProperty=function addUnresolveProperty(object,name){var properties=unresolvedProperties.get(object);if(!properties){unresolvedProperties.set(object,[]);properties=unresolvedProperties.get(object);}if(properties.indexOf(name)===-1){properties.push(name);}};_proto.tryToResolveProperty=function tryToResolveProperty(object,name,options){if(options===void 0){options={};}var _options2=options,inherited=_options2.inherited;if(inherited){if(object.parentElement&&isPropertyResolved(object.parentElement,name)){// const computedValue = object.parentElement.computedStyle[name];
|
|
7691
7691
|
var usedValue=object.parentElement.parsedStyle[name];if(// usedValue instanceof CSSKeywordValue &&
|
|
7692
7692
|
usedValue==='unset'||usedValue==='initial'||usedValue==='inherit'){return;}// else if (
|
|
7693
7693
|
// usedValue instanceof CSSUnitValue &&
|
|
@@ -7695,7 +7695,7 @@
|
|
|
7695
7695
|
// ) {
|
|
7696
7696
|
// return false;
|
|
7697
7697
|
// }
|
|
7698
|
-
return usedValue;}}return;};_proto.recalc=function recalc(object){var properties=unresolvedProperties
|
|
7698
|
+
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);}}/**
|
|
7699
7699
|
* update geometry when relative props changed,
|
|
7700
7700
|
* eg. r of Circle, width/height of Rect
|
|
7701
7701
|
*/;_proto.updateGeometry=function updateGeometry(object){var geometryUpdater=runtime.geometryUpdaterFactory[object.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;// account for negative width / height of Rect
|
|
@@ -7913,21 +7913,16 @@
|
|
|
7913
7913
|
* it has been inserted
|
|
7914
7914
|
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
|
|
7915
7915
|
*/ElementEvent["INSERTED"]="DOMNodeInserted";/**
|
|
7916
|
-
* it has had a child inserted
|
|
7917
|
-
*/ElementEvent["CHILD_INSERTED"]="child-inserted";/**
|
|
7918
7916
|
* it is being removed
|
|
7919
7917
|
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
|
|
7920
7918
|
*/ElementEvent["REMOVED"]="removed";/**
|
|
7921
|
-
* it has had a child removed
|
|
7922
|
-
*/ElementEvent["CHILD_REMOVED"]="child-removed";/**
|
|
7923
7919
|
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
|
|
7924
7920
|
*/ElementEvent["MOUNTED"]="DOMNodeInsertedIntoDocument";/**
|
|
7925
7921
|
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
|
|
7926
7922
|
*/ElementEvent["UNMOUNTED"]="DOMNodeRemovedFromDocument";ElementEvent["BOUNDS_CHANGED"]="bounds-changed";// GEOMETRY_BOUNDS_CHANGED = 'geometry-bounds-changed',
|
|
7927
7923
|
/**
|
|
7928
7924
|
* trigger when z-index changed
|
|
7929
|
-
*/ElementEvent["RENDER_ORDER_CHANGED"]="render-order-changed";ElementEvent["CULLED"]="culled";})(exports.ElementEvent||(exports.ElementEvent={}));var MutationEvent=/*#__PURE__*/function(_FederatedEvent){_inheritsLoose(MutationEvent,_FederatedEvent);function MutationEvent(typeArg,relatedNode,prevValue,newValue,attrName,attrChange,prevParsedValue,newParsedValue){var _this;_this=_FederatedEvent.call(this,null)||this;_this.relatedNode=void 0;_this.prevValue=void 0;_this.newValue=void 0;_this.attrName=void 0;_this.attrChange=void 0;_this.prevParsedValue=void 0;_this.newParsedValue=void 0;_this.relatedNode=relatedNode;_this.prevValue=prevValue;_this.newValue=newValue;_this.attrName=attrName;_this.attrChange=attrChange;_this.prevParsedValue=prevParsedValue;_this.newParsedValue=newParsedValue;_this.type=typeArg;return _this;}return MutationEvent;}(FederatedEvent);MutationEvent.ADDITION=2;MutationEvent.MODIFICATION=1;MutationEvent.REMOVAL=3;var entityCounter=0;function resetEntityCounter(){entityCounter=0;}
|
|
7930
|
-
var childInsertedEvent=new CustomEvent(exports.ElementEvent.CHILD_INSERTED,{child:null});var insertedEvent=new MutationEvent(exports.ElementEvent.INSERTED,null,'','','',0,'','');var removedEvent=new MutationEvent(exports.ElementEvent.REMOVED,null,'','','',0,'','');var destroyEvent=new CustomEvent(exports.ElementEvent.DESTROY);var childRemovedEvent=new CustomEvent(exports.ElementEvent.CHILD_REMOVED,{child:null});/**
|
|
7925
|
+
*/ElementEvent["RENDER_ORDER_CHANGED"]="render-order-changed";ElementEvent["CULLED"]="culled";})(exports.ElementEvent||(exports.ElementEvent={}));var MutationEvent=/*#__PURE__*/function(_FederatedEvent){_inheritsLoose(MutationEvent,_FederatedEvent);function MutationEvent(typeArg,relatedNode,prevValue,newValue,attrName,attrChange,prevParsedValue,newParsedValue){var _this;_this=_FederatedEvent.call(this,null)||this;_this.relatedNode=void 0;_this.prevValue=void 0;_this.newValue=void 0;_this.attrName=void 0;_this.attrChange=void 0;_this.prevParsedValue=void 0;_this.newParsedValue=void 0;_this.relatedNode=relatedNode;_this.prevValue=prevValue;_this.newValue=newValue;_this.attrName=attrName;_this.attrChange=attrChange;_this.prevParsedValue=prevParsedValue;_this.newParsedValue=newParsedValue;_this.type=typeArg;return _this;}return MutationEvent;}(FederatedEvent);MutationEvent.ADDITION=2;MutationEvent.MODIFICATION=1;MutationEvent.REMOVAL=3;var entityCounter=0;function resetEntityCounter(){entityCounter=0;}var insertedEvent=new MutationEvent(exports.ElementEvent.INSERTED,null,'','','',0,'','');var removedEvent=new MutationEvent(exports.ElementEvent.REMOVED,null,'','','',0,'','');var destroyEvent=new CustomEvent(exports.ElementEvent.DESTROY);/**
|
|
7931
7926
|
* Has following capabilities:
|
|
7932
7927
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
7933
7928
|
* * Query eg. querySelector getElementById...
|
|
@@ -7953,43 +7948,9 @@
|
|
|
7953
7948
|
};_this.attributes={};return _this;}Element.isElement=function isElement(target){return !!target.getAttribute;}/**
|
|
7954
7949
|
* Unique id.
|
|
7955
7950
|
*/;var _proto=Element.prototype;// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7956
|
-
_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.appendChild=function appendChild(child,index){runtime.sceneGraphService.attach(child,this,index)
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
// }),
|
|
7960
|
-
// );
|
|
7961
|
-
childInsertedEvent.detail.child=child;// @ts-ignore
|
|
7962
|
-
// this.ownerDocument?.defaultView?.mountChildren(child);
|
|
7963
|
-
this.dispatchEvent(childInsertedEvent);// child.emit(ElementEvent.INSERTED, {
|
|
7964
|
-
// parent: this,
|
|
7965
|
-
// index,
|
|
7966
|
-
// });
|
|
7967
|
-
insertedEvent.relatedNode=this;child.dispatchEvent(insertedEvent);return child;};_proto.insertBefore=function insertBefore(newChild,refChild){if(!refChild){this.appendChild(newChild);}else {var index=this.childNodes.indexOf(refChild);this.appendChild(newChild,index-1);}return newChild;};_proto.replaceChild=function replaceChild(newChild,oldChild){var index=this.childNodes.indexOf(oldChild);this.removeChild(oldChild);this.appendChild(newChild,index);return oldChild;};_proto.removeChild=function removeChild(child){// should emit on itself before detach
|
|
7968
|
-
// child.emit(ElementEvent.REMOVED, {
|
|
7969
|
-
// parent: this,
|
|
7970
|
-
// });
|
|
7971
|
-
removedEvent.relatedNode=this;child.dispatchEvent(removedEvent);// emit destroy event
|
|
7972
|
-
// if (destroy) {
|
|
7973
|
-
// // child.destroy();
|
|
7974
|
-
// child.dispatchEvent(destroyEvent);
|
|
7975
|
-
// (child as unknown as Element).destroyed = true;
|
|
7976
|
-
// }
|
|
7977
|
-
// emit on parent
|
|
7978
|
-
childRemovedEvent.detail.child=child;this.dispatchEvent(childRemovedEvent);// this.dispatchEvent(
|
|
7979
|
-
// new CustomEvent(ElementEvent.CHILD_REMOVED, {
|
|
7980
|
-
// child,
|
|
7981
|
-
// }),
|
|
7982
|
-
// );
|
|
7983
|
-
// remove from scene graph
|
|
7984
|
-
runtime.sceneGraphService.detach(child);// cannot emit Destroy event now
|
|
7985
|
-
// if (destroy) {
|
|
7986
|
-
// // this.removeChildren();
|
|
7987
|
-
// // remove event listeners
|
|
7988
|
-
// // @ts-ignore
|
|
7989
|
-
// child.emitter.removeAllListeners();
|
|
7990
|
-
// displayObjectPool.remove((child as unknown as Element).entity);
|
|
7991
|
-
// }
|
|
7992
|
-
return child;}/**
|
|
7951
|
+
_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.appendChild=function appendChild(child,index){var _this$ownerDocument;runtime.sceneGraphService.attach(child,this,index);if((_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:_this$ownerDocument.defaultView){this.ownerDocument.defaultView.mountChildren(child);}insertedEvent.relatedNode=this;child.dispatchEvent(insertedEvent);return child;};_proto.insertBefore=function insertBefore(newChild,refChild){if(!refChild){this.appendChild(newChild);}else {var index=this.childNodes.indexOf(refChild);this.appendChild(newChild,index-1);}return newChild;};_proto.replaceChild=function replaceChild(newChild,oldChild){var index=this.childNodes.indexOf(oldChild);this.removeChild(oldChild);this.appendChild(newChild,index);return oldChild;};_proto.removeChild=function removeChild(child){var _child$ownerDocument;// should emit on itself before detach
|
|
7952
|
+
removedEvent.relatedNode=this;child.dispatchEvent(removedEvent);if((_child$ownerDocument=child.ownerDocument)===null||_child$ownerDocument===void 0?void 0:_child$ownerDocument.defaultView){child.ownerDocument.defaultView.unmountChildren(child);}// remove from scene graph
|
|
7953
|
+
runtime.sceneGraphService.detach(child);return child;}/**
|
|
7993
7954
|
* Remove all children and destroy them.
|
|
7994
7955
|
*/;_proto.removeChildren=function removeChildren(){var _this2=this;this.childNodes.slice().forEach(function(child){_this2.removeChild(child);child.destroy();});}/**
|
|
7995
7956
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
|
@@ -8041,8 +8002,8 @@
|
|
|
8041
8002
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
|
|
8042
8003
|
*/_proto.getAttributeNames=function getAttributeNames(){return Object.keys(this.attributes);}/**
|
|
8043
8004
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
|
|
8044
|
-
*/;_proto.getAttribute=function getAttribute(name){var value=this.attributes[name];if(value===undefined){var _formatAttribute=formatAttribute(name
|
|
8045
|
-
return isNil(value)?null:value;}/**
|
|
8005
|
+
*/;_proto.getAttribute=function getAttribute(name){var value=this.attributes[name];if(value===undefined){var _formatAttribute=formatAttribute(name,''),attributeName=_formatAttribute[0];value=this.attributes[attributeName];// if the given attribute does not exist, the value returned will either be null or ""
|
|
8006
|
+
return isNil(value)?null:value;}else {return value;}}/**
|
|
8046
8007
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
|
|
8047
8008
|
*/;_proto.hasAttribute=function hasAttribute(qualifiedName){return this.getAttributeNames().includes(qualifiedName);}/**
|
|
8048
8009
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
|
|
@@ -8107,7 +8068,7 @@
|
|
|
8107
8068
|
* push to active animations after calling `animate()`
|
|
8108
8069
|
*/function DisplayObject(config){var _this$config$capture;var _this;_this=_Element.call(this)||this;// assign name, id to config
|
|
8109
8070
|
// eg. group.get('name')
|
|
8110
|
-
_this.config=void 0;_this.isCustomElement=false;_this.activeAnimations=[];_this.config=config;// compatible with G 3.0
|
|
8071
|
+
_this.config=void 0;_this.isCustomElement=false;_this.activeAnimations=[];_this.getClip=function(){return this.style.clipPath||null;};_this.config=config;// compatible with G 3.0
|
|
8111
8072
|
_this.config.interactive=(_this$config$capture=_this.config.capture)!==null&&_this$config$capture!==void 0?_this$config$capture:_this.config.interactive;// init scene graph node
|
|
8112
8073
|
_this.id=_this.config.id||'';_this.name=_this.config.name||'';if(_this.config.className||_this.config.class){_this.className=_this.config.className||_this.config.class;}_this.nodeName=_this.config.type||exports.Shape.GROUP;// compatible with G 3.0
|
|
8113
8074
|
_this.config.style=_extends({},_this.config.style,_this.config.attrs);if(_this.config.visible!=null){_this.config.style.visibility=_this.config.visible===false?'hidden':'visible';}if(_this.config.interactive!=null){_this.config.style.pointerEvents=_this.config.interactive===false?'none':'auto';}// merge parsed value
|
|
@@ -8168,11 +8129,9 @@
|
|
|
8168
8129
|
* get scaling in world space
|
|
8169
8130
|
*/;_proto.getScale=function getScale(){return runtime.sceneGraphService.getScale(this);}/**
|
|
8170
8131
|
* only return degrees of Z axis in world space
|
|
8171
|
-
*/;_proto.getEulerAngles=function getEulerAngles(){
|
|
8172
|
-
var _getEuler=getEuler(create$2(),runtime.sceneGraphService.getWorldTransform(this)),ex=_getEuler[0],ey=_getEuler[1],ez=_getEuler[2];return rad2deg(ez);}/**
|
|
8132
|
+
*/;_proto.getEulerAngles=function getEulerAngles(){var _getEuler=getEuler(create$2(),runtime.sceneGraphService.getWorldTransform(this)),ez=_getEuler[2];return rad2deg(ez);}/**
|
|
8173
8133
|
* only return degrees of Z axis in local space
|
|
8174
|
-
*/;_proto.getLocalEulerAngles=function getLocalEulerAngles(){
|
|
8175
|
-
var _getEuler2=getEuler(create$2(),runtime.sceneGraphService.getLocalRotation(this)),ex=_getEuler2[0],ey=_getEuler2[1],ez=_getEuler2[2];return rad2deg(ez);}/**
|
|
8134
|
+
*/;_proto.getLocalEulerAngles=function getLocalEulerAngles(){var _getEuler2=getEuler(create$2(),runtime.sceneGraphService.getLocalRotation(this)),ez=_getEuler2[2];return rad2deg(ez);}/**
|
|
8176
8135
|
* set euler angles(degrees) in world space
|
|
8177
8136
|
*/;_proto.setEulerAngles=function setEulerAngles(z){runtime.sceneGraphService.setEulerAngles(this,0,0,z);return this;}/**
|
|
8178
8137
|
* set euler angles(degrees) in local space
|
|
@@ -8206,8 +8165,7 @@
|
|
|
8206
8165
|
*/;_proto.getConfig=function getConfig(){return this.config;};_proto.attr=function attr(){var _this2=this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var name=args[0],value=args[1];if(!name){return this.attributes;}if(isObject(name)){Object.keys(name).forEach(function(key){_this2.setAttribute(key,name[key]);});return this;}if(args.length===2){this.setAttribute(name,value);return this;}return this.attributes[name];}/**
|
|
8207
8166
|
* return 3x3 matrix in world space
|
|
8208
8167
|
* @deprecated
|
|
8209
|
-
*/;_proto.getMatrix=function getMatrix(transformMat4){var transform=transformMat4||this.getWorldTransform();var _mat4$getTranslation=getTranslation(create$2(),transform),tx=_mat4$getTranslation[0],ty=_mat4$getTranslation[1];var _mat4$getScaling=getScaling(create$2(),transform),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1];var rotation=getRotation(create$4(),transform);//
|
|
8210
|
-
var _getEuler3=getEuler(create$2(),rotation),eux=_getEuler3[0],euy=_getEuler3[1],euz=_getEuler3[2];// gimbal lock at 90 degrees
|
|
8168
|
+
*/;_proto.getMatrix=function getMatrix(transformMat4){var transform=transformMat4||this.getWorldTransform();var _mat4$getTranslation=getTranslation(create$2(),transform),tx=_mat4$getTranslation[0],ty=_mat4$getTranslation[1];var _mat4$getScaling=getScaling(create$2(),transform),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1];var rotation=getRotation(create$4(),transform);var _getEuler3=getEuler(create$2(),rotation),eux=_getEuler3[0],euz=_getEuler3[2];// gimbal lock at 90 degrees
|
|
8211
8169
|
return fromRotationTranslationScale$1(eux||euz,tx,ty,sx,sy);}/**
|
|
8212
8170
|
* return 3x3 matrix in local space
|
|
8213
8171
|
* @deprecated
|
|
@@ -8223,7 +8181,48 @@
|
|
|
8223
8181
|
*/;_proto.show=function show(){this.style.visibility='visible';}/**
|
|
8224
8182
|
* Use `visibility: hidden` instead.
|
|
8225
8183
|
* @deprecated
|
|
8226
|
-
*/;_proto.hide=function hide(){this.style.visibility='hidden';}
|
|
8184
|
+
*/;_proto.hide=function hide(){this.style.visibility='hidden';}/**
|
|
8185
|
+
* Use `childElementCount` instead.
|
|
8186
|
+
* @deprecated
|
|
8187
|
+
*/;_proto.getCount=function getCount(){return this.childElementCount;}/**
|
|
8188
|
+
* Use `parentElement` instead.
|
|
8189
|
+
* @deprecated
|
|
8190
|
+
*/;_proto.getParent=function getParent(){return this.parentElement;}/**
|
|
8191
|
+
* Use `children` instead.
|
|
8192
|
+
* @deprecated
|
|
8193
|
+
*/;_proto.getChildren=function getChildren(){return this.children;}/**
|
|
8194
|
+
* Use `firstElementChild` instead.
|
|
8195
|
+
* @deprecated
|
|
8196
|
+
*/;_proto.getFirst=function getFirst(){return this.firstElementChild;}/**
|
|
8197
|
+
* Use `lastElementChild` instead.
|
|
8198
|
+
* @deprecated
|
|
8199
|
+
*/;_proto.getLast=function getLast(){return this.lastElementChild;}/**
|
|
8200
|
+
* Use `this.children[index]` instead.
|
|
8201
|
+
* @deprecated
|
|
8202
|
+
*/;_proto.getChildByIndex=function getChildByIndex(index){return this.children[index]||null;}/**
|
|
8203
|
+
* Use `appendChild` instead.
|
|
8204
|
+
* @deprecated
|
|
8205
|
+
*/;_proto.add=function add(child,index){return this.appendChild(child,index);}/**
|
|
8206
|
+
* Use `this.style.clipPath` instead.
|
|
8207
|
+
* @deprecated
|
|
8208
|
+
*/;_proto.setClip=function setClip(clipPath){this.style.clipPath=clipPath;}/**
|
|
8209
|
+
* Use `this.style.clipPath` instead.
|
|
8210
|
+
* @deprecated
|
|
8211
|
+
*/;/**
|
|
8212
|
+
* @deprecated
|
|
8213
|
+
*/_proto.set=function set(name,value){// @ts-ignore
|
|
8214
|
+
this.config[name]=value;}/**
|
|
8215
|
+
* @deprecated
|
|
8216
|
+
*/;_proto.get=function get(name){return this.config[name];}/**
|
|
8217
|
+
* Use `setPosition` instead.
|
|
8218
|
+
* @deprecated
|
|
8219
|
+
*/;_proto.moveTo=function moveTo(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
|
|
8220
|
+
* Use `setPosition` instead.
|
|
8221
|
+
* @deprecated
|
|
8222
|
+
*/;_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;}/**
|
|
8223
|
+
* Use `this.style.zIndex` instead.
|
|
8224
|
+
* @deprecated
|
|
8225
|
+
*/;_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:_extends({cx:'',cy:'',r:''},style),initialParsedStyle:{anchor:[0.5,0.5]}},rest))||this;}return Circle;}(DisplayObject);var _excluded$1=["style"];/**
|
|
8227
8226
|
* shadow root
|
|
8228
8227
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
8229
8228
|
*/var CustomElement=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(CustomElement,_DisplayObject);// static get observedAttributes(): string[] {
|
|
@@ -8385,7 +8384,8 @@
|
|
|
8385
8384
|
* Sets an offset in a larger frustum, used in PixelPicking
|
|
8386
8385
|
*/;_proto.setViewOffset=function setViewOffset(fullWidth,fullHeight,x,y,width,height){this.aspect=fullWidth/fullHeight;if(this.view===undefined){this.view={enabled:true,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};}this.view.enabled=true;this.view.fullWidth=fullWidth;this.view.fullHeight=fullHeight;this.view.offsetX=x;this.view.offsetY=y;this.view.width=width;this.view.height=height;if(this.projectionMode===exports.CameraProjectionMode.PERSPECTIVE){this.setPerspective(this.near,this.far,this.fov,this.aspect);}else {this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far);}return this;};_proto.clearViewOffset=function clearViewOffset(){if(this.view!==undefined){this.view.enabled=false;}if(this.projectionMode===exports.CameraProjectionMode.PERSPECTIVE){this.setPerspective(this.near,this.far,this.fov,this.aspect);}else {this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far);}return this;};_proto.setZoom=function setZoom(zoom){this.zoom=zoom;if(this.projectionMode===exports.CameraProjectionMode.ORTHOGRAPHIC){this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far);}else if(this.projectionMode===exports.CameraProjectionMode.PERSPECTIVE){this.setPerspective(this.near,this.far,this.fov,this.aspect);}return this;}/**
|
|
8387
8386
|
* Zoom by specified point in viewport coordinates.
|
|
8388
|
-
*/;_proto.setZoomByViewportPoint=function setZoomByViewportPoint(zoom,viewportPoint){var _this$canvas$viewport=this.canvas.viewport2Canvas({x:viewportPoint[0],y:viewportPoint[1]}),ox=_this$canvas$viewport.x,oy=_this$canvas$viewport.y;this.setPosition(ox,oy);this.setFocalPoint(ox,oy);this.setZoom(zoom);var _this$canvas$viewport2=this.canvas.viewport2Canvas({x:viewportPoint[0],y:viewportPoint[1]}),cx=_this$canvas$viewport2.x,cy=_this$canvas$viewport2.y
|
|
8387
|
+
*/;_proto.setZoomByViewportPoint=function setZoomByViewportPoint(zoom,viewportPoint){var _this$canvas$viewport=this.canvas.viewport2Canvas({x:viewportPoint[0],y:viewportPoint[1]}),ox=_this$canvas$viewport.x,oy=_this$canvas$viewport.y;var roll=this.roll;this.rotate(0,0,-roll);this.setPosition(ox,oy);this.setFocalPoint(ox,oy);this.setZoom(zoom);this.rotate(0,0,roll);var _this$canvas$viewport2=this.canvas.viewport2Canvas({x:viewportPoint[0],y:viewportPoint[1]}),cx=_this$canvas$viewport2.x,cy=_this$canvas$viewport2.y;// project to rotated axis
|
|
8388
|
+
var dvec=fromValues$2(cx-ox,cy-oy,0);var dx=dot(dvec,this.right)/length(this.right);var dy=dot(dvec,this.up)/length(this.up);this.pan(-dx,-dy);return this;};_proto.setPerspective=function setPerspective(near,far,fov,aspect){var _this$view;this.projectionMode=exports.CameraProjectionMode.PERSPECTIVE;this.fov=fov;this.near=near;this.far=far;this.aspect=aspect;var top=this.near*Math.tan(deg2rad(0.5*this.fov))/this.zoom;var height=2*top;var width=this.aspect*height;var left=-0.5*width;if((_this$view=this.view)===null||_this$view===void 0?void 0:_this$view.enabled){var fullWidth=this.view.fullWidth;var fullHeight=this.view.fullHeight;left+=this.view.offsetX*width/fullWidth;top-=this.view.offsetY*height/fullHeight;width*=this.view.width/fullWidth;height*=this.view.height/fullHeight;}makePerspective(this.projectionMatrix,left,left+width,top,top-height,near,this.far);// flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
|
|
8389
8389
|
scale(this.projectionMatrix,this.projectionMatrix,fromValues$2(1,-1,1));invert(this.projectionMatrixInverse,this.projectionMatrix);this.triggerUpdate();return this;};_proto.setOrthographic=function setOrthographic(l,r,t,b,near,far){var _this$view2;this.projectionMode=exports.CameraProjectionMode.ORTHOGRAPHIC;this.rright=r;this.left=l;this.top=t;this.bottom=b;this.near=near;this.far=far;var dx=(this.rright-this.left)/(2*this.zoom);var dy=(this.top-this.bottom)/(2*this.zoom);var cx=(this.rright+this.left)/2;var cy=(this.top+this.bottom)/2;var left=cx-dx;var right=cx+dx;var top=cy+dy;var bottom=cy-dy;if((_this$view2=this.view)===null||_this$view2===void 0?void 0:_this$view2.enabled){var scaleW=(this.rright-this.left)/this.view.fullWidth/this.zoom;var scaleH=(this.top-this.bottom)/this.view.fullHeight/this.zoom;left+=scaleW*this.view.offsetX;right=left+scaleW*this.view.width;top-=scaleH*this.view.offsetY;bottom=top-scaleH*this.view.height;}ortho(this.projectionMatrix,left,right,bottom,top,near,far);// flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
|
|
8390
8390
|
scale(this.projectionMatrix,this.projectionMatrix,fromValues$2(1,-1,1));invert(this.projectionMatrixInverse,this.projectionMatrix);this._getOrthoMatrix();this.triggerUpdate();return this;}/**
|
|
8391
8391
|
* Move the camera in world coordinates.
|
|
@@ -8786,6 +8786,8 @@
|
|
|
8786
8786
|
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
|
|
8787
8787
|
// @see https://github.com/mourner/rbush#bulk-inserting-data
|
|
8788
8788
|
this.rBush.load(bulk);bulk.length=0;this.toSync.clear();};return PrepareRendererPlugin;}();PrepareRendererPlugin.tag='Prepare';(function(CanvasEvent){CanvasEvent["READY"]="ready";CanvasEvent["BEFORE_RENDER"]="beforerender";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;/**
|
|
8789
|
+
* reuse custom event preventing from re-create them in every frame
|
|
8790
|
+
*/var mountEvent=new CustomEvent(exports.ElementEvent.MOUNTED);var unmountEvent=new CustomEvent(exports.ElementEvent.UNMOUNTED);var beforeRenderEvent=new CustomEvent(exports.CanvasEvent.BEFORE_RENDER);var afterRenderEvent=new CustomEvent(exports.CanvasEvent.AFTER_RENDER);/**
|
|
8789
8791
|
* can be treated like Window in DOM
|
|
8790
8792
|
* provide some extra methods like `window`, such as:
|
|
8791
8793
|
* * `window.requestAnimationFrame`
|
|
@@ -8816,10 +8818,8 @@
|
|
|
8816
8818
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element
|
|
8817
8819
|
*/ /**
|
|
8818
8820
|
* rAF in auto rendering
|
|
8819
|
-
*/ /**
|
|
8820
|
-
* reuse custom event preventing from re-create them in every frame
|
|
8821
8821
|
*/function Canvas(config){var _this;_this=_EventTarget.call(this)||this;// create document
|
|
8822
|
-
_this.document=void 0;_this.customElements=void 0;_this.requestAnimationFrame=void 0;_this.cancelAnimationFrame=void 0;_this.devicePixelRatio=void 0;_this.supportsPointerEvents=void 0;_this.supportsTouchEvents=void 0;_this.isTouchEvent=void 0;_this.isMouseEvent=void 0;_this.Element=DisplayObject;_this.frameId=void 0;_this.inited=false;_this.readyPromise=void 0;_this.resolveReadyPromise=void 0;_this.
|
|
8822
|
+
_this.document=void 0;_this.customElements=void 0;_this.requestAnimationFrame=void 0;_this.cancelAnimationFrame=void 0;_this.devicePixelRatio=void 0;_this.supportsPointerEvents=void 0;_this.supportsTouchEvents=void 0;_this.isTouchEvent=void 0;_this.isMouseEvent=void 0;_this.Element=DisplayObject;_this.frameId=void 0;_this.inited=false;_this.readyPromise=void 0;_this.resolveReadyPromise=void 0;_this.context={};_this.document=new Document();_this.document.defaultView=_assertThisInitialized(_this);// create registry of custom elements
|
|
8823
8823
|
_this.customElements=new CustomElementRegistry();var container=config.container,canvas=config.canvas,offscreenCanvas=config.offscreenCanvas,width=config.width,height=config.height,devicePixelRatio=config.devicePixelRatio,renderer=config.renderer,background=config.background,cursor=config.cursor,document=config.document,requestAnimationFrame=config.requestAnimationFrame,cancelAnimationFrame=config.cancelAnimationFrame,createImage=config.createImage,supportsPointerEvents=config.supportsPointerEvents,supportsTouchEvents=config.supportsTouchEvents,supportsCSSTransform=config.supportsCSSTransform,isTouchEvent=config.isTouchEvent,isMouseEvent=config.isMouseEvent;cleanExistedCanvas(container,_assertThisInitialized(_this));var canvasWidth=width;var canvasHeight=height;var dpr=devicePixelRatio;// use user-defined <canvas> or OffscreenCanvas
|
|
8824
8824
|
if(canvas){// infer width & height with dpr
|
|
8825
8825
|
dpr=devicePixelRatio||isBrowser&&window.devicePixelRatio||1;dpr=dpr>=1?Math.ceil(dpr):1;canvasWidth=width||getWidth(canvas)||canvas.width/dpr;canvasHeight=height||getHeight(canvas)||canvas.height/dpr;}/**
|
|
@@ -8828,13 +8828,13 @@
|
|
|
8828
8828
|
* limits query
|
|
8829
8829
|
*/ // the following feature-detect from hammer.js
|
|
8830
8830
|
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
8831
|
-
_this.supportsTouchEvents=supportsTouchEvents!==null&&supportsTouchEvents!==void 0?supportsTouchEvents:'ontouchstart'in globalThis;_this.supportsPointerEvents=supportsPointerEvents!==null&&supportsPointerEvents!==void 0?supportsPointerEvents:!!globalThis.PointerEvent;_this.isTouchEvent=isTouchEvent!==null&&isTouchEvent!==void 0?isTouchEvent:function(event){return _this.supportsTouchEvents&&event instanceof globalThis.TouchEvent;};_this.isMouseEvent=isMouseEvent!==null&&isMouseEvent!==void 0?isMouseEvent:function(event){return !globalThis.MouseEvent||event instanceof globalThis.MouseEvent&&(!_this.supportsPointerEvents||!(event instanceof globalThis.PointerEvent));};_this.initRenderingContext({container:container,canvas:canvas,width:canvasWidth,height:canvasHeight,renderer:renderer,offscreenCanvas:offscreenCanvas,devicePixelRatio:dpr,cursor:cursor||'default',background:background||'transparent',createImage:createImage,document:document,supportsCSSTransform:supportsCSSTransform});_this.initDefaultCamera(canvasWidth,canvasHeight);_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _this.initRenderer(renderer);case 2:_this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));if(_this.readyPromise){_this.resolveReadyPromise();}case 4:case"end":return _context.stop();}}},_callee);}))();return _this;}var _proto=Canvas.prototype;_proto.initRenderingContext=function initRenderingContext(mergedConfig){
|
|
8831
|
+
_this.supportsTouchEvents=supportsTouchEvents!==null&&supportsTouchEvents!==void 0?supportsTouchEvents:'ontouchstart'in globalThis;_this.supportsPointerEvents=supportsPointerEvents!==null&&supportsPointerEvents!==void 0?supportsPointerEvents:!!globalThis.PointerEvent;_this.isTouchEvent=isTouchEvent!==null&&isTouchEvent!==void 0?isTouchEvent:function(event){return _this.supportsTouchEvents&&event instanceof globalThis.TouchEvent;};_this.isMouseEvent=isMouseEvent!==null&&isMouseEvent!==void 0?isMouseEvent:function(event){return !globalThis.MouseEvent||event instanceof globalThis.MouseEvent&&(!_this.supportsPointerEvents||!(event instanceof globalThis.PointerEvent));};_this.initRenderingContext({container:container,canvas:canvas,width:canvasWidth,height:canvasHeight,renderer:renderer,offscreenCanvas:offscreenCanvas,devicePixelRatio:dpr,cursor:cursor||'default',background:background||'transparent',createImage:createImage,document:document,supportsCSSTransform:supportsCSSTransform});_this.initDefaultCamera(canvasWidth,canvasHeight);_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _this.initRenderer(renderer);case 2:_this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));if(_this.readyPromise){_this.resolveReadyPromise();}case 4:case"end":return _context.stop();}}},_callee);}))();return _this;}var _proto=Canvas.prototype;_proto.initRenderingContext=function initRenderingContext(mergedConfig){this.context.config=mergedConfig;// bind rendering context, shared by all renderers
|
|
8832
8832
|
this.context.renderingContext={/**
|
|
8833
8833
|
* the root node in scene graph
|
|
8834
|
-
*/root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set(),force:false,dirty:false};
|
|
8834
|
+
*/root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set(),force:false,dirty:false};};_proto.initDefaultCamera=function initDefaultCamera(width,height){var _this2=this;// set a default ortho camera
|
|
8835
8835
|
var camera=new runtime.CameraContribution();camera.setType(exports.CameraType.EXPLORING,exports.CameraTrackingMode.DEFAULT).setPosition(width/2,height/2,DEFAULT_CAMERA_Z).setFocalPoint(width/2,height/2,0).setOrthographic(width/-2,width/2,height/2,height/-2,DEFAULT_CAMERA_NEAR,DEFAULT_CAMERA_FAR);// keep ref since it will use raf in camera animation
|
|
8836
8836
|
camera.canvas=this;// redraw when camera changed
|
|
8837
|
-
camera.eventEmitter.on(CameraEvent.UPDATED,function(){
|
|
8837
|
+
camera.eventEmitter.on(CameraEvent.UPDATED,function(){_this2.context.renderingContext.renderReasons.add(exports.RenderReason.CAMERA_CHANGED);});// bind camera
|
|
8838
8838
|
this.context.camera=camera;};_proto.getConfig=function getConfig(){return this.context.config;}/**
|
|
8839
8839
|
* get the root displayObject in scenegraph
|
|
8840
8840
|
* @alias this.document.documentElement
|
|
@@ -8860,7 +8860,7 @@
|
|
|
8860
8860
|
var canvasConfig=this.context.config;canvasConfig.width=width;canvasConfig.height=height;// resize context
|
|
8861
8861
|
this.getContextService().resize(width,height);// resize camera
|
|
8862
8862
|
var camera=this.context.camera;var projectionMode=camera.getProjectionMode();camera.setPosition(width/2,height/2,DEFAULT_CAMERA_Z).setFocalPoint(width/2,height/2,0);if(projectionMode===exports.CameraProjectionMode.ORTHOGRAPHIC){camera.setOrthographic(width/-2,width/2,height/2,height/-2,camera.getNear(),camera.getFar());}else {camera.setAspect(width/height);}this.dispatchEvent(new CustomEvent(exports.CanvasEvent.RESIZE,{width:width,height:height}));}// proxy to document.documentElement
|
|
8863
|
-
;_proto.appendChild=function appendChild(child,index){return this.document.documentElement.appendChild(child,index);};_proto.insertBefore=function insertBefore(newChild,refChild){return this.document.documentElement.insertBefore(newChild,refChild);};_proto.removeChild=function removeChild(child){return this.document.documentElement.removeChild(child);};_proto.removeChildren=function removeChildren(){this.document.documentElement.removeChildren();};_proto.render=function render(){this.dispatchEvent(
|
|
8863
|
+
;_proto.appendChild=function appendChild(child,index){return this.document.documentElement.appendChild(child,index);};_proto.insertBefore=function insertBefore(newChild,refChild){return this.document.documentElement.insertBefore(newChild,refChild);};_proto.removeChild=function removeChild(child){return this.document.documentElement.removeChild(child);};_proto.removeChildren=function removeChildren(){this.document.documentElement.removeChildren();};_proto.render=function render(){this.dispatchEvent(beforeRenderEvent);var renderingService=this.getRenderingService();renderingService.render(this.getConfig());this.dispatchEvent(afterRenderEvent);};_proto.run=function run(){var _this3=this;var tick=function tick(){_this3.render();_this3.frameId=requestAnimationFrame(tick);};tick();};_proto.initRenderer=/*#__PURE__*/function(){var _initRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderer){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(renderer){_context2.next=2;break;}throw new Error('Renderer is required.');case 2:// reset
|
|
8864
8864
|
this.inited=false;this.readyPromise=undefined;// FIXME: should re-create here?
|
|
8865
8865
|
this.context.rBushRoot=new RBush();// reset rendering plugins
|
|
8866
8866
|
this.context.renderingPlugins=[];this.context.renderingPlugins.push(new EventPlugin(),new PrepareRendererPlugin(),new DirtyCheckPlugin(),new CullingPlugin([new FrustumCullingStrategy()]));//
|
|
@@ -8868,21 +8868,21 @@
|
|
|
8868
8868
|
this.context.contextService=new this.context.ContextService(_extends({},runtime,this.context));// init rendering service
|
|
8869
8869
|
this.context.renderingService=new RenderingService(runtime,this.context);// init event service
|
|
8870
8870
|
this.context.eventService=new EventService(runtime,this.context);this.context.eventService.init();_context2.next=14;return this.context.contextService.init();case 14:_context2.next=16;return this.context.renderingService.init();case 16:this.inited=true;this.getRoot().forEach(function(node){var renderable=node.renderable;if(renderable){renderable.renderBoundsDirty=true;renderable.boundsDirty=true;renderable.dirty=true;}});// keep current scenegraph unchanged, just trigger mounted event
|
|
8871
|
-
this.mountChildren(this.getRoot());if(renderer.getConfig().enableAutoRendering){this.run();}case 20:case"end":return _context2.stop();}}},_callee2,this);}));function initRenderer(_x){return _initRenderer.apply(this,arguments);}return initRenderer;}();_proto.loadRendererContainerModule=function loadRendererContainerModule(renderer){var
|
|
8872
|
-
var plugins=renderer.getPlugins();plugins.forEach(function(plugin){plugin.context=
|
|
8871
|
+
this.mountChildren(this.getRoot());if(renderer.getConfig().enableAutoRendering){this.run();}case 20:case"end":return _context2.stop();}}},_callee2,this);}));function initRenderer(_x){return _initRenderer.apply(this,arguments);}return initRenderer;}();_proto.loadRendererContainerModule=function loadRendererContainerModule(renderer){var _this4=this;// load other container modules provided by g-canvas/g-svg/g-webgl
|
|
8872
|
+
var plugins=renderer.getPlugins();plugins.forEach(function(plugin){plugin.context=_this4.context;plugin.init();});};_proto.setRenderer=/*#__PURE__*/function(){var _setRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(renderer){var canvasConfig,oldRenderer;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:// update canvas' config
|
|
8873
8873
|
canvasConfig=this.getConfig();if(!(canvasConfig.renderer===renderer)){_context3.next=3;break;}return _context3.abrupt("return");case 3:oldRenderer=canvasConfig.renderer;canvasConfig.renderer=renderer;// keep all children undestroyed
|
|
8874
8874
|
this.destroy(false,true);// destroy all plugins, reverse will mutate origin array
|
|
8875
|
-
[].concat(oldRenderer===null||oldRenderer===void 0?void 0:oldRenderer.getPlugins()).reverse().forEach(function(plugin){plugin.destroy();});_context3.next=9;return this.initRenderer(renderer);case 9:case"end":return _context3.stop();}}},_callee3,this);}));function setRenderer(_x2){return _setRenderer.apply(this,arguments);}return setRenderer;}();_proto.setCursor=function setCursor(cursor){var canvasConfig=this.getConfig();canvasConfig.cursor=cursor;this.getContextService().applyCursorStyle(cursor);};_proto.unmountChildren=function unmountChildren(parent){var
|
|
8875
|
+
[].concat(oldRenderer===null||oldRenderer===void 0?void 0:oldRenderer.getPlugins()).reverse().forEach(function(plugin){plugin.destroy();});_context3.next=9;return this.initRenderer(renderer);case 9:case"end":return _context3.stop();}}},_callee3,this);}));function setRenderer(_x2){return _setRenderer.apply(this,arguments);}return setRenderer;}();_proto.setCursor=function setCursor(cursor){var canvasConfig=this.getConfig();canvasConfig.cursor=cursor;this.getContextService().applyCursorStyle(cursor);};_proto.unmountChildren=function unmountChildren(parent){var _this5=this;if(this.inited){var path=[];parent.forEach(function(child){if(child.isConnected){path.push(child);}});// unmount from leaf to root
|
|
8876
8876
|
path.reverse().forEach(function(child){// trigger before unmounted
|
|
8877
|
-
if(child instanceof CustomElement){if(child.disconnectedCallback){child.disconnectedCallback();}}child.dispatchEvent(
|
|
8878
|
-
if(child!==
|
|
8877
|
+
if(child instanceof CustomElement){if(child.disconnectedCallback){child.disconnectedCallback();}}child.dispatchEvent(unmountEvent);// skip document.documentElement
|
|
8878
|
+
if(child!==_this5.document.documentElement){child.ownerDocument=null;}child.isConnected=false;});}};_proto.mountChildren=function mountChildren(parent){var _this6=this;if(this.inited){parent.forEach(function(child){if(!child.isConnected){child.ownerDocument=_this6.document;child.isConnected=true;child.dispatchEvent(mountEvent);// trigger after mounted
|
|
8879
8879
|
if(child instanceof CustomElement){if(child.connectedCallback){child.connectedCallback();}}}});}else {console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.",'appended child: ',parent.nodeName);}};_proto.client2Viewport=function client2Viewport(client){return this.getEventService().client2Viewport(client);};_proto.viewport2Client=function viewport2Client(canvas){return this.getEventService().viewport2Client(canvas);};_proto.viewport2Canvas=function viewport2Canvas(viewport){return this.getEventService().viewport2Canvas(viewport);};_proto.canvas2Viewport=function canvas2Viewport(canvas){return this.getEventService().canvas2Viewport(canvas);}/**
|
|
8880
8880
|
* @deprecated
|
|
8881
8881
|
* @alias client2Viewport
|
|
8882
8882
|
*/;_proto.getPointByClient=function getPointByClient(clientX,clientY){return this.client2Viewport({x:clientX,y:clientY});}/**
|
|
8883
8883
|
* @deprecated
|
|
8884
8884
|
* @alias viewport2Client
|
|
8885
|
-
*/;_proto.getClientByPoint=function getClientByPoint(x,y){return this.viewport2Client({x:x,y:y});};_createClass(Canvas,[{key:"ready",get:function get(){var
|
|
8885
|
+
*/;_proto.getClientByPoint=function getClientByPoint(x,y){return this.viewport2Client({x:x,y:y});};_createClass(Canvas,[{key:"ready",get:function get(){var _this7=this;if(!this.readyPromise){this.readyPromise=new Promise(function(resolve){_this7.resolveReadyPromise=function(){resolve(_this7);};});if(this.inited){this.resolveReadyPromise();}}return this.readyPromise;}}]);return Canvas;}(EventTarget);
|
|
8886
8886
|
|
|
8887
8887
|
function _inheritsLoose$1(subClass, superClass) {
|
|
8888
8888
|
subClass.prototype = Object.create(superClass.prototype);
|
|
@@ -10133,94 +10133,6 @@
|
|
|
10133
10133
|
|
|
10134
10134
|
runtime.CameraContribution = AdvancedCamera;
|
|
10135
10135
|
|
|
10136
|
-
DisplayObject.prototype.getCount = function () {
|
|
10137
|
-
return this.childElementCount;
|
|
10138
|
-
}; // @ts-ignore
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
DisplayObject.prototype.getParent = function () {
|
|
10142
|
-
return this.parentElement;
|
|
10143
|
-
}; // @ts-ignore
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
DisplayObject.prototype.getChildren = function () {
|
|
10147
|
-
return this.children;
|
|
10148
|
-
}; // @ts-ignore
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
DisplayObject.prototype.getFirst = function () {
|
|
10152
|
-
return this.firstElementChild;
|
|
10153
|
-
}; // @ts-ignore
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
DisplayObject.prototype.getLast = function () {
|
|
10157
|
-
return this.lastElementChild;
|
|
10158
|
-
}; // @ts-ignore
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
DisplayObject.prototype.getChildByIndex = function (index) {
|
|
10162
|
-
return this.children[index] || null;
|
|
10163
|
-
}; // @ts-ignore
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
DisplayObject.prototype.add = function (child, index) {
|
|
10167
|
-
return this.appendChild(child, index);
|
|
10168
|
-
}; // @ts-ignore
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
DisplayObject.prototype.setClip = function (clipPath) {
|
|
10172
|
-
this.style.clipPath = clipPath;
|
|
10173
|
-
}; // @ts-ignore
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
DisplayObject.prototype.getClip = function () {
|
|
10177
|
-
return this.style.clipPath || null;
|
|
10178
|
-
}; // @ts-ignore
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
DisplayObject.prototype.set = function (name, value) {
|
|
10182
|
-
this.config[name] = value;
|
|
10183
|
-
}; // @ts-ignore
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
DisplayObject.prototype.get = function (name) {
|
|
10187
|
-
return this.config[name];
|
|
10188
|
-
}; // @ts-ignore
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
DisplayObject.prototype.moveTo = function (position, y, z) {
|
|
10192
|
-
if (y === void 0) {
|
|
10193
|
-
y = 0;
|
|
10194
|
-
}
|
|
10195
|
-
|
|
10196
|
-
if (z === void 0) {
|
|
10197
|
-
z = 0;
|
|
10198
|
-
}
|
|
10199
|
-
|
|
10200
|
-
this.setPosition(position, y, z);
|
|
10201
|
-
return this;
|
|
10202
|
-
}; // @ts-ignore
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
DisplayObject.prototype.move = function (position, y, z) {
|
|
10206
|
-
if (y === void 0) {
|
|
10207
|
-
y = 0;
|
|
10208
|
-
}
|
|
10209
|
-
|
|
10210
|
-
if (z === void 0) {
|
|
10211
|
-
z = 0;
|
|
10212
|
-
}
|
|
10213
|
-
|
|
10214
|
-
this.setPosition(position, y, z);
|
|
10215
|
-
return this;
|
|
10216
|
-
}; // @ts-ignore
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
DisplayObject.prototype.setZIndex = function (zIndex) {
|
|
10220
|
-
this.style.zIndex = zIndex;
|
|
10221
|
-
return this;
|
|
10222
|
-
};
|
|
10223
|
-
|
|
10224
10136
|
// export const ContextNode = Syringe.defineToken('');
|
|
10225
10137
|
var FragmentResult = function FragmentResult(_layoutContext, _node, options) {
|
|
10226
10138
|
this._layoutContext = void 0;
|