@antv/g-lite 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts +69 -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/dom/Element.d.ts.map +1 -1
- package/dist/dom/interfaces.d.ts +2 -8
- package/dist/dom/interfaces.d.ts.map +1 -1
- package/dist/index.esm.js +231 -127
- package/dist/index.js +231 -127
- package/dist/index.umd.js +231 -127
- package/dist/index.umd.min.js +2 -2
- package/dist/shapes/AABB.d.ts +1 -1
- package/dist/shapes/AABB.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) {
|
|
@@ -8062,6 +8064,7 @@ var SyncWaterfallHook = /*#__PURE__*/function (_SyncHook) {
|
|
|
8062
8064
|
// SyncWaterfallHook.prototype = null;
|
|
8063
8065
|
|
|
8064
8066
|
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
|
|
8067
|
+
var stringRegExp = /([\"\'])[^\'\"]+\1/;
|
|
8065
8068
|
function toFontString(attributes) {
|
|
8066
8069
|
var fontSize = attributes.fontSize,
|
|
8067
8070
|
fontFamily = attributes.fontFamily,
|
|
@@ -8081,7 +8084,7 @@ function toFontString(attributes) {
|
|
|
8081
8084
|
var _fontFamily = fontFamilies[i].trim(); // Check if font already contains strings
|
|
8082
8085
|
|
|
8083
8086
|
|
|
8084
|
-
if (
|
|
8087
|
+
if (!stringRegExp.test(_fontFamily) && genericFontFamilies.indexOf(_fontFamily) < 0) {
|
|
8085
8088
|
_fontFamily = "\"" + _fontFamily + "\"";
|
|
8086
8089
|
}
|
|
8087
8090
|
|
|
@@ -8586,7 +8589,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
8586
8589
|
d: '0'
|
|
8587
8590
|
}];
|
|
8588
8591
|
var propertyMetadataCache = {};
|
|
8589
|
-
var unresolvedProperties =
|
|
8592
|
+
var unresolvedProperties = new WeakMap();
|
|
8590
8593
|
var priorityMap = {};
|
|
8591
8594
|
var sortAttributeNames = memoize(function (attributeNames) {
|
|
8592
8595
|
return attributeNames.sort(function (a, b) {
|
|
@@ -8598,11 +8601,13 @@ var tmpVec3b = vec3.create();
|
|
|
8598
8601
|
var tmpVec3c = vec3.create();
|
|
8599
8602
|
|
|
8600
8603
|
var isPropertyResolved = function isPropertyResolved(object, name) {
|
|
8601
|
-
|
|
8604
|
+
var properties = unresolvedProperties.get(object);
|
|
8605
|
+
|
|
8606
|
+
if (!properties || properties.length === 0) {
|
|
8602
8607
|
return true;
|
|
8603
8608
|
}
|
|
8604
8609
|
|
|
8605
|
-
return
|
|
8610
|
+
return properties.includes(name);
|
|
8606
8611
|
};
|
|
8607
8612
|
|
|
8608
8613
|
var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
@@ -8848,12 +8853,15 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8848
8853
|
;
|
|
8849
8854
|
|
|
8850
8855
|
_proto.addUnresolveProperty = function addUnresolveProperty(object, name) {
|
|
8851
|
-
|
|
8852
|
-
|
|
8856
|
+
var properties = unresolvedProperties.get(object);
|
|
8857
|
+
|
|
8858
|
+
if (!properties) {
|
|
8859
|
+
unresolvedProperties.set(object, []);
|
|
8860
|
+
properties = unresolvedProperties.get(object);
|
|
8853
8861
|
}
|
|
8854
8862
|
|
|
8855
|
-
if (
|
|
8856
|
-
|
|
8863
|
+
if (properties.indexOf(name) === -1) {
|
|
8864
|
+
properties.push(name);
|
|
8857
8865
|
}
|
|
8858
8866
|
};
|
|
8859
8867
|
|
|
@@ -8889,7 +8897,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8889
8897
|
};
|
|
8890
8898
|
|
|
8891
8899
|
_proto.recalc = function recalc(object) {
|
|
8892
|
-
var properties = unresolvedProperties
|
|
8900
|
+
var properties = unresolvedProperties.get(object);
|
|
8893
8901
|
|
|
8894
8902
|
if (properties && properties.length) {
|
|
8895
8903
|
var attributes = {};
|
|
@@ -8897,7 +8905,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
8897
8905
|
attributes[property] = object.attributes[property];
|
|
8898
8906
|
});
|
|
8899
8907
|
this.processProperties(object, attributes);
|
|
8900
|
-
delete
|
|
8908
|
+
unresolvedProperties.delete(object);
|
|
8901
8909
|
}
|
|
8902
8910
|
}
|
|
8903
8911
|
/**
|
|
@@ -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
|
|
10555
10520
|
|
|
10521
|
+
|
|
10522
|
+
runtime.sceneGraphService.detach(child);
|
|
10556
10523
|
return child;
|
|
10557
10524
|
}
|
|
10558
10525
|
/**
|
|
@@ -10845,14 +10812,15 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10845
10812
|
var value = this.attributes[name];
|
|
10846
10813
|
|
|
10847
10814
|
if (value === undefined) {
|
|
10848
|
-
var _formatAttribute = formatAttribute(name
|
|
10815
|
+
var _formatAttribute = formatAttribute(name, ''),
|
|
10849
10816
|
attributeName = _formatAttribute[0];
|
|
10850
10817
|
|
|
10851
|
-
value = this.attributes[attributeName];
|
|
10852
|
-
} // if the given attribute does not exist, the value returned will either be null or ""
|
|
10853
|
-
|
|
10818
|
+
value = this.attributes[attributeName]; // if the given attribute does not exist, the value returned will either be null or ""
|
|
10854
10819
|
|
|
10855
|
-
|
|
10820
|
+
return isNil(value) ? null : value;
|
|
10821
|
+
} else {
|
|
10822
|
+
return value;
|
|
10823
|
+
}
|
|
10856
10824
|
}
|
|
10857
10825
|
/**
|
|
10858
10826
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
|
|
@@ -11295,6 +11263,11 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11295
11263
|
_this.config = void 0;
|
|
11296
11264
|
_this.isCustomElement = 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
|
|
@@ -11667,10 +11640,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11667
11640
|
;
|
|
11668
11641
|
|
|
11669
11642
|
_proto.getEulerAngles = function getEulerAngles() {
|
|
11670
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11671
11643
|
var _getEuler = getEuler(vec3.create(), runtime.sceneGraphService.getWorldTransform(this)),
|
|
11672
|
-
ex = _getEuler[0],
|
|
11673
|
-
ey = _getEuler[1],
|
|
11674
11644
|
ez = _getEuler[2];
|
|
11675
11645
|
|
|
11676
11646
|
return rad2deg(ez);
|
|
@@ -11681,10 +11651,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11681
11651
|
;
|
|
11682
11652
|
|
|
11683
11653
|
_proto.getLocalEulerAngles = function getLocalEulerAngles() {
|
|
11684
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11685
11654
|
var _getEuler2 = getEuler(vec3.create(), runtime.sceneGraphService.getLocalRotation(this)),
|
|
11686
|
-
ex = _getEuler2[0],
|
|
11687
|
-
ey = _getEuler2[1],
|
|
11688
11655
|
ez = _getEuler2[2];
|
|
11689
11656
|
|
|
11690
11657
|
return rad2deg(ez);
|
|
@@ -11911,11 +11878,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11911
11878
|
sx = _mat4$getScaling[0],
|
|
11912
11879
|
sy = _mat4$getScaling[1];
|
|
11913
11880
|
|
|
11914
|
-
var rotation = mat4.getRotation(quat$1.create(), transform);
|
|
11881
|
+
var rotation = mat4.getRotation(quat$1.create(), transform);
|
|
11915
11882
|
|
|
11916
11883
|
var _getEuler3 = getEuler(vec3.create(), rotation),
|
|
11917
11884
|
eux = _getEuler3[0],
|
|
11918
|
-
euy = _getEuler3[1],
|
|
11919
11885
|
euz = _getEuler3[2]; // gimbal lock at 90 degrees
|
|
11920
11886
|
|
|
11921
11887
|
|
|
@@ -11979,6 +11945,145 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
11979
11945
|
|
|
11980
11946
|
_proto.hide = function hide() {
|
|
11981
11947
|
this.style.visibility = 'hidden';
|
|
11948
|
+
}
|
|
11949
|
+
/**
|
|
11950
|
+
* Use `childElementCount` instead.
|
|
11951
|
+
* @deprecated
|
|
11952
|
+
*/
|
|
11953
|
+
;
|
|
11954
|
+
|
|
11955
|
+
_proto.getCount = function getCount() {
|
|
11956
|
+
return this.childElementCount;
|
|
11957
|
+
}
|
|
11958
|
+
/**
|
|
11959
|
+
* Use `parentElement` instead.
|
|
11960
|
+
* @deprecated
|
|
11961
|
+
*/
|
|
11962
|
+
;
|
|
11963
|
+
|
|
11964
|
+
_proto.getParent = function getParent() {
|
|
11965
|
+
return this.parentElement;
|
|
11966
|
+
}
|
|
11967
|
+
/**
|
|
11968
|
+
* Use `children` instead.
|
|
11969
|
+
* @deprecated
|
|
11970
|
+
*/
|
|
11971
|
+
;
|
|
11972
|
+
|
|
11973
|
+
_proto.getChildren = function getChildren() {
|
|
11974
|
+
return this.children;
|
|
11975
|
+
}
|
|
11976
|
+
/**
|
|
11977
|
+
* Use `firstElementChild` instead.
|
|
11978
|
+
* @deprecated
|
|
11979
|
+
*/
|
|
11980
|
+
;
|
|
11981
|
+
|
|
11982
|
+
_proto.getFirst = function getFirst() {
|
|
11983
|
+
return this.firstElementChild;
|
|
11984
|
+
}
|
|
11985
|
+
/**
|
|
11986
|
+
* Use `lastElementChild` instead.
|
|
11987
|
+
* @deprecated
|
|
11988
|
+
*/
|
|
11989
|
+
;
|
|
11990
|
+
|
|
11991
|
+
_proto.getLast = function getLast() {
|
|
11992
|
+
return this.lastElementChild;
|
|
11993
|
+
}
|
|
11994
|
+
/**
|
|
11995
|
+
* Use `this.children[index]` instead.
|
|
11996
|
+
* @deprecated
|
|
11997
|
+
*/
|
|
11998
|
+
;
|
|
11999
|
+
|
|
12000
|
+
_proto.getChildByIndex = function getChildByIndex(index) {
|
|
12001
|
+
return this.children[index] || null;
|
|
12002
|
+
}
|
|
12003
|
+
/**
|
|
12004
|
+
* Use `appendChild` instead.
|
|
12005
|
+
* @deprecated
|
|
12006
|
+
*/
|
|
12007
|
+
;
|
|
12008
|
+
|
|
12009
|
+
_proto.add = function add(child, index) {
|
|
12010
|
+
return this.appendChild(child, index);
|
|
12011
|
+
}
|
|
12012
|
+
/**
|
|
12013
|
+
* Use `this.style.clipPath` instead.
|
|
12014
|
+
* @deprecated
|
|
12015
|
+
*/
|
|
12016
|
+
;
|
|
12017
|
+
|
|
12018
|
+
_proto.setClip = function setClip(clipPath) {
|
|
12019
|
+
this.style.clipPath = clipPath;
|
|
12020
|
+
}
|
|
12021
|
+
/**
|
|
12022
|
+
* Use `this.style.clipPath` instead.
|
|
12023
|
+
* @deprecated
|
|
12024
|
+
*/
|
|
12025
|
+
;
|
|
12026
|
+
|
|
12027
|
+
/**
|
|
12028
|
+
* @deprecated
|
|
12029
|
+
*/
|
|
12030
|
+
_proto.set = function set(name, value) {
|
|
12031
|
+
// @ts-ignore
|
|
12032
|
+
this.config[name] = value;
|
|
12033
|
+
}
|
|
12034
|
+
/**
|
|
12035
|
+
* @deprecated
|
|
12036
|
+
*/
|
|
12037
|
+
;
|
|
12038
|
+
|
|
12039
|
+
_proto.get = function get(name) {
|
|
12040
|
+
return this.config[name];
|
|
12041
|
+
}
|
|
12042
|
+
/**
|
|
12043
|
+
* Use `setPosition` instead.
|
|
12044
|
+
* @deprecated
|
|
12045
|
+
*/
|
|
12046
|
+
;
|
|
12047
|
+
|
|
12048
|
+
_proto.moveTo = function moveTo(position, y, z) {
|
|
12049
|
+
if (y === void 0) {
|
|
12050
|
+
y = 0;
|
|
12051
|
+
}
|
|
12052
|
+
|
|
12053
|
+
if (z === void 0) {
|
|
12054
|
+
z = 0;
|
|
12055
|
+
}
|
|
12056
|
+
|
|
12057
|
+
this.setPosition(position, y, z);
|
|
12058
|
+
return this;
|
|
12059
|
+
}
|
|
12060
|
+
/**
|
|
12061
|
+
* Use `setPosition` instead.
|
|
12062
|
+
* @deprecated
|
|
12063
|
+
*/
|
|
12064
|
+
;
|
|
12065
|
+
|
|
12066
|
+
_proto.move = function move(position, y, z) {
|
|
12067
|
+
if (y === void 0) {
|
|
12068
|
+
y = 0;
|
|
12069
|
+
}
|
|
12070
|
+
|
|
12071
|
+
if (z === void 0) {
|
|
12072
|
+
z = 0;
|
|
12073
|
+
}
|
|
12074
|
+
|
|
12075
|
+
this.setPosition(position, y, z);
|
|
12076
|
+
return this;
|
|
12077
|
+
}
|
|
12078
|
+
/**
|
|
12079
|
+
* Use `this.style.zIndex` instead.
|
|
12080
|
+
* @deprecated
|
|
12081
|
+
*/
|
|
12082
|
+
;
|
|
12083
|
+
|
|
12084
|
+
_proto.setZIndex = function setZIndex(zIndex) {
|
|
12085
|
+
this.style.zIndex = zIndex;
|
|
12086
|
+
return this;
|
|
11982
12087
|
};
|
|
11983
12088
|
|
|
11984
12089
|
_createClass(DisplayObject, [{
|
|
@@ -13443,18 +13548,25 @@ var Camera = /*#__PURE__*/function () {
|
|
|
13443
13548
|
ox = _this$canvas$viewport.x,
|
|
13444
13549
|
oy = _this$canvas$viewport.y;
|
|
13445
13550
|
|
|
13551
|
+
var roll = this.roll;
|
|
13552
|
+
this.rotate(0, 0, -roll);
|
|
13446
13553
|
this.setPosition(ox, oy);
|
|
13447
13554
|
this.setFocalPoint(ox, oy);
|
|
13448
13555
|
this.setZoom(zoom);
|
|
13556
|
+
this.rotate(0, 0, roll);
|
|
13449
13557
|
|
|
13450
13558
|
var _this$canvas$viewport2 = this.canvas.viewport2Canvas({
|
|
13451
13559
|
x: viewportPoint[0],
|
|
13452
13560
|
y: viewportPoint[1]
|
|
13453
13561
|
}),
|
|
13454
13562
|
cx = _this$canvas$viewport2.x,
|
|
13455
|
-
cy = _this$canvas$viewport2.y;
|
|
13563
|
+
cy = _this$canvas$viewport2.y; // project to rotated axis
|
|
13564
|
+
|
|
13456
13565
|
|
|
13457
|
-
|
|
13566
|
+
var dvec = vec3.fromValues(cx - ox, cy - oy, 0);
|
|
13567
|
+
var dx = vec3.dot(dvec, this.right) / vec3.length(this.right);
|
|
13568
|
+
var dy = vec3.dot(dvec, this.up) / vec3.length(this.up);
|
|
13569
|
+
this.pan(-dx, -dy);
|
|
13458
13570
|
return this;
|
|
13459
13571
|
};
|
|
13460
13572
|
|
|
@@ -17986,6 +18098,14 @@ var CanvasEvent;
|
|
|
17986
18098
|
var DEFAULT_CAMERA_Z = 500;
|
|
17987
18099
|
var DEFAULT_CAMERA_NEAR = 0.1;
|
|
17988
18100
|
var DEFAULT_CAMERA_FAR = 1000;
|
|
18101
|
+
/**
|
|
18102
|
+
* reuse custom event preventing from re-create them in every frame
|
|
18103
|
+
*/
|
|
18104
|
+
|
|
18105
|
+
var mountEvent = new CustomEvent(ElementEvent.MOUNTED);
|
|
18106
|
+
var unmountEvent = new CustomEvent(ElementEvent.UNMOUNTED);
|
|
18107
|
+
var beforeRenderEvent = new CustomEvent(CanvasEvent.BEFORE_RENDER);
|
|
18108
|
+
var afterRenderEvent = new CustomEvent(CanvasEvent.AFTER_RENDER);
|
|
17989
18109
|
/**
|
|
17990
18110
|
* can be treated like Window in DOM
|
|
17991
18111
|
* provide some extra methods like `window`, such as:
|
|
@@ -18043,10 +18163,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18043
18163
|
/**
|
|
18044
18164
|
* rAF in auto rendering
|
|
18045
18165
|
*/
|
|
18046
|
-
|
|
18047
|
-
/**
|
|
18048
|
-
* reuse custom event preventing from re-create them in every frame
|
|
18049
|
-
*/
|
|
18050
18166
|
function Canvas(config) {
|
|
18051
18167
|
var _this;
|
|
18052
18168
|
|
|
@@ -18066,10 +18182,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18066
18182
|
_this.inited = false;
|
|
18067
18183
|
_this.readyPromise = void 0;
|
|
18068
18184
|
_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
18185
|
_this.context = {};
|
|
18074
18186
|
_this.document = new Document();
|
|
18075
18187
|
_this.document.defaultView = _assertThisInitialized(_this); // create registry of custom elements
|
|
@@ -18174,8 +18286,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18174
18286
|
var _proto = Canvas.prototype;
|
|
18175
18287
|
|
|
18176
18288
|
_proto.initRenderingContext = function initRenderingContext(mergedConfig) {
|
|
18177
|
-
var _this2 = this;
|
|
18178
|
-
|
|
18179
18289
|
this.context.config = mergedConfig; // bind rendering context, shared by all renderers
|
|
18180
18290
|
|
|
18181
18291
|
this.context.renderingContext = {
|
|
@@ -18189,16 +18299,10 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18189
18299
|
force: false,
|
|
18190
18300
|
dirty: false
|
|
18191
18301
|
};
|
|
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
18302
|
};
|
|
18199
18303
|
|
|
18200
18304
|
_proto.initDefaultCamera = function initDefaultCamera(width, height) {
|
|
18201
|
-
var
|
|
18305
|
+
var _this2 = this;
|
|
18202
18306
|
|
|
18203
18307
|
// set a default ortho camera
|
|
18204
18308
|
var camera = new runtime.CameraContribution();
|
|
@@ -18207,7 +18311,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18207
18311
|
camera.canvas = this; // redraw when camera changed
|
|
18208
18312
|
|
|
18209
18313
|
camera.eventEmitter.on(CameraEvent.UPDATED, function () {
|
|
18210
|
-
|
|
18314
|
+
_this2.context.renderingContext.renderReasons.add(RenderReason.CAMERA_CHANGED);
|
|
18211
18315
|
}); // bind camera
|
|
18212
18316
|
|
|
18213
18317
|
this.context.camera = camera;
|
|
@@ -18351,19 +18455,19 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18351
18455
|
};
|
|
18352
18456
|
|
|
18353
18457
|
_proto.render = function render() {
|
|
18354
|
-
this.dispatchEvent(
|
|
18458
|
+
this.dispatchEvent(beforeRenderEvent);
|
|
18355
18459
|
var renderingService = this.getRenderingService();
|
|
18356
18460
|
renderingService.render(this.getConfig());
|
|
18357
|
-
this.dispatchEvent(
|
|
18461
|
+
this.dispatchEvent(afterRenderEvent);
|
|
18358
18462
|
};
|
|
18359
18463
|
|
|
18360
18464
|
_proto.run = function run() {
|
|
18361
|
-
var
|
|
18465
|
+
var _this3 = this;
|
|
18362
18466
|
|
|
18363
18467
|
var tick = function tick() {
|
|
18364
|
-
|
|
18468
|
+
_this3.render();
|
|
18365
18469
|
|
|
18366
|
-
|
|
18470
|
+
_this3.frameId = requestAnimationFrame(tick);
|
|
18367
18471
|
};
|
|
18368
18472
|
|
|
18369
18473
|
tick();
|
|
@@ -18441,12 +18545,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18441
18545
|
}();
|
|
18442
18546
|
|
|
18443
18547
|
_proto.loadRendererContainerModule = function loadRendererContainerModule(renderer) {
|
|
18444
|
-
var
|
|
18548
|
+
var _this4 = this;
|
|
18445
18549
|
|
|
18446
18550
|
// load other container modules provided by g-canvas/g-svg/g-webgl
|
|
18447
18551
|
var plugins = renderer.getPlugins();
|
|
18448
18552
|
plugins.forEach(function (plugin) {
|
|
18449
|
-
plugin.context =
|
|
18553
|
+
plugin.context = _this4.context;
|
|
18450
18554
|
plugin.init();
|
|
18451
18555
|
});
|
|
18452
18556
|
};
|
|
@@ -18502,7 +18606,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18502
18606
|
};
|
|
18503
18607
|
|
|
18504
18608
|
_proto.unmountChildren = function unmountChildren(parent) {
|
|
18505
|
-
var
|
|
18609
|
+
var _this5 = this;
|
|
18506
18610
|
|
|
18507
18611
|
if (this.inited) {
|
|
18508
18612
|
var path = [];
|
|
@@ -18520,9 +18624,9 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18520
18624
|
}
|
|
18521
18625
|
}
|
|
18522
18626
|
|
|
18523
|
-
child.dispatchEvent(
|
|
18627
|
+
child.dispatchEvent(unmountEvent); // skip document.documentElement
|
|
18524
18628
|
|
|
18525
|
-
if (child !==
|
|
18629
|
+
if (child !== _this5.document.documentElement) {
|
|
18526
18630
|
child.ownerDocument = null;
|
|
18527
18631
|
}
|
|
18528
18632
|
|
|
@@ -18532,14 +18636,14 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18532
18636
|
};
|
|
18533
18637
|
|
|
18534
18638
|
_proto.mountChildren = function mountChildren(parent) {
|
|
18535
|
-
var
|
|
18639
|
+
var _this6 = this;
|
|
18536
18640
|
|
|
18537
18641
|
if (this.inited) {
|
|
18538
18642
|
parent.forEach(function (child) {
|
|
18539
18643
|
if (!child.isConnected) {
|
|
18540
|
-
child.ownerDocument =
|
|
18644
|
+
child.ownerDocument = _this6.document;
|
|
18541
18645
|
child.isConnected = true;
|
|
18542
|
-
child.dispatchEvent(
|
|
18646
|
+
child.dispatchEvent(mountEvent); // trigger after mounted
|
|
18543
18647
|
|
|
18544
18648
|
if (child instanceof CustomElement) {
|
|
18545
18649
|
if (child.connectedCallback) {
|
|
@@ -18596,12 +18700,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18596
18700
|
_createClass(Canvas, [{
|
|
18597
18701
|
key: "ready",
|
|
18598
18702
|
get: function get() {
|
|
18599
|
-
var
|
|
18703
|
+
var _this7 = this;
|
|
18600
18704
|
|
|
18601
18705
|
if (!this.readyPromise) {
|
|
18602
18706
|
this.readyPromise = new Promise(function (resolve) {
|
|
18603
|
-
|
|
18604
|
-
resolve(
|
|
18707
|
+
_this7.resolveReadyPromise = function () {
|
|
18708
|
+
resolve(_this7);
|
|
18605
18709
|
};
|
|
18606
18710
|
});
|
|
18607
18711
|
|