@antv/g-lite 1.0.11 → 1.0.13
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/Canvas.d.ts +2 -9
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/camera/Camera.d.ts.map +1 -1
- package/dist/css/StyleValueRegistry.d.ts +1 -1
- package/dist/css/StyleValueRegistry.d.ts.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts +70 -1
- package/dist/display-objects/DisplayObject.d.ts.map +1 -1
- package/dist/display-objects/DisplayObjectPool.d.ts +2 -2
- package/dist/display-objects/DisplayObjectPool.d.ts.map +1 -1
- package/dist/display-objects/Line.d.ts +2 -2
- package/dist/display-objects/Line.d.ts.map +1 -1
- package/dist/display-objects/Path.d.ts +2 -2
- package/dist/display-objects/Path.d.ts.map +1 -1
- package/dist/display-objects/Polyline.d.ts +2 -2
- package/dist/display-objects/Polyline.d.ts.map +1 -1
- package/dist/display-objects/Text.d.ts +2 -2
- package/dist/display-objects/Text.d.ts.map +1 -1
- package/dist/dom/Element.d.ts.map +1 -1
- package/dist/dom/EventTarget.d.ts +1 -1
- package/dist/dom/EventTarget.d.ts.map +1 -1
- package/dist/dom/interfaces.d.ts +3 -9
- package/dist/dom/interfaces.d.ts.map +1 -1
- package/dist/index.esm.js +376 -225
- package/dist/index.js +376 -225
- package/dist/index.umd.js +381 -232
- package/dist/index.umd.min.js +2 -2
- package/dist/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/dist/services/EventService.d.ts +1 -1
- package/dist/services/EventService.d.ts.map +1 -1
- package/dist/services/RenderingService.d.ts.map +1 -1
- package/dist/services/SceneGraphService.d.ts.map +1 -1
- package/dist/services/TextService.d.ts.map +1 -1
- package/dist/shapes/AABB.d.ts +1 -1
- package/dist/shapes/AABB.d.ts.map +1 -1
- package/dist/utils/assert.d.ts +4 -1
- package/dist/utils/assert.d.ts.map +1 -1
- package/dist/utils/text.d.ts.map +1 -1
- package/package.json +6 -3
package/dist/index.esm.js
CHANGED
|
@@ -98,6 +98,14 @@ var AABB = /*#__PURE__*/function () {
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
function AABB(center, halfExtents) {
|
|
101
|
+
if (center === void 0) {
|
|
102
|
+
center = [0, 0, 0];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (halfExtents === void 0) {
|
|
106
|
+
halfExtents = [0, 0, 0];
|
|
107
|
+
}
|
|
108
|
+
|
|
101
109
|
this.center = vec3.create();
|
|
102
110
|
this.halfExtents = vec3.create();
|
|
103
111
|
this.min = vec3.create();
|
|
@@ -108,16 +116,10 @@ var AABB = /*#__PURE__*/function () {
|
|
|
108
116
|
var _proto = AABB.prototype;
|
|
109
117
|
|
|
110
118
|
_proto.update = function update(center, halfExtents) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (halfExtents) {
|
|
116
|
-
vec3.copy(this.halfExtents, halfExtents || vec3.fromValues(0, 0, 0));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.min = vec3.sub(this.min, this.center, this.halfExtents);
|
|
120
|
-
this.max = vec3.add(this.max, this.center, this.halfExtents);
|
|
119
|
+
vec3.copy(this.center, center);
|
|
120
|
+
vec3.copy(this.halfExtents, halfExtents);
|
|
121
|
+
vec3.sub(this.min, this.center, this.halfExtents);
|
|
122
|
+
vec3.add(this.max, this.center, this.halfExtents);
|
|
121
123
|
};
|
|
122
124
|
|
|
123
125
|
_proto.setMinMax = function setMinMax(min, max) {
|
|
@@ -559,10 +561,7 @@ var FORMAT_ATTR_MAP = {
|
|
|
559
561
|
alias: 'lineWidth'
|
|
560
562
|
},
|
|
561
563
|
textAnchor: {
|
|
562
|
-
alias: 'textAlign'
|
|
563
|
-
values: {
|
|
564
|
-
middle: 'center'
|
|
565
|
-
}
|
|
564
|
+
alias: 'textAlign'
|
|
566
565
|
},
|
|
567
566
|
src: {
|
|
568
567
|
alias: 'img'
|
|
@@ -572,18 +571,8 @@ var formatAttributeName = memoize(function (name) {
|
|
|
572
571
|
var attributeName = camelCase(name);
|
|
573
572
|
var map = FORMAT_ATTR_MAP[attributeName];
|
|
574
573
|
attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
|
|
575
|
-
return
|
|
574
|
+
return attributeName;
|
|
576
575
|
});
|
|
577
|
-
function formatAttribute(name, value) {
|
|
578
|
-
var _map$values;
|
|
579
|
-
|
|
580
|
-
var _formatAttributeName = formatAttributeName(name),
|
|
581
|
-
attributeName = _formatAttributeName[0],
|
|
582
|
-
map = _formatAttributeName[1];
|
|
583
|
-
|
|
584
|
-
var attributeValue = isString(value) && (map === null || map === void 0 ? void 0 : (_map$values = map.values) === null || _map$values === void 0 ? void 0 : _map$values[value]) || value;
|
|
585
|
-
return [attributeName, attributeValue];
|
|
586
|
-
}
|
|
587
576
|
|
|
588
577
|
var canvasMap = {};
|
|
589
578
|
var defaultCanvasIdCounter = 0;
|
|
@@ -5443,16 +5432,23 @@ var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
|
|
|
5443
5432
|
};
|
|
5444
5433
|
|
|
5445
5434
|
_proto.postProcessor = function postProcessor(object) {
|
|
5446
|
-
|
|
5435
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
5436
|
+
offsetPath = _object$parsedStyle.offsetPath,
|
|
5437
|
+
offsetDistance = _object$parsedStyle.offsetDistance;
|
|
5438
|
+
|
|
5439
|
+
if (!offsetPath) {
|
|
5447
5440
|
return;
|
|
5448
5441
|
}
|
|
5449
5442
|
|
|
5450
|
-
var
|
|
5443
|
+
var nodeName = offsetPath.nodeName;
|
|
5451
5444
|
|
|
5452
|
-
if (
|
|
5453
|
-
|
|
5445
|
+
if (nodeName === Shape.LINE || nodeName === Shape.PATH || nodeName === Shape.POLYLINE) {
|
|
5446
|
+
// set position in world space
|
|
5447
|
+
var point = offsetPath.getPoint(offsetDistance);
|
|
5454
5448
|
|
|
5455
5449
|
if (point) {
|
|
5450
|
+
object.parsedStyle.defX = point.x;
|
|
5451
|
+
object.parsedStyle.defY = point.y;
|
|
5456
5452
|
object.setLocalPosition(point.x, point.y);
|
|
5457
5453
|
}
|
|
5458
5454
|
}
|
|
@@ -8062,6 +8058,7 @@ var SyncWaterfallHook = /*#__PURE__*/function (_SyncHook) {
|
|
|
8062
8058
|
// SyncWaterfallHook.prototype = null;
|
|
8063
8059
|
|
|
8064
8060
|
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
|
|
8061
|
+
var stringRegExp = /([\"\'])[^\'\"]+\1/;
|
|
8065
8062
|
function toFontString(attributes) {
|
|
8066
8063
|
var fontSize = attributes.fontSize,
|
|
8067
8064
|
fontFamily = attributes.fontFamily,
|
|
@@ -8081,7 +8078,7 @@ function toFontString(attributes) {
|
|
|
8081
8078
|
var _fontFamily = fontFamilies[i].trim(); // Check if font already contains strings
|
|
8082
8079
|
|
|
8083
8080
|
|
|
8084
|
-
if (
|
|
8081
|
+
if (!stringRegExp.test(_fontFamily) && genericFontFamilies.indexOf(_fontFamily) < 0) {
|
|
8085
8082
|
_fontFamily = "\"" + _fontFamily + "\"";
|
|
8086
8083
|
}
|
|
8087
8084
|
|
|
@@ -8557,7 +8554,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
8557
8554
|
n: 'textAlign',
|
|
8558
8555
|
l: true,
|
|
8559
8556
|
inh: true,
|
|
8560
|
-
k: ['start', 'center', 'end', 'left', 'right'],
|
|
8557
|
+
k: ['start', 'center', 'middle', 'end', 'left', 'right'],
|
|
8561
8558
|
d: 'start'
|
|
8562
8559
|
}, // {
|
|
8563
8560
|
// n: 'whiteSpace',
|
|
@@ -8586,7 +8583,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
8586
8583
|
d: '0'
|
|
8587
8584
|
}];
|
|
8588
8585
|
var propertyMetadataCache = {};
|
|
8589
|
-
var unresolvedProperties =
|
|
8586
|
+
var unresolvedProperties = new WeakMap();
|
|
8590
8587
|
var priorityMap = {};
|
|
8591
8588
|
var sortAttributeNames = memoize(function (attributeNames) {
|
|
8592
8589
|
return attributeNames.sort(function (a, b) {
|
|
@@ -8598,11 +8595,13 @@ var tmpVec3b = vec3.create();
|
|
|
8598
8595
|
var tmpVec3c = vec3.create();
|
|
8599
8596
|
|
|
8600
8597
|
var isPropertyResolved = function isPropertyResolved(object, name) {
|
|
8601
|
-
|
|
8598
|
+
var properties = unresolvedProperties.get(object);
|
|
8599
|
+
|
|
8600
|
+
if (!properties || properties.length === 0) {
|
|
8602
8601
|
return true;
|
|
8603
8602
|
}
|
|
8604
8603
|
|
|
8605
|
-
return
|
|
8604
|
+
return properties.includes(name);
|
|
8606
8605
|
};
|
|
8607
8606
|
|
|
8608
8607
|
var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
@@ -8667,12 +8666,10 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8667
8666
|
attributeNames.forEach(function (attributeName) {
|
|
8668
8667
|
var _propertyMetadataCach;
|
|
8669
8668
|
|
|
8670
|
-
var
|
|
8671
|
-
name = _formatAttribute[0],
|
|
8672
|
-
value = _formatAttribute[1];
|
|
8669
|
+
var name = formatAttributeName(attributeName);
|
|
8673
8670
|
|
|
8674
8671
|
if (!skipUpdateAttribute) {
|
|
8675
|
-
object.attributes[name] =
|
|
8672
|
+
object.attributes[name] = attributes[attributeName];
|
|
8676
8673
|
}
|
|
8677
8674
|
|
|
8678
8675
|
if (!needUpdateGeometry && ((_propertyMetadataCach = propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.l)) {
|
|
@@ -8848,12 +8845,15 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8848
8845
|
;
|
|
8849
8846
|
|
|
8850
8847
|
_proto.addUnresolveProperty = function addUnresolveProperty(object, name) {
|
|
8851
|
-
|
|
8852
|
-
|
|
8848
|
+
var properties = unresolvedProperties.get(object);
|
|
8849
|
+
|
|
8850
|
+
if (!properties) {
|
|
8851
|
+
unresolvedProperties.set(object, []);
|
|
8852
|
+
properties = unresolvedProperties.get(object);
|
|
8853
8853
|
}
|
|
8854
8854
|
|
|
8855
|
-
if (
|
|
8856
|
-
|
|
8855
|
+
if (properties.indexOf(name) === -1) {
|
|
8856
|
+
properties.push(name);
|
|
8857
8857
|
}
|
|
8858
8858
|
};
|
|
8859
8859
|
|
|
@@ -8889,7 +8889,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8889
8889
|
};
|
|
8890
8890
|
|
|
8891
8891
|
_proto.recalc = function recalc(object) {
|
|
8892
|
-
var properties = unresolvedProperties
|
|
8892
|
+
var properties = unresolvedProperties.get(object);
|
|
8893
8893
|
|
|
8894
8894
|
if (properties && properties.length) {
|
|
8895
8895
|
var attributes = {};
|
|
@@ -8897,7 +8897,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8897
8897
|
attributes[property] = object.attributes[property];
|
|
8898
8898
|
});
|
|
8899
8899
|
this.processProperties(object, attributes);
|
|
8900
|
-
delete
|
|
8900
|
+
unresolvedProperties.delete(object);
|
|
8901
8901
|
}
|
|
8902
8902
|
}
|
|
8903
8903
|
/**
|
|
@@ -9453,7 +9453,11 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
9453
9453
|
*/
|
|
9454
9454
|
;
|
|
9455
9455
|
|
|
9456
|
-
_proto.dispatchEvent = function dispatchEvent(e) {
|
|
9456
|
+
_proto.dispatchEvent = function dispatchEvent(e, skipPropagate) {
|
|
9457
|
+
if (skipPropagate === void 0) {
|
|
9458
|
+
skipPropagate = false;
|
|
9459
|
+
}
|
|
9460
|
+
|
|
9457
9461
|
if (!(e instanceof FederatedEvent)) {
|
|
9458
9462
|
throw new Error('DisplayObject cannot propagate events outside of the Federated Events API');
|
|
9459
9463
|
} // should account for Element / Document / Canvas
|
|
@@ -9483,8 +9487,12 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
9483
9487
|
|
|
9484
9488
|
e.defaultPrevented = false;
|
|
9485
9489
|
e.path = [];
|
|
9486
|
-
|
|
9487
|
-
(
|
|
9490
|
+
|
|
9491
|
+
if (!skipPropagate) {
|
|
9492
|
+
e.target = this;
|
|
9493
|
+
}
|
|
9494
|
+
|
|
9495
|
+
(_e$manager = e.manager) === null || _e$manager === void 0 ? void 0 : _e$manager.dispatchEvent(e, e.type, skipPropagate);
|
|
9488
9496
|
}
|
|
9489
9497
|
|
|
9490
9498
|
return !e.defaultPrevented;
|
|
@@ -10267,22 +10275,12 @@ var ElementEvent;
|
|
|
10267
10275
|
*/
|
|
10268
10276
|
|
|
10269
10277
|
ElementEvent["INSERTED"] = "DOMNodeInserted";
|
|
10270
|
-
/**
|
|
10271
|
-
* it has had a child inserted
|
|
10272
|
-
*/
|
|
10273
|
-
|
|
10274
|
-
ElementEvent["CHILD_INSERTED"] = "child-inserted";
|
|
10275
10278
|
/**
|
|
10276
10279
|
* it is being removed
|
|
10277
10280
|
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
|
|
10278
10281
|
*/
|
|
10279
10282
|
|
|
10280
10283
|
ElementEvent["REMOVED"] = "removed";
|
|
10281
|
-
/**
|
|
10282
|
-
* it has had a child removed
|
|
10283
|
-
*/
|
|
10284
|
-
|
|
10285
|
-
ElementEvent["CHILD_REMOVED"] = "child-removed";
|
|
10286
10284
|
/**
|
|
10287
10285
|
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
|
|
10288
10286
|
*/
|
|
@@ -10337,17 +10335,10 @@ MutationEvent.REMOVAL = 3;
|
|
|
10337
10335
|
var entityCounter = 0;
|
|
10338
10336
|
function resetEntityCounter() {
|
|
10339
10337
|
entityCounter = 0;
|
|
10340
|
-
}
|
|
10341
|
-
|
|
10342
|
-
var childInsertedEvent = new CustomEvent(ElementEvent.CHILD_INSERTED, {
|
|
10343
|
-
child: null
|
|
10344
|
-
});
|
|
10338
|
+
}
|
|
10345
10339
|
var insertedEvent = new MutationEvent(ElementEvent.INSERTED, null, '', '', '', 0, '', '');
|
|
10346
10340
|
var removedEvent = new MutationEvent(ElementEvent.REMOVED, null, '', '', '', 0, '', '');
|
|
10347
10341
|
var destroyEvent = new CustomEvent(ElementEvent.DESTROY);
|
|
10348
|
-
var childRemovedEvent = new CustomEvent(ElementEvent.CHILD_REMOVED, {
|
|
10349
|
-
child: null
|
|
10350
|
-
});
|
|
10351
10342
|
/**
|
|
10352
10343
|
* Has following capabilities:
|
|
10353
10344
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
@@ -10485,19 +10476,13 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10485
10476
|
};
|
|
10486
10477
|
|
|
10487
10478
|
_proto.appendChild = function appendChild(child, index) {
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
// this.ownerDocument?.defaultView?.mountChildren(child);
|
|
10496
|
-
|
|
10497
|
-
this.dispatchEvent(childInsertedEvent); // child.emit(ElementEvent.INSERTED, {
|
|
10498
|
-
// parent: this,
|
|
10499
|
-
// index,
|
|
10500
|
-
// });
|
|
10479
|
+
var _this$ownerDocument;
|
|
10480
|
+
|
|
10481
|
+
runtime.sceneGraphService.attach(child, this, index);
|
|
10482
|
+
|
|
10483
|
+
if ((_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.defaultView) {
|
|
10484
|
+
this.ownerDocument.defaultView.mountChildren(child);
|
|
10485
|
+
}
|
|
10501
10486
|
|
|
10502
10487
|
insertedEvent.relatedNode = this;
|
|
10503
10488
|
child.dispatchEvent(insertedEvent);
|
|
@@ -10523,36 +10508,18 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10523
10508
|
};
|
|
10524
10509
|
|
|
10525
10510
|
_proto.removeChild = function removeChild(child) {
|
|
10511
|
+
var _child$ownerDocument;
|
|
10512
|
+
|
|
10526
10513
|
// should emit on itself before detach
|
|
10527
|
-
// child.emit(ElementEvent.REMOVED, {
|
|
10528
|
-
// parent: this,
|
|
10529
|
-
// });
|
|
10530
10514
|
removedEvent.relatedNode = this;
|
|
10531
|
-
child.dispatchEvent(removedEvent);
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
//
|
|
10536
|
-
|
|
10537
|
-
// emit on parent
|
|
10538
|
-
|
|
10539
|
-
childRemovedEvent.detail.child = child;
|
|
10540
|
-
this.dispatchEvent(childRemovedEvent); // this.dispatchEvent(
|
|
10541
|
-
// new CustomEvent(ElementEvent.CHILD_REMOVED, {
|
|
10542
|
-
// child,
|
|
10543
|
-
// }),
|
|
10544
|
-
// );
|
|
10545
|
-
// remove from scene graph
|
|
10546
|
-
|
|
10547
|
-
runtime.sceneGraphService.detach(child); // cannot emit Destroy event now
|
|
10548
|
-
// if (destroy) {
|
|
10549
|
-
// // this.removeChildren();
|
|
10550
|
-
// // remove event listeners
|
|
10551
|
-
// // @ts-ignore
|
|
10552
|
-
// child.emitter.removeAllListeners();
|
|
10553
|
-
// displayObjectPool.remove((child as unknown as Element).entity);
|
|
10554
|
-
// }
|
|
10515
|
+
child.dispatchEvent(removedEvent);
|
|
10516
|
+
|
|
10517
|
+
if ((_child$ownerDocument = child.ownerDocument) === null || _child$ownerDocument === void 0 ? void 0 : _child$ownerDocument.defaultView) {
|
|
10518
|
+
child.ownerDocument.defaultView.unmountChildren(child);
|
|
10519
|
+
} // remove from scene graph
|
|
10520
|
+
|
|
10555
10521
|
|
|
10522
|
+
runtime.sceneGraphService.detach(child);
|
|
10556
10523
|
return child;
|
|
10557
10524
|
}
|
|
10558
10525
|
/**
|
|
@@ -10845,14 +10812,13 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10845
10812
|
var value = this.attributes[name];
|
|
10846
10813
|
|
|
10847
10814
|
if (value === undefined) {
|
|
10848
|
-
var
|
|
10849
|
-
|
|
10815
|
+
var attributeName = formatAttributeName(name);
|
|
10816
|
+
value = this.attributes[attributeName]; // if the given attribute does not exist, the value returned will either be null or ""
|
|
10850
10817
|
|
|
10851
|
-
value
|
|
10852
|
-
}
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
return isNil(value) ? null : value;
|
|
10818
|
+
return isNil(value) ? null : value;
|
|
10819
|
+
} else {
|
|
10820
|
+
return value;
|
|
10821
|
+
}
|
|
10856
10822
|
}
|
|
10857
10823
|
/**
|
|
10858
10824
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
|
|
@@ -11255,6 +11221,7 @@ var DEFAULT_PARSED_STYLE_PROPS = {
|
|
|
11255
11221
|
filter: [],
|
|
11256
11222
|
shadowType: 'outer'
|
|
11257
11223
|
};
|
|
11224
|
+
var INHERITABLE_STYLE_PROPS = ['opacity', 'fillOpacity', 'strokeOpacity', 'transformOrigin', 'visibility', 'pointerEvents', 'lineWidth', 'lineCap', 'lineJoin', 'increasedLineWidthForHitTesting', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'textAlign', 'textBaseline', 'textTransform'];
|
|
11258
11225
|
/**
|
|
11259
11226
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
11260
11227
|
*
|
|
@@ -11294,7 +11261,13 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11294
11261
|
|
|
11295
11262
|
_this.config = void 0;
|
|
11296
11263
|
_this.isCustomElement = false;
|
|
11264
|
+
_this.isMutationObserved = false;
|
|
11297
11265
|
_this.activeAnimations = [];
|
|
11266
|
+
|
|
11267
|
+
_this.getClip = function () {
|
|
11268
|
+
return this.style.clipPath || null;
|
|
11269
|
+
};
|
|
11270
|
+
|
|
11298
11271
|
_this.config = config; // compatible with G 3.0
|
|
11299
11272
|
|
|
11300
11273
|
_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
|
|
@@ -11423,14 +11396,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11423
11396
|
|
|
11424
11397
|
runtime.styleValueRegistry.processProperties(this, attributes, {
|
|
11425
11398
|
forceUpdateGeometry: true,
|
|
11426
|
-
usedAttributes:
|
|
11427
|
-
// 'transform',
|
|
11428
|
-
// 'zIndex',
|
|
11429
|
-
// 'filter',
|
|
11430
|
-
// 'shadowType',
|
|
11431
|
-
// 'fill',
|
|
11432
|
-
// 'stroke',
|
|
11433
|
-
'opacity', 'fillOpacity', 'strokeOpacity', 'transformOrigin', 'visibility', 'pointerEvents', 'lineWidth', 'lineCap', 'lineJoin', 'increasedLineWidthForHitTesting', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'textAlign', 'textBaseline', 'textTransform']
|
|
11399
|
+
usedAttributes: INHERITABLE_STYLE_PROPS
|
|
11434
11400
|
}); // redraw at next frame
|
|
11435
11401
|
|
|
11436
11402
|
renderable.dirty = true;
|
|
@@ -11441,19 +11407,16 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11441
11407
|
force = false;
|
|
11442
11408
|
}
|
|
11443
11409
|
|
|
11444
|
-
var
|
|
11445
|
-
attributeName = _formatAttribute[0],
|
|
11446
|
-
attributeValue = _formatAttribute[1]; // ignore undefined value
|
|
11447
|
-
|
|
11410
|
+
var attributeName = formatAttributeName(name); // ignore undefined value
|
|
11448
11411
|
|
|
11449
11412
|
if (isUndefined(value)) {
|
|
11450
11413
|
return;
|
|
11451
11414
|
}
|
|
11452
11415
|
|
|
11453
|
-
if (force ||
|
|
11454
|
-
this.internalSetAttribute(attributeName,
|
|
11416
|
+
if (force || value !== this.attributes[attributeName]) {
|
|
11417
|
+
this.internalSetAttribute(attributeName, value);
|
|
11455
11418
|
|
|
11456
|
-
_Element.prototype.setAttribute.call(this, attributeName,
|
|
11419
|
+
_Element.prototype.setAttribute.call(this, attributeName, value);
|
|
11457
11420
|
}
|
|
11458
11421
|
}
|
|
11459
11422
|
/**
|
|
@@ -11483,7 +11446,13 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11483
11446
|
mutationEvent.attrName = name;
|
|
11484
11447
|
mutationEvent.prevParsedValue = oldParsedValue;
|
|
11485
11448
|
mutationEvent.newParsedValue = newParsedValue;
|
|
11486
|
-
|
|
11449
|
+
|
|
11450
|
+
if (this.isMutationObserved) {
|
|
11451
|
+
this.dispatchEvent(mutationEvent);
|
|
11452
|
+
} else {
|
|
11453
|
+
mutationEvent.target = this;
|
|
11454
|
+
this.ownerDocument.defaultView.dispatchEvent(mutationEvent, true);
|
|
11455
|
+
}
|
|
11487
11456
|
}
|
|
11488
11457
|
|
|
11489
11458
|
if ((this.isCustomElement && this.isConnected || !this.isCustomElement) && this.attributeChangedCallback) {
|
|
@@ -11667,10 +11636,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11667
11636
|
;
|
|
11668
11637
|
|
|
11669
11638
|
_proto.getEulerAngles = function getEulerAngles() {
|
|
11670
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11671
11639
|
var _getEuler = getEuler(vec3.create(), runtime.sceneGraphService.getWorldTransform(this)),
|
|
11672
|
-
ex = _getEuler[0],
|
|
11673
|
-
ey = _getEuler[1],
|
|
11674
11640
|
ez = _getEuler[2];
|
|
11675
11641
|
|
|
11676
11642
|
return rad2deg(ez);
|
|
@@ -11681,10 +11647,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11681
11647
|
;
|
|
11682
11648
|
|
|
11683
11649
|
_proto.getLocalEulerAngles = function getLocalEulerAngles() {
|
|
11684
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11685
11650
|
var _getEuler2 = getEuler(vec3.create(), runtime.sceneGraphService.getLocalRotation(this)),
|
|
11686
|
-
ex = _getEuler2[0],
|
|
11687
|
-
ey = _getEuler2[1],
|
|
11688
11651
|
ez = _getEuler2[2];
|
|
11689
11652
|
|
|
11690
11653
|
return rad2deg(ez);
|
|
@@ -11911,11 +11874,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11911
11874
|
sx = _mat4$getScaling[0],
|
|
11912
11875
|
sy = _mat4$getScaling[1];
|
|
11913
11876
|
|
|
11914
|
-
var rotation = mat4.getRotation(quat$1.create(), transform);
|
|
11877
|
+
var rotation = mat4.getRotation(quat$1.create(), transform);
|
|
11915
11878
|
|
|
11916
11879
|
var _getEuler3 = getEuler(vec3.create(), rotation),
|
|
11917
11880
|
eux = _getEuler3[0],
|
|
11918
|
-
euy = _getEuler3[1],
|
|
11919
11881
|
euz = _getEuler3[2]; // gimbal lock at 90 degrees
|
|
11920
11882
|
|
|
11921
11883
|
|
|
@@ -11979,6 +11941,145 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11979
11941
|
|
|
11980
11942
|
_proto.hide = function hide() {
|
|
11981
11943
|
this.style.visibility = 'hidden';
|
|
11944
|
+
}
|
|
11945
|
+
/**
|
|
11946
|
+
* Use `childElementCount` instead.
|
|
11947
|
+
* @deprecated
|
|
11948
|
+
*/
|
|
11949
|
+
;
|
|
11950
|
+
|
|
11951
|
+
_proto.getCount = function getCount() {
|
|
11952
|
+
return this.childElementCount;
|
|
11953
|
+
}
|
|
11954
|
+
/**
|
|
11955
|
+
* Use `parentElement` instead.
|
|
11956
|
+
* @deprecated
|
|
11957
|
+
*/
|
|
11958
|
+
;
|
|
11959
|
+
|
|
11960
|
+
_proto.getParent = function getParent() {
|
|
11961
|
+
return this.parentElement;
|
|
11962
|
+
}
|
|
11963
|
+
/**
|
|
11964
|
+
* Use `children` instead.
|
|
11965
|
+
* @deprecated
|
|
11966
|
+
*/
|
|
11967
|
+
;
|
|
11968
|
+
|
|
11969
|
+
_proto.getChildren = function getChildren() {
|
|
11970
|
+
return this.children;
|
|
11971
|
+
}
|
|
11972
|
+
/**
|
|
11973
|
+
* Use `firstElementChild` instead.
|
|
11974
|
+
* @deprecated
|
|
11975
|
+
*/
|
|
11976
|
+
;
|
|
11977
|
+
|
|
11978
|
+
_proto.getFirst = function getFirst() {
|
|
11979
|
+
return this.firstElementChild;
|
|
11980
|
+
}
|
|
11981
|
+
/**
|
|
11982
|
+
* Use `lastElementChild` instead.
|
|
11983
|
+
* @deprecated
|
|
11984
|
+
*/
|
|
11985
|
+
;
|
|
11986
|
+
|
|
11987
|
+
_proto.getLast = function getLast() {
|
|
11988
|
+
return this.lastElementChild;
|
|
11989
|
+
}
|
|
11990
|
+
/**
|
|
11991
|
+
* Use `this.children[index]` instead.
|
|
11992
|
+
* @deprecated
|
|
11993
|
+
*/
|
|
11994
|
+
;
|
|
11995
|
+
|
|
11996
|
+
_proto.getChildByIndex = function getChildByIndex(index) {
|
|
11997
|
+
return this.children[index] || null;
|
|
11998
|
+
}
|
|
11999
|
+
/**
|
|
12000
|
+
* Use `appendChild` instead.
|
|
12001
|
+
* @deprecated
|
|
12002
|
+
*/
|
|
12003
|
+
;
|
|
12004
|
+
|
|
12005
|
+
_proto.add = function add(child, index) {
|
|
12006
|
+
return this.appendChild(child, index);
|
|
12007
|
+
}
|
|
12008
|
+
/**
|
|
12009
|
+
* Use `this.style.clipPath` instead.
|
|
12010
|
+
* @deprecated
|
|
12011
|
+
*/
|
|
12012
|
+
;
|
|
12013
|
+
|
|
12014
|
+
_proto.setClip = function setClip(clipPath) {
|
|
12015
|
+
this.style.clipPath = clipPath;
|
|
12016
|
+
}
|
|
12017
|
+
/**
|
|
12018
|
+
* Use `this.style.clipPath` instead.
|
|
12019
|
+
* @deprecated
|
|
12020
|
+
*/
|
|
12021
|
+
;
|
|
12022
|
+
|
|
12023
|
+
/**
|
|
12024
|
+
* @deprecated
|
|
12025
|
+
*/
|
|
12026
|
+
_proto.set = function set(name, value) {
|
|
12027
|
+
// @ts-ignore
|
|
12028
|
+
this.config[name] = value;
|
|
12029
|
+
}
|
|
12030
|
+
/**
|
|
12031
|
+
* @deprecated
|
|
12032
|
+
*/
|
|
12033
|
+
;
|
|
12034
|
+
|
|
12035
|
+
_proto.get = function get(name) {
|
|
12036
|
+
return this.config[name];
|
|
12037
|
+
}
|
|
12038
|
+
/**
|
|
12039
|
+
* Use `setPosition` instead.
|
|
12040
|
+
* @deprecated
|
|
12041
|
+
*/
|
|
12042
|
+
;
|
|
12043
|
+
|
|
12044
|
+
_proto.moveTo = function moveTo(position, y, z) {
|
|
12045
|
+
if (y === void 0) {
|
|
12046
|
+
y = 0;
|
|
12047
|
+
}
|
|
12048
|
+
|
|
12049
|
+
if (z === void 0) {
|
|
12050
|
+
z = 0;
|
|
12051
|
+
}
|
|
12052
|
+
|
|
12053
|
+
this.setPosition(position, y, z);
|
|
12054
|
+
return this;
|
|
12055
|
+
}
|
|
12056
|
+
/**
|
|
12057
|
+
* Use `setPosition` instead.
|
|
12058
|
+
* @deprecated
|
|
12059
|
+
*/
|
|
12060
|
+
;
|
|
12061
|
+
|
|
12062
|
+
_proto.move = function move(position, y, z) {
|
|
12063
|
+
if (y === void 0) {
|
|
12064
|
+
y = 0;
|
|
12065
|
+
}
|
|
12066
|
+
|
|
12067
|
+
if (z === void 0) {
|
|
12068
|
+
z = 0;
|
|
12069
|
+
}
|
|
12070
|
+
|
|
12071
|
+
this.setPosition(position, y, z);
|
|
12072
|
+
return this;
|
|
12073
|
+
}
|
|
12074
|
+
/**
|
|
12075
|
+
* Use `this.style.zIndex` instead.
|
|
12076
|
+
* @deprecated
|
|
12077
|
+
*/
|
|
12078
|
+
;
|
|
12079
|
+
|
|
12080
|
+
_proto.setZIndex = function setZIndex(zIndex) {
|
|
12081
|
+
this.style.zIndex = zIndex;
|
|
12082
|
+
return this;
|
|
11982
12083
|
};
|
|
11983
12084
|
|
|
11984
12085
|
_createClass(DisplayObject, [{
|
|
@@ -12408,7 +12509,11 @@ var Line = /*#__PURE__*/function (_DisplayObject) {
|
|
|
12408
12509
|
marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
|
|
12409
12510
|
};
|
|
12410
12511
|
|
|
12411
|
-
_proto.getPoint = function getPoint(ratio) {
|
|
12512
|
+
_proto.getPoint = function getPoint(ratio, inWorldSpace) {
|
|
12513
|
+
if (inWorldSpace === void 0) {
|
|
12514
|
+
inWorldSpace = false;
|
|
12515
|
+
}
|
|
12516
|
+
|
|
12412
12517
|
// TODO: account for z1/z2 in 3D line
|
|
12413
12518
|
var _this$parsedStyle3 = this.parsedStyle,
|
|
12414
12519
|
x1 = _this$parsedStyle3.x1,
|
|
@@ -12422,13 +12527,17 @@ var Line = /*#__PURE__*/function (_DisplayObject) {
|
|
|
12422
12527
|
x = _LineUtil$pointAt.x,
|
|
12423
12528
|
y = _LineUtil$pointAt.y;
|
|
12424
12529
|
|
|
12425
|
-
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
|
|
12530
|
+
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform()); // apply local transformation
|
|
12426
12531
|
|
|
12427
12532
|
return new Point(transformed[0], transformed[1]);
|
|
12428
12533
|
};
|
|
12429
12534
|
|
|
12430
|
-
_proto.getPointAtLength = function getPointAtLength(distance) {
|
|
12431
|
-
|
|
12535
|
+
_proto.getPointAtLength = function getPointAtLength(distance, inWorldSpace) {
|
|
12536
|
+
if (inWorldSpace === void 0) {
|
|
12537
|
+
inWorldSpace = false;
|
|
12538
|
+
}
|
|
12539
|
+
|
|
12540
|
+
return this.getPoint(distance / this.getTotalLength(), inWorldSpace);
|
|
12432
12541
|
};
|
|
12433
12542
|
|
|
12434
12543
|
_proto.getTotalLength = function getTotalLength() {
|
|
@@ -12625,7 +12734,11 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
12625
12734
|
*/
|
|
12626
12735
|
;
|
|
12627
12736
|
|
|
12628
|
-
_proto.getPointAtLength = function getPointAtLength$1(distance) {
|
|
12737
|
+
_proto.getPointAtLength = function getPointAtLength$1(distance, inWorldSpace) {
|
|
12738
|
+
if (inWorldSpace === void 0) {
|
|
12739
|
+
inWorldSpace = false;
|
|
12740
|
+
}
|
|
12741
|
+
|
|
12629
12742
|
var _this$parsedStyle4 = this.parsedStyle,
|
|
12630
12743
|
defX = _this$parsedStyle4.defX,
|
|
12631
12744
|
defY = _this$parsedStyle4.defY,
|
|
@@ -12635,7 +12748,7 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
12635
12748
|
x = _getPointAtLength2.x,
|
|
12636
12749
|
y = _getPointAtLength2.y;
|
|
12637
12750
|
|
|
12638
|
-
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
|
|
12751
|
+
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform()); // apply local transformation
|
|
12639
12752
|
|
|
12640
12753
|
return new Point(transformed[0], transformed[1]);
|
|
12641
12754
|
}
|
|
@@ -12644,8 +12757,12 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
12644
12757
|
*/
|
|
12645
12758
|
;
|
|
12646
12759
|
|
|
12647
|
-
_proto.getPoint = function getPoint(ratio) {
|
|
12648
|
-
|
|
12760
|
+
_proto.getPoint = function getPoint(ratio, inWorldSpace) {
|
|
12761
|
+
if (inWorldSpace === void 0) {
|
|
12762
|
+
inWorldSpace = false;
|
|
12763
|
+
}
|
|
12764
|
+
|
|
12765
|
+
return this.getPointAtLength(ratio * getOrCalculatePathTotalLength(this), inWorldSpace);
|
|
12649
12766
|
}
|
|
12650
12767
|
/**
|
|
12651
12768
|
* Get start tangent vector
|
|
@@ -12904,11 +13021,19 @@ var Polyline = /*#__PURE__*/function (_Polygon) {
|
|
|
12904
13021
|
return this.parsedStyle.points.totalLength;
|
|
12905
13022
|
};
|
|
12906
13023
|
|
|
12907
|
-
_proto.getPointAtLength = function getPointAtLength(distance) {
|
|
12908
|
-
|
|
13024
|
+
_proto.getPointAtLength = function getPointAtLength(distance, inWorldSpace) {
|
|
13025
|
+
if (inWorldSpace === void 0) {
|
|
13026
|
+
inWorldSpace = false;
|
|
13027
|
+
}
|
|
13028
|
+
|
|
13029
|
+
return this.getPoint(distance / this.getTotalLength(), inWorldSpace);
|
|
12909
13030
|
};
|
|
12910
13031
|
|
|
12911
|
-
_proto.getPoint = function getPoint(ratio) {
|
|
13032
|
+
_proto.getPoint = function getPoint(ratio, inWorldSpace) {
|
|
13033
|
+
if (inWorldSpace === void 0) {
|
|
13034
|
+
inWorldSpace = false;
|
|
13035
|
+
}
|
|
13036
|
+
|
|
12912
13037
|
var _this$parsedStyle = this.parsedStyle,
|
|
12913
13038
|
defX = _this$parsedStyle.defX,
|
|
12914
13039
|
defY = _this$parsedStyle.defY,
|
|
@@ -12928,7 +13053,7 @@ var Polyline = /*#__PURE__*/function (_Polygon) {
|
|
|
12928
13053
|
x = _LineUtil$pointAt.x,
|
|
12929
13054
|
y = _LineUtil$pointAt.y;
|
|
12930
13055
|
|
|
12931
|
-
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
|
|
13056
|
+
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform()); // apply local transformation
|
|
12932
13057
|
|
|
12933
13058
|
return new Point(transformed[0], transformed[1]);
|
|
12934
13059
|
};
|
|
@@ -13443,18 +13568,25 @@ var Camera = /*#__PURE__*/function () {
|
|
|
13443
13568
|
ox = _this$canvas$viewport.x,
|
|
13444
13569
|
oy = _this$canvas$viewport.y;
|
|
13445
13570
|
|
|
13571
|
+
var roll = this.roll;
|
|
13572
|
+
this.rotate(0, 0, -roll);
|
|
13446
13573
|
this.setPosition(ox, oy);
|
|
13447
13574
|
this.setFocalPoint(ox, oy);
|
|
13448
13575
|
this.setZoom(zoom);
|
|
13576
|
+
this.rotate(0, 0, roll);
|
|
13449
13577
|
|
|
13450
13578
|
var _this$canvas$viewport2 = this.canvas.viewport2Canvas({
|
|
13451
13579
|
x: viewportPoint[0],
|
|
13452
13580
|
y: viewportPoint[1]
|
|
13453
13581
|
}),
|
|
13454
13582
|
cx = _this$canvas$viewport2.x,
|
|
13455
|
-
cy = _this$canvas$viewport2.y;
|
|
13583
|
+
cy = _this$canvas$viewport2.y; // project to rotated axis
|
|
13584
|
+
|
|
13456
13585
|
|
|
13457
|
-
|
|
13586
|
+
var dvec = vec3.fromValues(cx - ox, cy - oy, 0);
|
|
13587
|
+
var dx = vec3.dot(dvec, this.right) / vec3.length(this.right);
|
|
13588
|
+
var dy = vec3.dot(dvec, this.up) / vec3.length(this.up);
|
|
13589
|
+
this.pan(-dx, -dy);
|
|
13458
13590
|
return this;
|
|
13459
13591
|
};
|
|
13460
13592
|
|
|
@@ -14118,7 +14250,7 @@ var TextUpdater = /*#__PURE__*/function () {
|
|
|
14118
14250
|
var anchor = [0, 1];
|
|
14119
14251
|
var lineXOffset = 0;
|
|
14120
14252
|
|
|
14121
|
-
if (textAlign === 'center') {
|
|
14253
|
+
if (textAlign === 'center' || textAlign === 'middle') {
|
|
14122
14254
|
lineXOffset = lineWidth / 2;
|
|
14123
14255
|
anchor = [0.5, 1];
|
|
14124
14256
|
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
@@ -14843,10 +14975,20 @@ var EventService = /*#__PURE__*/function () {
|
|
|
14843
14975
|
}
|
|
14844
14976
|
};
|
|
14845
14977
|
|
|
14846
|
-
_proto.dispatchEvent = function dispatchEvent(e, type) {
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14978
|
+
_proto.dispatchEvent = function dispatchEvent(e, type, skipPropagate) {
|
|
14979
|
+
// Canvas should skip
|
|
14980
|
+
if (!skipPropagate) {
|
|
14981
|
+
e.propagationStopped = false;
|
|
14982
|
+
e.propagationImmediatelyStopped = false;
|
|
14983
|
+
this.propagate(e, type);
|
|
14984
|
+
} else {
|
|
14985
|
+
// target phase
|
|
14986
|
+
e.eventPhase = e.AT_TARGET;
|
|
14987
|
+
var canvas = this.rootTarget.defaultView || null;
|
|
14988
|
+
e.currentTarget = canvas;
|
|
14989
|
+
this.notifyListeners(e, type);
|
|
14990
|
+
}
|
|
14991
|
+
|
|
14850
14992
|
this.emitter.emit(type || e.type, e);
|
|
14851
14993
|
};
|
|
14852
14994
|
|
|
@@ -15653,10 +15795,11 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
15653
15795
|
|
|
15654
15796
|
if (renderOrderChanged) {
|
|
15655
15797
|
displayObject.forEach(function (child) {
|
|
15798
|
+
_this2.renderOrderChangedEvent.target = child;
|
|
15656
15799
|
_this2.renderOrderChangedEvent.detail = {
|
|
15657
15800
|
renderOrder: child.sortable.renderOrder
|
|
15658
15801
|
};
|
|
15659
|
-
child.dispatchEvent(_this2.renderOrderChangedEvent);
|
|
15802
|
+
child.ownerDocument.defaultView.dispatchEvent(_this2.renderOrderChangedEvent, true);
|
|
15660
15803
|
});
|
|
15661
15804
|
}
|
|
15662
15805
|
};
|
|
@@ -16317,9 +16460,10 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
16317
16460
|
var set = new Set();
|
|
16318
16461
|
|
|
16319
16462
|
var trigger = function trigger(element, detail) {
|
|
16320
|
-
if (!set.has(element.entity)) {
|
|
16463
|
+
if (element.isConnected && !set.has(element.entity)) {
|
|
16321
16464
|
_this2.boundsChangedEvent.detail = detail;
|
|
16322
|
-
|
|
16465
|
+
_this2.boundsChangedEvent.target = element;
|
|
16466
|
+
element.ownerDocument.defaultView.dispatchEvent(_this2.boundsChangedEvent, true);
|
|
16323
16467
|
set.add(element.entity);
|
|
16324
16468
|
}
|
|
16325
16469
|
};
|
|
@@ -16337,6 +16481,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
16337
16481
|
}
|
|
16338
16482
|
});
|
|
16339
16483
|
this.pendingEvents = [];
|
|
16484
|
+
set.clear();
|
|
16340
16485
|
};
|
|
16341
16486
|
|
|
16342
16487
|
_proto.dirtifyToRoot = function dirtifyToRoot(element, affectChildren) {
|
|
@@ -16987,7 +17132,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
16987
17132
|
lineMetrics: lineWidths.map(function (width, i) {
|
|
16988
17133
|
var offsetX = 0; // handle horizontal text align
|
|
16989
17134
|
|
|
16990
|
-
if (textAlign === 'center') {
|
|
17135
|
+
if (textAlign === 'center' || textAlign === 'middle') {
|
|
16991
17136
|
offsetX -= width / 2;
|
|
16992
17137
|
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
16993
17138
|
offsetX -= width;
|
|
@@ -17817,21 +17962,14 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17817
17962
|
|
|
17818
17963
|
var _proto = PrepareRendererPlugin.prototype;
|
|
17819
17964
|
|
|
17820
|
-
|
|
17821
|
-
var _this = this;
|
|
17822
|
-
|
|
17823
|
-
list.forEach(function (i) {
|
|
17824
|
-
_this.toSync.add(i);
|
|
17825
|
-
});
|
|
17826
|
-
} // private isFirstTimeRendering = true;
|
|
17827
|
-
;
|
|
17828
|
-
|
|
17965
|
+
// private isFirstTimeRendering = true;
|
|
17829
17966
|
_proto.apply = function apply(context) {
|
|
17830
|
-
var
|
|
17967
|
+
var _this = this;
|
|
17831
17968
|
|
|
17832
17969
|
var renderingService = context.renderingService,
|
|
17833
17970
|
renderingContext = context.renderingContext,
|
|
17834
17971
|
rBushRoot = context.rBushRoot;
|
|
17972
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
17835
17973
|
this.rBush = rBushRoot;
|
|
17836
17974
|
|
|
17837
17975
|
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
@@ -17846,20 +17984,26 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17846
17984
|
|
|
17847
17985
|
if (affectChildren) {
|
|
17848
17986
|
object.forEach(function (node) {
|
|
17849
|
-
|
|
17987
|
+
_this.toSync.add(node);
|
|
17850
17988
|
});
|
|
17851
17989
|
}
|
|
17852
17990
|
|
|
17853
|
-
|
|
17991
|
+
var p = object;
|
|
17992
|
+
|
|
17993
|
+
while (p) {
|
|
17994
|
+
if (p.renderable) {
|
|
17995
|
+
_this.toSync.add(p);
|
|
17996
|
+
}
|
|
17997
|
+
|
|
17998
|
+
p = p.parentElement;
|
|
17999
|
+
} // this.pushToSync(e.composedPath().slice(0, -2) as DisplayObject[]);
|
|
18000
|
+
|
|
17854
18001
|
|
|
17855
18002
|
renderingService.dirtify();
|
|
17856
18003
|
};
|
|
17857
18004
|
|
|
17858
18005
|
var handleMounted = function handleMounted(e) {
|
|
17859
|
-
var object = e.target;
|
|
17860
|
-
|
|
17861
|
-
_this2.pushToSync(e.composedPath().slice(0, -2)); // recalc style values
|
|
17862
|
-
|
|
18006
|
+
var object = e.target; // recalc style values
|
|
17863
18007
|
|
|
17864
18008
|
runtime.styleValueRegistry.recalc(object);
|
|
17865
18009
|
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
@@ -17871,12 +18015,12 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17871
18015
|
var rBushNode = object.rBushNode;
|
|
17872
18016
|
|
|
17873
18017
|
if (rBushNode.aabb) {
|
|
17874
|
-
|
|
18018
|
+
_this.rBush.remove(rBushNode.aabb);
|
|
17875
18019
|
}
|
|
17876
18020
|
|
|
17877
|
-
|
|
18021
|
+
_this.toSync.delete(object);
|
|
17878
18022
|
|
|
17879
|
-
runtime.sceneGraphService.dirtifyToRoot(
|
|
18023
|
+
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
17880
18024
|
renderingService.dirtify();
|
|
17881
18025
|
};
|
|
17882
18026
|
|
|
@@ -17885,10 +18029,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17885
18029
|
while (1) {
|
|
17886
18030
|
switch (_context.prev = _context.next) {
|
|
17887
18031
|
case 0:
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
18032
|
+
canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
18033
|
+
canvas.addEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
18034
|
+
canvas.addEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
18035
|
+
canvas.addEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
17892
18036
|
|
|
17893
18037
|
case 4:
|
|
17894
18038
|
case "end":
|
|
@@ -17898,10 +18042,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17898
18042
|
}, _callee);
|
|
17899
18043
|
})));
|
|
17900
18044
|
renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag, function () {
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
18045
|
+
canvas.removeEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
18046
|
+
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
18047
|
+
canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
18048
|
+
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
17905
18049
|
});
|
|
17906
18050
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
17907
18051
|
// if (this.isFirstTimeRendering) {
|
|
@@ -17911,12 +18055,12 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17911
18055
|
// } else {
|
|
17912
18056
|
// this.syncRTree();
|
|
17913
18057
|
// }
|
|
17914
|
-
|
|
18058
|
+
_this.syncRTree();
|
|
17915
18059
|
});
|
|
17916
18060
|
};
|
|
17917
18061
|
|
|
17918
18062
|
_proto.syncRTree = function syncRTree() {
|
|
17919
|
-
var
|
|
18063
|
+
var _this2 = this;
|
|
17920
18064
|
|
|
17921
18065
|
// bounds changed, need re-inserting its children
|
|
17922
18066
|
var bulk = [];
|
|
@@ -17927,7 +18071,7 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
17927
18071
|
var rBushNode = node.rBushNode; // clear dirty node
|
|
17928
18072
|
|
|
17929
18073
|
if (rBushNode && rBushNode.aabb) {
|
|
17930
|
-
|
|
18074
|
+
_this2.rBush.remove(rBushNode.aabb);
|
|
17931
18075
|
}
|
|
17932
18076
|
|
|
17933
18077
|
var renderBounds = node.getRenderBounds();
|
|
@@ -17986,6 +18130,14 @@ var CanvasEvent;
|
|
|
17986
18130
|
var DEFAULT_CAMERA_Z = 500;
|
|
17987
18131
|
var DEFAULT_CAMERA_NEAR = 0.1;
|
|
17988
18132
|
var DEFAULT_CAMERA_FAR = 1000;
|
|
18133
|
+
/**
|
|
18134
|
+
* reuse custom event preventing from re-create them in every frame
|
|
18135
|
+
*/
|
|
18136
|
+
|
|
18137
|
+
var mountedEvent = new CustomEvent(ElementEvent.MOUNTED);
|
|
18138
|
+
var unmountedEvent = new CustomEvent(ElementEvent.UNMOUNTED);
|
|
18139
|
+
var beforeRenderEvent = new CustomEvent(CanvasEvent.BEFORE_RENDER);
|
|
18140
|
+
var afterRenderEvent = new CustomEvent(CanvasEvent.AFTER_RENDER);
|
|
17989
18141
|
/**
|
|
17990
18142
|
* can be treated like Window in DOM
|
|
17991
18143
|
* provide some extra methods like `window`, such as:
|
|
@@ -18043,10 +18195,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18043
18195
|
/**
|
|
18044
18196
|
* rAF in auto rendering
|
|
18045
18197
|
*/
|
|
18046
|
-
|
|
18047
|
-
/**
|
|
18048
|
-
* reuse custom event preventing from re-create them in every frame
|
|
18049
|
-
*/
|
|
18050
18198
|
function Canvas(config) {
|
|
18051
18199
|
var _this;
|
|
18052
18200
|
|
|
@@ -18066,10 +18214,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18066
18214
|
_this.inited = false;
|
|
18067
18215
|
_this.readyPromise = void 0;
|
|
18068
18216
|
_this.resolveReadyPromise = void 0;
|
|
18069
|
-
_this.mountEvent = new CustomEvent(ElementEvent.MOUNTED);
|
|
18070
|
-
_this.unmountEvent = new CustomEvent(ElementEvent.UNMOUNTED);
|
|
18071
|
-
_this.beforeRenderEvent = new CustomEvent(CanvasEvent.BEFORE_RENDER);
|
|
18072
|
-
_this.afterRenderEvent = new CustomEvent(CanvasEvent.AFTER_RENDER);
|
|
18073
18217
|
_this.context = {};
|
|
18074
18218
|
_this.document = new Document();
|
|
18075
18219
|
_this.document.defaultView = _assertThisInitialized(_this); // create registry of custom elements
|
|
@@ -18174,8 +18318,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18174
18318
|
var _proto = Canvas.prototype;
|
|
18175
18319
|
|
|
18176
18320
|
_proto.initRenderingContext = function initRenderingContext(mergedConfig) {
|
|
18177
|
-
var _this2 = this;
|
|
18178
|
-
|
|
18179
18321
|
this.context.config = mergedConfig; // bind rendering context, shared by all renderers
|
|
18180
18322
|
|
|
18181
18323
|
this.context.renderingContext = {
|
|
@@ -18189,16 +18331,10 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18189
18331
|
force: false,
|
|
18190
18332
|
dirty: false
|
|
18191
18333
|
};
|
|
18192
|
-
this.document.documentElement.addEventListener(ElementEvent.CHILD_INSERTED, function (e) {
|
|
18193
|
-
_this2.mountChildren(e.detail.child);
|
|
18194
|
-
});
|
|
18195
|
-
this.document.documentElement.addEventListener(ElementEvent.CHILD_REMOVED, function (e) {
|
|
18196
|
-
_this2.unmountChildren(e.detail.child);
|
|
18197
|
-
});
|
|
18198
18334
|
};
|
|
18199
18335
|
|
|
18200
18336
|
_proto.initDefaultCamera = function initDefaultCamera(width, height) {
|
|
18201
|
-
var
|
|
18337
|
+
var _this2 = this;
|
|
18202
18338
|
|
|
18203
18339
|
// set a default ortho camera
|
|
18204
18340
|
var camera = new runtime.CameraContribution();
|
|
@@ -18207,7 +18343,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18207
18343
|
camera.canvas = this; // redraw when camera changed
|
|
18208
18344
|
|
|
18209
18345
|
camera.eventEmitter.on(CameraEvent.UPDATED, function () {
|
|
18210
|
-
|
|
18346
|
+
_this2.context.renderingContext.renderReasons.add(RenderReason.CAMERA_CHANGED);
|
|
18211
18347
|
}); // bind camera
|
|
18212
18348
|
|
|
18213
18349
|
this.context.camera = camera;
|
|
@@ -18351,19 +18487,19 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18351
18487
|
};
|
|
18352
18488
|
|
|
18353
18489
|
_proto.render = function render() {
|
|
18354
|
-
this.dispatchEvent(
|
|
18490
|
+
this.dispatchEvent(beforeRenderEvent);
|
|
18355
18491
|
var renderingService = this.getRenderingService();
|
|
18356
18492
|
renderingService.render(this.getConfig());
|
|
18357
|
-
this.dispatchEvent(
|
|
18493
|
+
this.dispatchEvent(afterRenderEvent);
|
|
18358
18494
|
};
|
|
18359
18495
|
|
|
18360
18496
|
_proto.run = function run() {
|
|
18361
|
-
var
|
|
18497
|
+
var _this3 = this;
|
|
18362
18498
|
|
|
18363
18499
|
var tick = function tick() {
|
|
18364
|
-
|
|
18500
|
+
_this3.render();
|
|
18365
18501
|
|
|
18366
|
-
|
|
18502
|
+
_this3.frameId = requestAnimationFrame(tick);
|
|
18367
18503
|
};
|
|
18368
18504
|
|
|
18369
18505
|
tick();
|
|
@@ -18441,12 +18577,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18441
18577
|
}();
|
|
18442
18578
|
|
|
18443
18579
|
_proto.loadRendererContainerModule = function loadRendererContainerModule(renderer) {
|
|
18444
|
-
var
|
|
18580
|
+
var _this4 = this;
|
|
18445
18581
|
|
|
18446
18582
|
// load other container modules provided by g-canvas/g-svg/g-webgl
|
|
18447
18583
|
var plugins = renderer.getPlugins();
|
|
18448
18584
|
plugins.forEach(function (plugin) {
|
|
18449
|
-
plugin.context =
|
|
18585
|
+
plugin.context = _this4.context;
|
|
18450
18586
|
plugin.init();
|
|
18451
18587
|
});
|
|
18452
18588
|
};
|
|
@@ -18502,7 +18638,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18502
18638
|
};
|
|
18503
18639
|
|
|
18504
18640
|
_proto.unmountChildren = function unmountChildren(parent) {
|
|
18505
|
-
var
|
|
18641
|
+
var _this5 = this;
|
|
18506
18642
|
|
|
18507
18643
|
if (this.inited) {
|
|
18508
18644
|
var path = [];
|
|
@@ -18514,15 +18650,22 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18514
18650
|
|
|
18515
18651
|
path.reverse().forEach(function (child) {
|
|
18516
18652
|
// trigger before unmounted
|
|
18517
|
-
if (child
|
|
18653
|
+
if (child.isCustomElement) {
|
|
18518
18654
|
if (child.disconnectedCallback) {
|
|
18519
18655
|
child.disconnectedCallback();
|
|
18520
18656
|
}
|
|
18521
18657
|
}
|
|
18522
18658
|
|
|
18523
|
-
child.
|
|
18659
|
+
if (child.isMutationObserved) {
|
|
18660
|
+
child.dispatchEvent(unmountedEvent);
|
|
18661
|
+
} else {
|
|
18662
|
+
unmountedEvent.target = child;
|
|
18663
|
+
|
|
18664
|
+
_this5.dispatchEvent(unmountedEvent, true);
|
|
18665
|
+
} // skip document.documentElement
|
|
18666
|
+
|
|
18524
18667
|
|
|
18525
|
-
if (child !==
|
|
18668
|
+
if (child !== _this5.document.documentElement) {
|
|
18526
18669
|
child.ownerDocument = null;
|
|
18527
18670
|
}
|
|
18528
18671
|
|
|
@@ -18532,16 +18675,24 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18532
18675
|
};
|
|
18533
18676
|
|
|
18534
18677
|
_proto.mountChildren = function mountChildren(parent) {
|
|
18535
|
-
var
|
|
18678
|
+
var _this6 = this;
|
|
18536
18679
|
|
|
18537
18680
|
if (this.inited) {
|
|
18538
18681
|
parent.forEach(function (child) {
|
|
18539
18682
|
if (!child.isConnected) {
|
|
18540
|
-
child.ownerDocument =
|
|
18683
|
+
child.ownerDocument = _this6.document;
|
|
18541
18684
|
child.isConnected = true;
|
|
18542
|
-
child.dispatchEvent(_this7.mountEvent); // trigger after mounted
|
|
18543
18685
|
|
|
18544
|
-
if (child
|
|
18686
|
+
if (child.isMutationObserved) {
|
|
18687
|
+
child.dispatchEvent(mountedEvent);
|
|
18688
|
+
} else {
|
|
18689
|
+
mountedEvent.target = child;
|
|
18690
|
+
|
|
18691
|
+
_this6.dispatchEvent(mountedEvent, true);
|
|
18692
|
+
} // trigger after mounted
|
|
18693
|
+
|
|
18694
|
+
|
|
18695
|
+
if (child.isCustomElement) {
|
|
18545
18696
|
if (child.connectedCallback) {
|
|
18546
18697
|
child.connectedCallback();
|
|
18547
18698
|
}
|
|
@@ -18596,12 +18747,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18596
18747
|
_createClass(Canvas, [{
|
|
18597
18748
|
key: "ready",
|
|
18598
18749
|
get: function get() {
|
|
18599
|
-
var
|
|
18750
|
+
var _this7 = this;
|
|
18600
18751
|
|
|
18601
18752
|
if (!this.readyPromise) {
|
|
18602
18753
|
this.readyPromise = new Promise(function (resolve) {
|
|
18603
|
-
|
|
18604
|
-
resolve(
|
|
18754
|
+
_this7.resolveReadyPromise = function () {
|
|
18755
|
+
resolve(_this7);
|
|
18605
18756
|
};
|
|
18606
18757
|
});
|
|
18607
18758
|
|