@antv/g-webgpu 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +207 -97
- package/dist/index.js +207 -97
- package/dist/index.umd.js +8078 -6856
- package/dist/index.umd.min.js +6 -6
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -415,22 +415,114 @@ function _asyncToGenerator(fn) {
|
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
418
|
+
function _classCallCheck(instance, Constructor) {
|
|
419
|
+
if (!(instance instanceof Constructor)) {
|
|
420
|
+
throw new TypeError("Cannot call a class as a function");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function _defineProperties(target, props) {
|
|
425
|
+
for (var i = 0; i < props.length; i++) {
|
|
426
|
+
var descriptor = props[i];
|
|
427
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
428
|
+
descriptor.configurable = true;
|
|
429
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
430
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
421
433
|
|
|
422
|
-
|
|
434
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
435
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
436
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
437
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
438
|
+
writable: false
|
|
439
|
+
});
|
|
440
|
+
return Constructor;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function _inherits(subClass, superClass) {
|
|
444
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
445
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
449
|
+
constructor: {
|
|
450
|
+
value: subClass,
|
|
451
|
+
writable: true,
|
|
452
|
+
configurable: true
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
Object.defineProperty(subClass, "prototype", {
|
|
456
|
+
writable: false
|
|
457
|
+
});
|
|
458
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function _getPrototypeOf(o) {
|
|
462
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
463
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
464
|
+
};
|
|
465
|
+
return _getPrototypeOf(o);
|
|
423
466
|
}
|
|
424
467
|
|
|
425
468
|
function _setPrototypeOf(o, p) {
|
|
426
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
469
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
427
470
|
o.__proto__ = p;
|
|
428
471
|
return o;
|
|
429
472
|
};
|
|
430
|
-
|
|
431
473
|
return _setPrototypeOf(o, p);
|
|
432
474
|
}
|
|
433
475
|
|
|
476
|
+
function _isNativeReflectConstruct() {
|
|
477
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
478
|
+
if (Reflect.construct.sham) return false;
|
|
479
|
+
if (typeof Proxy === "function") return true;
|
|
480
|
+
|
|
481
|
+
try {
|
|
482
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
483
|
+
return true;
|
|
484
|
+
} catch (e) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function _assertThisInitialized(self) {
|
|
490
|
+
if (self === void 0) {
|
|
491
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return self;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function _possibleConstructorReturn(self, call) {
|
|
498
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
499
|
+
return call;
|
|
500
|
+
} else if (call !== void 0) {
|
|
501
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
return _assertThisInitialized(self);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function _createSuper(Derived) {
|
|
508
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
509
|
+
|
|
510
|
+
return function _createSuperInternal() {
|
|
511
|
+
var Super = _getPrototypeOf(Derived),
|
|
512
|
+
result;
|
|
513
|
+
|
|
514
|
+
if (hasNativeReflectConstruct) {
|
|
515
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
516
|
+
|
|
517
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
518
|
+
} else {
|
|
519
|
+
result = Super.apply(this, arguments);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return _possibleConstructorReturn(this, result);
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
|
|
434
526
|
/******************************************************************************
|
|
435
527
|
Copyright (c) Microsoft Corporation.
|
|
436
528
|
|
|
@@ -459,6 +551,8 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
459
551
|
|
|
460
552
|
var WebGLContextService = /*#__PURE__*/function () {
|
|
461
553
|
function WebGLContextService() {
|
|
554
|
+
_classCallCheck(this, WebGLContextService);
|
|
555
|
+
|
|
462
556
|
this.$container = void 0;
|
|
463
557
|
this.$canvas = void 0;
|
|
464
558
|
this.dpr = void 0;
|
|
@@ -466,106 +560,114 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
466
560
|
this.canvasConfig = void 0;
|
|
467
561
|
}
|
|
468
562
|
|
|
469
|
-
|
|
563
|
+
_createClass(WebGLContextService, [{
|
|
564
|
+
key: "init",
|
|
565
|
+
value: function () {
|
|
566
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
567
|
+
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
470
568
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
569
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
570
|
+
while (1) {
|
|
571
|
+
switch (_context.prev = _context.next) {
|
|
572
|
+
case 0:
|
|
573
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
474
574
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
switch (_context.prev = _context.next) {
|
|
478
|
-
case 0:
|
|
479
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
575
|
+
if (canvas) {
|
|
576
|
+
this.$canvas = canvas;
|
|
480
577
|
|
|
481
|
-
|
|
482
|
-
|
|
578
|
+
if (container && canvas.parentElement !== container) {
|
|
579
|
+
container.appendChild(canvas);
|
|
580
|
+
}
|
|
483
581
|
|
|
484
|
-
|
|
485
|
-
container
|
|
486
|
-
}
|
|
582
|
+
this.$container = canvas.parentElement;
|
|
583
|
+
this.canvasConfig.container = this.$container;
|
|
584
|
+
} else if (container) {
|
|
585
|
+
// create container
|
|
586
|
+
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
487
587
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
588
|
+
if (this.$container) {
|
|
589
|
+
// create canvas
|
|
590
|
+
$canvas = document.createElement('canvas');
|
|
591
|
+
this.$container.appendChild($canvas);
|
|
493
592
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
this.$container.appendChild($canvas);
|
|
593
|
+
if (!this.$container.style.position) {
|
|
594
|
+
this.$container.style.position = 'relative';
|
|
595
|
+
}
|
|
498
596
|
|
|
499
|
-
|
|
500
|
-
this.$container.style.position = 'relative';
|
|
597
|
+
this.$canvas = $canvas;
|
|
501
598
|
}
|
|
502
|
-
|
|
503
|
-
this.$canvas = $canvas;
|
|
504
|
-
}
|
|
505
|
-
} // use user-defined dpr first
|
|
599
|
+
} // use user-defined dpr first
|
|
506
600
|
|
|
507
601
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
602
|
+
dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
603
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
604
|
+
this.dpr = dpr;
|
|
511
605
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
606
|
+
case 5:
|
|
607
|
+
case "end":
|
|
608
|
+
return _context.stop();
|
|
609
|
+
}
|
|
515
610
|
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}));
|
|
519
|
-
|
|
520
|
-
function init() {
|
|
521
|
-
return _init.apply(this, arguments);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
return init;
|
|
525
|
-
}();
|
|
526
|
-
|
|
527
|
-
_proto.getDomElement = function getDomElement() {
|
|
528
|
-
return this.$canvas;
|
|
529
|
-
};
|
|
611
|
+
}, _callee, this);
|
|
612
|
+
}));
|
|
530
613
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
614
|
+
function init() {
|
|
615
|
+
return _init.apply(this, arguments);
|
|
616
|
+
}
|
|
534
617
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
618
|
+
return init;
|
|
619
|
+
}()
|
|
620
|
+
}, {
|
|
621
|
+
key: "getDomElement",
|
|
622
|
+
value: function getDomElement() {
|
|
623
|
+
return this.$canvas;
|
|
538
624
|
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
625
|
+
}, {
|
|
626
|
+
key: "getContext",
|
|
627
|
+
value: function getContext() {
|
|
628
|
+
return this.context;
|
|
629
|
+
}
|
|
630
|
+
}, {
|
|
631
|
+
key: "getBoundingClientRect",
|
|
632
|
+
value: function getBoundingClientRect() {
|
|
633
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
634
|
+
return this.$canvas.getBoundingClientRect();
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}, {
|
|
638
|
+
key: "destroy",
|
|
639
|
+
value: function destroy() {
|
|
544
640
|
// @ts-ignore
|
|
545
|
-
this.$container
|
|
641
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
642
|
+
// @ts-ignore
|
|
643
|
+
this.$container.removeChild(this.$canvas);
|
|
644
|
+
}
|
|
546
645
|
}
|
|
547
|
-
}
|
|
646
|
+
}, {
|
|
647
|
+
key: "resize",
|
|
648
|
+
value: function resize(width, height) {
|
|
649
|
+
if (this.$canvas) {
|
|
650
|
+
var dpr = this.getDPR(); // set canvas width & height
|
|
548
651
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
var dpr = this.getDPR(); // set canvas width & height
|
|
652
|
+
this.$canvas.width = dpr * width;
|
|
653
|
+
this.$canvas.height = dpr * height; // set CSS style width & height
|
|
552
654
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
g.setDOMSize(this.$canvas, width, height);
|
|
655
|
+
g.setDOMSize(this.$canvas, width, height);
|
|
656
|
+
}
|
|
557
657
|
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
565
|
-
if (this.$container && this.$container.style) {
|
|
566
|
-
this.$container.style.cursor = cursor;
|
|
658
|
+
}, {
|
|
659
|
+
key: "getDPR",
|
|
660
|
+
value: function getDPR() {
|
|
661
|
+
return this.dpr;
|
|
567
662
|
}
|
|
568
|
-
}
|
|
663
|
+
}, {
|
|
664
|
+
key: "applyCursorStyle",
|
|
665
|
+
value: function applyCursorStyle(cursor) {
|
|
666
|
+
if (this.$container && this.$container.style) {
|
|
667
|
+
this.$container.style.cursor = cursor;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}]);
|
|
569
671
|
|
|
570
672
|
return WebGLContextService;
|
|
571
673
|
}();
|
|
@@ -584,29 +686,37 @@ var containerModule = g.Module(function (register) {
|
|
|
584
686
|
});
|
|
585
687
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
586
688
|
function ContextRegisterPlugin() {
|
|
689
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
690
|
+
|
|
587
691
|
this.name = 'webgpu-context-register';
|
|
588
692
|
}
|
|
589
693
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
container
|
|
598
|
-
|
|
694
|
+
_createClass(ContextRegisterPlugin, [{
|
|
695
|
+
key: "init",
|
|
696
|
+
value: function init(container) {
|
|
697
|
+
container.load(containerModule, true);
|
|
698
|
+
}
|
|
699
|
+
}, {
|
|
700
|
+
key: "destroy",
|
|
701
|
+
value: function destroy(container) {
|
|
702
|
+
container.unload(containerModule);
|
|
703
|
+
}
|
|
704
|
+
}]);
|
|
599
705
|
|
|
600
706
|
return ContextRegisterPlugin;
|
|
601
707
|
}();
|
|
602
708
|
|
|
603
709
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
604
|
-
|
|
710
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
711
|
+
|
|
712
|
+
var _super = _createSuper(Renderer);
|
|
605
713
|
|
|
606
714
|
function Renderer(config) {
|
|
607
715
|
var _this;
|
|
608
716
|
|
|
609
|
-
|
|
717
|
+
_classCallCheck(this, Renderer);
|
|
718
|
+
|
|
719
|
+
_this = _super.call(this, config);
|
|
610
720
|
|
|
611
721
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
612
722
|
|
|
@@ -623,7 +733,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
623
733
|
return _this;
|
|
624
734
|
}
|
|
625
735
|
|
|
626
|
-
return Renderer;
|
|
736
|
+
return _createClass(Renderer);
|
|
627
737
|
}(g.AbstractRenderer);
|
|
628
738
|
|
|
629
739
|
exports.DeviceRenderer = DeviceRenderer__namespace;
|