@antv/g-webgpu 1.7.25 → 1.7.27
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 +126 -65
- package/dist/index.umd.min.js +5 -5
- package/package.json +10 -7
package/dist/index.umd.js
CHANGED
|
@@ -8353,6 +8353,7 @@
|
|
|
8353
8353
|
this.context = context;
|
|
8354
8354
|
var renderingService = context.renderingService,
|
|
8355
8355
|
renderingContext = context.renderingContext;
|
|
8356
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
8356
8357
|
|
|
8357
8358
|
var handleMounted = function handleMounted(e) {
|
|
8358
8359
|
var object = e.target; // collect lights
|
|
@@ -8432,11 +8433,11 @@
|
|
|
8432
8433
|
while (1) {
|
|
8433
8434
|
switch (_context.prev = _context.next) {
|
|
8434
8435
|
case 0:
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8436
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
8437
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
8438
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
8439
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
8440
|
+
canvas.addEventListener(gLite.ElementEvent.RENDER_ORDER_CHANGED, handleRenderOrderChanged);
|
|
8440
8441
|
_this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
|
|
8441
8442
|
$canvas = _this.context.contextService.getDomElement();
|
|
8442
8443
|
_this$context$config = _this.context.config, width = _this$context$config.width, height = _this$context$config.height;
|
|
@@ -8458,7 +8459,7 @@
|
|
|
8458
8459
|
|
|
8459
8460
|
_this.swapChain.configureSwapChain($canvas.width, $canvas.height);
|
|
8460
8461
|
|
|
8461
|
-
|
|
8462
|
+
canvas.addEventListener(gLite.CanvasEvent.RESIZE, function () {
|
|
8462
8463
|
_this.swapChain.configureSwapChain($canvas.width, $canvas.height);
|
|
8463
8464
|
});
|
|
8464
8465
|
|
|
@@ -8476,11 +8477,11 @@
|
|
|
8476
8477
|
renderingService.hooks.destroy.tap(RenderGraphPlugin.tag, function () {
|
|
8477
8478
|
_this.renderHelper.destroy();
|
|
8478
8479
|
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8480
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
8481
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
8482
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
8483
|
+
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
8484
|
+
canvas.removeEventListener(gLite.ElementEvent.RENDER_ORDER_CHANGED, handleRenderOrderChanged);
|
|
8484
8485
|
});
|
|
8485
8486
|
/**
|
|
8486
8487
|
* build frame graph at the beginning of each frame
|
|
@@ -8692,6 +8693,7 @@
|
|
|
8692
8693
|
this.context = context;
|
|
8693
8694
|
var renderingService = context.renderingService,
|
|
8694
8695
|
renderingContext = context.renderingContext;
|
|
8696
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
8695
8697
|
|
|
8696
8698
|
var handleMounted = function handleMounted(e) {
|
|
8697
8699
|
var object = e.target; // @ts-ignore
|
|
@@ -8712,7 +8714,7 @@
|
|
|
8712
8714
|
while (1) {
|
|
8713
8715
|
switch (_context.prev = _context.next) {
|
|
8714
8716
|
case 0:
|
|
8715
|
-
|
|
8717
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
8716
8718
|
|
|
8717
8719
|
case 1:
|
|
8718
8720
|
case "end":
|
|
@@ -8722,7 +8724,7 @@
|
|
|
8722
8724
|
}, _callee);
|
|
8723
8725
|
})));
|
|
8724
8726
|
renderingService.hooks.destroy.tap(PickingPlugin.tag, function () {
|
|
8725
|
-
|
|
8727
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
8726
8728
|
});
|
|
8727
8729
|
/**
|
|
8728
8730
|
* Sync version is not implemented.
|
|
@@ -13084,7 +13086,7 @@
|
|
|
13084
13086
|
// }
|
|
13085
13087
|
|
|
13086
13088
|
if (instance.parsedStyle.metrics.font !== object.parsedStyle.metrics.font || instancedAttributes.some(function (name) {
|
|
13087
|
-
return instance.parsedStyle[name]
|
|
13089
|
+
return instance.parsedStyle[name] !== object.parsedStyle[name];
|
|
13088
13090
|
})) {
|
|
13089
13091
|
return false;
|
|
13090
13092
|
}
|
|
@@ -15539,6 +15541,7 @@
|
|
|
15539
15541
|
}
|
|
15540
15542
|
|
|
15541
15543
|
var HTML_PREFIX = 'g-html-';
|
|
15544
|
+
var CANVAS_CAMERA_ID = 'g-canvas-camera';
|
|
15542
15545
|
|
|
15543
15546
|
var HTMLRenderingPlugin = /*#__PURE__*/function () {
|
|
15544
15547
|
function HTMLRenderingPlugin() {
|
|
@@ -15548,23 +15551,31 @@
|
|
|
15548
15551
|
|
|
15549
15552
|
var _proto = HTMLRenderingPlugin.prototype;
|
|
15550
15553
|
|
|
15554
|
+
_proto.joinTransformMatrix = function joinTransformMatrix(matrix) {
|
|
15555
|
+
return "matrix(" + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(',') + ")";
|
|
15556
|
+
};
|
|
15557
|
+
|
|
15551
15558
|
_proto.apply = function apply(context) {
|
|
15552
15559
|
var _this = this;
|
|
15553
15560
|
|
|
15554
|
-
var
|
|
15561
|
+
var camera = context.camera,
|
|
15562
|
+
renderingContext = context.renderingContext,
|
|
15555
15563
|
renderingService = context.renderingService;
|
|
15556
15564
|
this.context = context;
|
|
15565
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15557
15566
|
|
|
15558
15567
|
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(',') + ")";
|
|
15568
|
+
$el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
|
|
15561
15569
|
};
|
|
15562
15570
|
|
|
15563
15571
|
var handleMounted = function handleMounted(e) {
|
|
15564
15572
|
var object = e.target;
|
|
15565
15573
|
|
|
15566
15574
|
if (object.nodeName === gLite.Shape.HTML) {
|
|
15567
|
-
|
|
15575
|
+
// create DOM element
|
|
15576
|
+
var $el = _this.getOrCreateEl(object);
|
|
15577
|
+
|
|
15578
|
+
_this.$camera.appendChild($el); // apply documentElement's style
|
|
15568
15579
|
|
|
15569
15580
|
|
|
15570
15581
|
var attributes = object.ownerDocument.documentElement.attributes;
|
|
@@ -15581,18 +15592,17 @@
|
|
|
15581
15592
|
var handleUnmounted = function handleUnmounted(e) {
|
|
15582
15593
|
var object = e.target;
|
|
15583
15594
|
|
|
15584
|
-
if (object.nodeName === gLite.Shape.HTML) {
|
|
15585
|
-
var
|
|
15586
|
-
|
|
15587
|
-
var $container = _this.context.contextService.getDomElement().parentNode;
|
|
15595
|
+
if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
|
|
15596
|
+
var $el = _this.getOrCreateEl(object);
|
|
15588
15597
|
|
|
15589
|
-
if ($
|
|
15590
|
-
|
|
15598
|
+
if ($el) {
|
|
15599
|
+
$el.remove();
|
|
15600
|
+
} // const existedId = this.getId(object);
|
|
15601
|
+
// const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
|
|
15602
|
+
// if ($existedElement) {
|
|
15603
|
+
// this.$camera.removeChild($existedElement);
|
|
15604
|
+
// }
|
|
15591
15605
|
|
|
15592
|
-
if ($existedElement) {
|
|
15593
|
-
$container.removeChild($existedElement);
|
|
15594
|
-
}
|
|
15595
|
-
}
|
|
15596
15606
|
}
|
|
15597
15607
|
};
|
|
15598
15608
|
|
|
@@ -15616,28 +15626,50 @@
|
|
|
15616
15626
|
}
|
|
15617
15627
|
};
|
|
15618
15628
|
|
|
15629
|
+
var handleCanvasResize = function handleCanvasResize() {
|
|
15630
|
+
var _this$context$config = _this.context.config,
|
|
15631
|
+
width = _this$context$config.width,
|
|
15632
|
+
height = _this$context$config.height;
|
|
15633
|
+
_this.$camera.style.width = (width || 0) + "px";
|
|
15634
|
+
_this.$camera.style.height = (height || 0) + "px";
|
|
15635
|
+
};
|
|
15636
|
+
|
|
15619
15637
|
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
15620
15638
|
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
15621
15639
|
while (1) {
|
|
15622
15640
|
switch (_context.prev = _context.next) {
|
|
15623
15641
|
case 0:
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15642
|
+
// append camera
|
|
15643
|
+
_this.$camera = _this.createCamera(camera);
|
|
15644
|
+
canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
15645
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
15646
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
15647
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
15648
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
15628
15649
|
|
|
15629
|
-
case
|
|
15650
|
+
case 6:
|
|
15630
15651
|
case "end":
|
|
15631
15652
|
return _context.stop();
|
|
15632
15653
|
}
|
|
15633
15654
|
}
|
|
15634
15655
|
}, _callee);
|
|
15635
15656
|
})));
|
|
15657
|
+
renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
|
|
15658
|
+
if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
15659
|
+
_this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
|
|
15660
|
+
}
|
|
15661
|
+
});
|
|
15636
15662
|
renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15663
|
+
// remove camera
|
|
15664
|
+
if (_this.$camera) {
|
|
15665
|
+
_this.$camera.remove();
|
|
15666
|
+
}
|
|
15667
|
+
|
|
15668
|
+
canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
|
|
15669
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
15670
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
15671
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
15672
|
+
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
15641
15673
|
});
|
|
15642
15674
|
};
|
|
15643
15675
|
|
|
@@ -15645,43 +15677,71 @@
|
|
|
15645
15677
|
return object.id || HTML_PREFIX + object.entity;
|
|
15646
15678
|
};
|
|
15647
15679
|
|
|
15648
|
-
_proto.
|
|
15649
|
-
var
|
|
15650
|
-
|
|
15680
|
+
_proto.createCamera = function createCamera(camera) {
|
|
15681
|
+
var _this$context$config2 = this.context.config,
|
|
15682
|
+
doc = _this$context$config2.document,
|
|
15683
|
+
width = _this$context$config2.width,
|
|
15684
|
+
height = _this$context$config2.height;
|
|
15651
15685
|
var $canvas = this.context.contextService.getDomElement();
|
|
15652
15686
|
var $container = $canvas.parentNode;
|
|
15653
15687
|
|
|
15654
15688
|
if ($container) {
|
|
15655
|
-
var
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
$
|
|
15689
|
+
var cameraId = CANVAS_CAMERA_ID;
|
|
15690
|
+
var $existedCamera = $container.querySelector('#' + cameraId);
|
|
15691
|
+
|
|
15692
|
+
if (!$existedCamera) {
|
|
15693
|
+
var $camera = (doc || document).createElement('div');
|
|
15694
|
+
$existedCamera = $camera;
|
|
15695
|
+
$camera.id = cameraId; // use absolute position
|
|
15696
|
+
|
|
15697
|
+
$camera.style.position = 'absolute'; // account for DOM element's offset @see https://github.com/antvis/G/issues/1150
|
|
15698
|
+
|
|
15699
|
+
$camera.style.left = ($canvas.offsetLeft || 0) + "px";
|
|
15700
|
+
$camera.style.top = ($canvas.offsetTop || 0) + "px";
|
|
15701
|
+
$camera.style.transformOrigin = 'left top';
|
|
15702
|
+
$camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix()); // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
|
|
15703
|
+
|
|
15704
|
+
$camera.style.overflow = 'hidden';
|
|
15705
|
+
$camera.style.pointerEvents = 'none';
|
|
15706
|
+
$camera.style.width = (width || 0) + "px";
|
|
15707
|
+
$camera.style.height = (height || 0) + "px";
|
|
15708
|
+
$container.appendChild($camera);
|
|
15709
|
+
}
|
|
15661
15710
|
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
}
|
|
15711
|
+
return $existedCamera;
|
|
15712
|
+
}
|
|
15665
15713
|
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
}
|
|
15714
|
+
return null;
|
|
15715
|
+
};
|
|
15669
15716
|
|
|
15670
|
-
|
|
15717
|
+
_proto.getOrCreateEl = function getOrCreateEl(object) {
|
|
15718
|
+
var doc = this.context.config.document;
|
|
15719
|
+
var existedId = this.getId(object);
|
|
15720
|
+
var $existedElement = this.$camera.querySelector('#' + existedId);
|
|
15671
15721
|
|
|
15672
|
-
|
|
15722
|
+
if (!$existedElement) {
|
|
15723
|
+
$existedElement = (doc || document).createElement('div');
|
|
15724
|
+
object.parsedStyle.$el = $existedElement;
|
|
15725
|
+
$existedElement.id = existedId;
|
|
15673
15726
|
|
|
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(',') + ")";
|
|
15727
|
+
if (object.name) {
|
|
15728
|
+
$existedElement.setAttribute('name', object.name);
|
|
15679
15729
|
}
|
|
15680
15730
|
|
|
15681
|
-
|
|
15731
|
+
if (object.className) {
|
|
15732
|
+
$existedElement.className = object.className;
|
|
15733
|
+
} // use absolute position
|
|
15734
|
+
|
|
15735
|
+
|
|
15736
|
+
$existedElement.style.position = 'absolute'; // @see https://github.com/antvis/G/issues/1150
|
|
15737
|
+
|
|
15738
|
+
$existedElement.style.left = "0px";
|
|
15739
|
+
$existedElement.style.top = "0px";
|
|
15740
|
+
$existedElement.style['will-change'] = 'transform';
|
|
15741
|
+
$existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
|
|
15682
15742
|
}
|
|
15683
15743
|
|
|
15684
|
-
return
|
|
15744
|
+
return $existedElement;
|
|
15685
15745
|
};
|
|
15686
15746
|
|
|
15687
15747
|
_proto.updateAttribute = function updateAttribute(name, object) {
|
|
@@ -16404,6 +16464,7 @@
|
|
|
16404
16464
|
var renderingService = context.renderingService,
|
|
16405
16465
|
renderingContext = context.renderingContext,
|
|
16406
16466
|
imagePool = context.imagePool;
|
|
16467
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
16407
16468
|
|
|
16408
16469
|
var handleMounted = function handleMounted(e) {
|
|
16409
16470
|
var object = e.target;
|
|
@@ -16446,8 +16507,8 @@
|
|
|
16446
16507
|
while (1) {
|
|
16447
16508
|
switch (_context.prev = _context.next) {
|
|
16448
16509
|
case 0:
|
|
16449
|
-
|
|
16450
|
-
|
|
16510
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
16511
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
16451
16512
|
|
|
16452
16513
|
case 2:
|
|
16453
16514
|
case "end":
|
|
@@ -16457,8 +16518,8 @@
|
|
|
16457
16518
|
}, _callee);
|
|
16458
16519
|
})));
|
|
16459
16520
|
renderingService.hooks.destroy.tap(LoadImagePlugin.tag, function () {
|
|
16460
|
-
|
|
16461
|
-
|
|
16521
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
16522
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
16462
16523
|
});
|
|
16463
16524
|
};
|
|
16464
16525
|
|