@antv/g-webgpu 1.7.25 → 1.7.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +98 -40
- package/dist/index.umd.min.js +4 -4
- package/package.json +10 -7
package/dist/index.umd.js
CHANGED
|
@@ -13084,7 +13084,7 @@
|
|
|
13084
13084
|
// }
|
|
13085
13085
|
|
|
13086
13086
|
if (instance.parsedStyle.metrics.font !== object.parsedStyle.metrics.font || instancedAttributes.some(function (name) {
|
|
13087
|
-
return instance.parsedStyle[name]
|
|
13087
|
+
return instance.parsedStyle[name] !== object.parsedStyle[name];
|
|
13088
13088
|
})) {
|
|
13089
13089
|
return false;
|
|
13090
13090
|
}
|
|
@@ -15539,6 +15539,7 @@
|
|
|
15539
15539
|
}
|
|
15540
15540
|
|
|
15541
15541
|
var HTML_PREFIX = 'g-html-';
|
|
15542
|
+
var CANVAS_CAMERA_ID = 'g_canvas_camera';
|
|
15542
15543
|
|
|
15543
15544
|
var HTMLRenderingPlugin = /*#__PURE__*/function () {
|
|
15544
15545
|
function HTMLRenderingPlugin() {
|
|
@@ -15548,23 +15549,31 @@
|
|
|
15548
15549
|
|
|
15549
15550
|
var _proto = HTMLRenderingPlugin.prototype;
|
|
15550
15551
|
|
|
15552
|
+
_proto.joinTransformMatrix = function joinTransformMatrix(matrix) {
|
|
15553
|
+
return "matrix(" + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(',') + ")";
|
|
15554
|
+
};
|
|
15555
|
+
|
|
15551
15556
|
_proto.apply = function apply(context) {
|
|
15552
15557
|
var _this = this;
|
|
15553
15558
|
|
|
15554
|
-
var
|
|
15559
|
+
var camera = context.camera,
|
|
15560
|
+
renderingContext = context.renderingContext,
|
|
15555
15561
|
renderingService = context.renderingService;
|
|
15556
15562
|
this.context = context;
|
|
15563
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15557
15564
|
|
|
15558
15565
|
var setTransform = function setTransform(object, $el) {
|
|
15559
|
-
|
|
15560
|
-
$el.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
15566
|
+
$el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
|
|
15561
15567
|
};
|
|
15562
15568
|
|
|
15563
15569
|
var handleMounted = function handleMounted(e) {
|
|
15564
15570
|
var object = e.target;
|
|
15565
15571
|
|
|
15566
15572
|
if (object.nodeName === gLite.Shape.HTML) {
|
|
15567
|
-
|
|
15573
|
+
// create DOM element
|
|
15574
|
+
var $el = _this.getOrCreateEl(object);
|
|
15575
|
+
|
|
15576
|
+
_this.$camera.appendChild($el); // apply documentElement's style
|
|
15568
15577
|
|
|
15569
15578
|
|
|
15570
15579
|
var attributes = object.ownerDocument.documentElement.attributes;
|
|
@@ -15581,18 +15590,17 @@
|
|
|
15581
15590
|
var handleUnmounted = function handleUnmounted(e) {
|
|
15582
15591
|
var object = e.target;
|
|
15583
15592
|
|
|
15584
|
-
if (object.nodeName === gLite.Shape.HTML) {
|
|
15585
|
-
var
|
|
15586
|
-
|
|
15587
|
-
var $container = _this.context.contextService.getDomElement().parentNode;
|
|
15593
|
+
if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
|
|
15594
|
+
var $el = _this.getOrCreateEl(object);
|
|
15588
15595
|
|
|
15589
|
-
if ($
|
|
15590
|
-
|
|
15596
|
+
if ($el) {
|
|
15597
|
+
$el.remove();
|
|
15598
|
+
} // const existedId = this.getId(object);
|
|
15599
|
+
// const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
|
|
15600
|
+
// if ($existedElement) {
|
|
15601
|
+
// this.$camera.removeChild($existedElement);
|
|
15602
|
+
// }
|
|
15591
15603
|
|
|
15592
|
-
if ($existedElement) {
|
|
15593
|
-
$container.removeChild($existedElement);
|
|
15594
|
-
}
|
|
15595
|
-
}
|
|
15596
15604
|
}
|
|
15597
15605
|
};
|
|
15598
15606
|
|
|
@@ -15616,24 +15624,46 @@
|
|
|
15616
15624
|
}
|
|
15617
15625
|
};
|
|
15618
15626
|
|
|
15627
|
+
var handleCanvasResize = function handleCanvasResize() {
|
|
15628
|
+
var _this$context$config = _this.context.config,
|
|
15629
|
+
width = _this$context$config.width,
|
|
15630
|
+
height = _this$context$config.height;
|
|
15631
|
+
_this.$camera.style.width = (width || 0) + "px";
|
|
15632
|
+
_this.$camera.style.height = (height || 0) + "px";
|
|
15633
|
+
};
|
|
15634
|
+
|
|
15619
15635
|
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
15620
15636
|
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
15621
15637
|
while (1) {
|
|
15622
15638
|
switch (_context.prev = _context.next) {
|
|
15623
15639
|
case 0:
|
|
15640
|
+
// append camera
|
|
15641
|
+
_this.$camera = _this.createCamera(camera);
|
|
15642
|
+
canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
15624
15643
|
renderingContext.root.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
15625
15644
|
renderingContext.root.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
15626
15645
|
renderingContext.root.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
15627
15646
|
renderingContext.root.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
15628
15647
|
|
|
15629
|
-
case
|
|
15648
|
+
case 6:
|
|
15630
15649
|
case "end":
|
|
15631
15650
|
return _context.stop();
|
|
15632
15651
|
}
|
|
15633
15652
|
}
|
|
15634
15653
|
}, _callee);
|
|
15635
15654
|
})));
|
|
15655
|
+
renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
|
|
15656
|
+
if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
15657
|
+
_this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
|
|
15658
|
+
}
|
|
15659
|
+
});
|
|
15636
15660
|
renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
|
|
15661
|
+
// remove camera
|
|
15662
|
+
if (_this.$camera) {
|
|
15663
|
+
_this.$camera.remove();
|
|
15664
|
+
}
|
|
15665
|
+
|
|
15666
|
+
canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
15637
15667
|
renderingContext.root.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
15638
15668
|
renderingContext.root.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
15639
15669
|
renderingContext.root.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
@@ -15645,43 +15675,71 @@
|
|
|
15645
15675
|
return object.id || HTML_PREFIX + object.entity;
|
|
15646
15676
|
};
|
|
15647
15677
|
|
|
15648
|
-
_proto.
|
|
15649
|
-
var
|
|
15650
|
-
|
|
15678
|
+
_proto.createCamera = function createCamera(camera) {
|
|
15679
|
+
var _this$context$config2 = this.context.config,
|
|
15680
|
+
doc = _this$context$config2.document,
|
|
15681
|
+
width = _this$context$config2.width,
|
|
15682
|
+
height = _this$context$config2.height;
|
|
15651
15683
|
var $canvas = this.context.contextService.getDomElement();
|
|
15652
15684
|
var $container = $canvas.parentNode;
|
|
15653
15685
|
|
|
15654
15686
|
if ($container) {
|
|
15655
|
-
var
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
$
|
|
15687
|
+
var cameraId = CANVAS_CAMERA_ID;
|
|
15688
|
+
var $existedCamera = $container.querySelector('#' + cameraId);
|
|
15689
|
+
|
|
15690
|
+
if (!$existedCamera) {
|
|
15691
|
+
var $camera = (doc || document).createElement('div');
|
|
15692
|
+
$existedCamera = $camera;
|
|
15693
|
+
$camera.id = cameraId; // use absolute position
|
|
15694
|
+
|
|
15695
|
+
$camera.style.position = 'absolute'; // account for DOM element's offset @see https://github.com/antvis/G/issues/1150
|
|
15696
|
+
|
|
15697
|
+
$camera.style.left = ($canvas.offsetLeft || 0) + "px";
|
|
15698
|
+
$camera.style.top = ($canvas.offsetTop || 0) + "px";
|
|
15699
|
+
$camera.style.transformOrigin = 'left top';
|
|
15700
|
+
$camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix()); // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
|
|
15701
|
+
|
|
15702
|
+
$camera.style.overflow = 'hidden';
|
|
15703
|
+
$camera.style.pointerEvents = 'none';
|
|
15704
|
+
$camera.style.width = (width || 0) + "px";
|
|
15705
|
+
$camera.style.height = (height || 0) + "px";
|
|
15706
|
+
$container.appendChild($camera);
|
|
15707
|
+
}
|
|
15661
15708
|
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
}
|
|
15709
|
+
return $existedCamera;
|
|
15710
|
+
}
|
|
15665
15711
|
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
}
|
|
15712
|
+
return null;
|
|
15713
|
+
};
|
|
15669
15714
|
|
|
15670
|
-
|
|
15715
|
+
_proto.getOrCreateEl = function getOrCreateEl(object) {
|
|
15716
|
+
var doc = this.context.config.document;
|
|
15717
|
+
var existedId = this.getId(object);
|
|
15718
|
+
var $existedElement = this.$camera.querySelector('#' + existedId);
|
|
15671
15719
|
|
|
15672
|
-
|
|
15720
|
+
if (!$existedElement) {
|
|
15721
|
+
$existedElement = (doc || document).createElement('div');
|
|
15722
|
+
object.parsedStyle.$el = $existedElement;
|
|
15723
|
+
$existedElement.id = existedId;
|
|
15673
15724
|
|
|
15674
|
-
|
|
15675
|
-
$existedElement.
|
|
15676
|
-
$existedElement.style['will-change'] = 'transform';
|
|
15677
|
-
var worldTransform = object.getWorldTransform();
|
|
15678
|
-
$existedElement.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
15725
|
+
if (object.name) {
|
|
15726
|
+
$existedElement.setAttribute('name', object.name);
|
|
15679
15727
|
}
|
|
15680
15728
|
|
|
15681
|
-
|
|
15729
|
+
if (object.className) {
|
|
15730
|
+
$existedElement.className = object.className;
|
|
15731
|
+
} // use absolute position
|
|
15732
|
+
|
|
15733
|
+
|
|
15734
|
+
$existedElement.style.position = 'absolute'; // @see https://github.com/antvis/G/issues/1150
|
|
15735
|
+
|
|
15736
|
+
$existedElement.style.left = "0px";
|
|
15737
|
+
$existedElement.style.top = "0px";
|
|
15738
|
+
$existedElement.style['will-change'] = 'transform';
|
|
15739
|
+
$existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
|
|
15682
15740
|
}
|
|
15683
15741
|
|
|
15684
|
-
return
|
|
15742
|
+
return $existedElement;
|
|
15685
15743
|
};
|
|
15686
15744
|
|
|
15687
15745
|
_proto.updateAttribute = function updateAttribute(name, object) {
|