@vectojs/core 0.2.2 → 0.2.3
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 +8 -9
- package/dist/{chunk-RW6NC4RB.js → chunk-6I53LI3Z.js} +55 -13
- package/dist/{chunk-H3QIE77O.mjs → chunk-ISGOYXPF.mjs} +177 -52
- package/dist/{chunk-LA3FJLP2.js → chunk-KPWVPGHR.js} +187 -62
- package/dist/{chunk-T456DL4P.mjs → chunk-LIOJ37MH.mjs} +1 -1
- package/dist/{chunk-2Y45S4JK.mjs → chunk-NKOQV3RM.mjs} +84 -5
- package/dist/{chunk-LIX7DJTI.js → chunk-TXA3LZDM.js} +85 -6
- package/dist/{chunk-72WVPMSJ.js → chunk-VVOQNUBK.js} +8 -8
- package/dist/{chunk-YA2J5ZH7.mjs → chunk-YSS44ADQ.mjs} +49 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +184 -119
- package/dist/index.mjs +146 -81
- package/dist/layout/LayoutWorkerManager.d.ts +4 -0
- package/dist/layout.js +3 -3
- package/dist/layout.mjs +2 -2
- package/dist/renderer/CanvasRenderer.d.ts +6 -0
- package/dist/renderer/IRenderer.d.ts +9 -0
- package/dist/renderer/SVGRenderer.d.ts +14 -0
- package/dist/renderer/url.d.ts +31 -0
- package/dist/renderer.js +2 -2
- package/dist/renderer.mjs +1 -1
- package/dist/text.js +3 -3
- package/dist/text.mjs +2 -2
- package/dist/tree/DOMPortalEntity.d.ts +2 -1
- package/dist/tree/Entity.d.ts +48 -7
- package/dist/tree/Scene.d.ts +9 -1
- package/package.json +2 -4
package/dist/index.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkVVOQNUBKjs = require('./chunk-VVOQNUBK.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var _chunkLIX7DJTIjs = require('./chunk-LIX7DJTI.js');
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
var _chunkTXA3LZDMjs = require('./chunk-TXA3LZDM.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -22,12 +22,14 @@ var _chunkLIX7DJTIjs = require('./chunk-LIX7DJTI.js');
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
var _chunkLA3FJLP2js = require('./chunk-LA3FJLP2.js');
|
|
26
25
|
|
|
27
26
|
|
|
27
|
+
var _chunkKPWVPGHRjs = require('./chunk-KPWVPGHR.js');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
var _chunk6I53LI3Zjs = require('./chunk-6I53LI3Z.js');
|
|
31
33
|
|
|
32
34
|
// src/tree/ComputeParticleEntity.ts
|
|
33
35
|
var PARTICLE_STRIDE_FLOATS = 8;
|
|
@@ -39,7 +41,7 @@ var PARTICLE_OFFSET_ORIGIN_X = 4;
|
|
|
39
41
|
var PARTICLE_OFFSET_ORIGIN_Y = 5;
|
|
40
42
|
var PARTICLE_OFFSET_SIZE = 6;
|
|
41
43
|
var PARTICLE_OFFSET_LIFE = 7;
|
|
42
|
-
var ComputeParticleEntity = (_class = class extends
|
|
44
|
+
var ComputeParticleEntity = (_class = class extends _chunkKPWVPGHRjs.Entity {
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
|
|
@@ -408,7 +410,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
408
410
|
this.particleBackend = _nullishCoalesce(options.particleBackend, () => ( "auto"));
|
|
409
411
|
this.a11ySyncInterval = _nullishCoalesce(options.a11ySyncInterval, () => ( 0));
|
|
410
412
|
this.reducedMotionQuery = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
|
|
411
|
-
this.root = new class RootEntity extends
|
|
413
|
+
this.root = new class RootEntity extends _chunkKPWVPGHRjs.Entity {
|
|
412
414
|
isPointInside() {
|
|
413
415
|
return false;
|
|
414
416
|
}
|
|
@@ -417,7 +419,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
417
419
|
}
|
|
418
420
|
}("root");
|
|
419
421
|
this.root._scene = this;
|
|
420
|
-
this.overlayRoot = new class OverlayRoot extends
|
|
422
|
+
this.overlayRoot = new class OverlayRoot extends _chunkKPWVPGHRjs.Entity {
|
|
421
423
|
isPointInside() {
|
|
422
424
|
return false;
|
|
423
425
|
}
|
|
@@ -428,7 +430,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
428
430
|
if (options.renderer) {
|
|
429
431
|
this.renderer = options.renderer;
|
|
430
432
|
} else {
|
|
431
|
-
this.renderer = new (0,
|
|
433
|
+
this.renderer = new (0, _chunkTXA3LZDMjs.CanvasRenderer)(canvas);
|
|
432
434
|
}
|
|
433
435
|
if (typeof document !== "undefined") {
|
|
434
436
|
this.a11yRoot = document.createElement("div");
|
|
@@ -489,6 +491,17 @@ var Scene = (_class2 = class _Scene {
|
|
|
489
491
|
getRenderer() {
|
|
490
492
|
return this.renderer;
|
|
491
493
|
}
|
|
494
|
+
/** Convert browser viewport coordinates into this Scene's logical coordinates. */
|
|
495
|
+
clientToScene(clientX, clientY) {
|
|
496
|
+
const rect = _optionalChain([this, 'access', _19 => _19.canvas, 'access', _20 => _20.getBoundingClientRect, 'optionalCall', _21 => _21()]);
|
|
497
|
+
if (!rect) return { x: clientX, y: clientY };
|
|
498
|
+
const cssWidth = rect.width || this.canvas.clientWidth || this.width;
|
|
499
|
+
const cssHeight = rect.height || this.canvas.clientHeight || this.height;
|
|
500
|
+
return {
|
|
501
|
+
x: (clientX - rect.left) * (cssWidth > 0 ? this.width / cssWidth : 1),
|
|
502
|
+
y: (clientY - rect.top) * (cssHeight > 0 ? this.height / cssHeight : 1)
|
|
503
|
+
};
|
|
504
|
+
}
|
|
492
505
|
/**
|
|
493
506
|
* Add a top-level entity to the scene graph.
|
|
494
507
|
*
|
|
@@ -563,12 +576,21 @@ var Scene = (_class2 = class _Scene {
|
|
|
563
576
|
this.removeA11yRecursively(overlay);
|
|
564
577
|
this.markDirty();
|
|
565
578
|
}
|
|
579
|
+
destroyEntitySubtree(entity) {
|
|
580
|
+
while (entity.children.length > 0) this.destroyEntitySubtree(entity.children.at(-1));
|
|
581
|
+
entity.destroy();
|
|
582
|
+
}
|
|
566
583
|
/**
|
|
567
584
|
* Tear down the Scene, halt the loop, and clean up event listeners and DOM elements.
|
|
568
585
|
*/
|
|
569
586
|
destroy() {
|
|
587
|
+
if (this.destroyed) return;
|
|
570
588
|
this.destroyed = true;
|
|
571
589
|
this.stop();
|
|
590
|
+
while (this.root.children.length > 0) this.destroyEntitySubtree(this.root.children.at(-1));
|
|
591
|
+
while (this.overlayRoot.children.length > 0) {
|
|
592
|
+
this.destroyEntitySubtree(this.overlayRoot.children.at(-1));
|
|
593
|
+
}
|
|
572
594
|
if (typeof window !== "undefined" && !this.disableWindowResize) {
|
|
573
595
|
window.removeEventListener("resize", this.resizeHandler);
|
|
574
596
|
}
|
|
@@ -580,12 +602,13 @@ var Scene = (_class2 = class _Scene {
|
|
|
580
602
|
this.canvas.removeEventListener("pointerleave", this.pointerLeaveListener);
|
|
581
603
|
}
|
|
582
604
|
}
|
|
583
|
-
_optionalChain([this, 'access',
|
|
584
|
-
_optionalChain([this, 'access',
|
|
605
|
+
_optionalChain([this, 'access', _22 => _22.a11yRoot, 'optionalAccess', _23 => _23.remove, 'call', _24 => _24()]);
|
|
606
|
+
_optionalChain([this, 'access', _25 => _25.portalRoot, 'optionalAccess', _26 => _26.remove, 'call', _27 => _27()]);
|
|
585
607
|
this.a11yElements.clear();
|
|
586
|
-
_optionalChain([this, 'access',
|
|
587
|
-
_optionalChain([this, 'access',
|
|
588
|
-
_optionalChain([this, 'access',
|
|
608
|
+
_optionalChain([this, 'access', _28 => _28.pointRenderer, 'optionalAccess', _29 => _29.destroy, 'call', _30 => _30()]);
|
|
609
|
+
_optionalChain([this, 'access', _31 => _31.renderer, 'access', _32 => _32.dispose, 'optionalCall', _33 => _33()]);
|
|
610
|
+
_optionalChain([this, 'access', _34 => _34.glCanvas, 'optionalAccess', _35 => _35.remove, 'call', _36 => _36()]);
|
|
611
|
+
_optionalChain([this, 'access', _37 => _37.gpuCanvas, 'optionalAccess', _38 => _38.remove, 'call', _39 => _39()]);
|
|
589
612
|
this.gpuCanvas = null;
|
|
590
613
|
this.gpuContext = null;
|
|
591
614
|
if (this.recoveryTimerId) {
|
|
@@ -603,9 +626,9 @@ var Scene = (_class2 = class _Scene {
|
|
|
603
626
|
}
|
|
604
627
|
if (typeof window !== "undefined" && this.canvas && typeof this.canvas.addEventListener === "function") {
|
|
605
628
|
this.pointerMoveListener = (e) => {
|
|
606
|
-
const
|
|
607
|
-
this.mouseX =
|
|
608
|
-
this.mouseY =
|
|
629
|
+
const point = this.clientToScene(e.clientX, e.clientY);
|
|
630
|
+
this.mouseX = point.x;
|
|
631
|
+
this.mouseY = point.y;
|
|
609
632
|
};
|
|
610
633
|
this.pointerLeaveListener = () => {
|
|
611
634
|
this.mouseX = -9999;
|
|
@@ -721,6 +744,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
721
744
|
el.id = node.id;
|
|
722
745
|
el.setAttribute("data-vecto-id", node.id);
|
|
723
746
|
el.style.position = "absolute";
|
|
747
|
+
el.style.transformOrigin = "0 0";
|
|
724
748
|
el.style.pointerEvents = "auto";
|
|
725
749
|
el.style.touchAction = "pinch-zoom";
|
|
726
750
|
el.style.margin = "0";
|
|
@@ -736,42 +760,42 @@ var Scene = (_class2 = class _Scene {
|
|
|
736
760
|
el.style.background = "transparent";
|
|
737
761
|
}
|
|
738
762
|
el.addEventListener("click", (e) => {
|
|
739
|
-
node.dispatchEvent(new (0,
|
|
763
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("click", node, e));
|
|
740
764
|
});
|
|
741
765
|
el.addEventListener("mouseenter", (e) => {
|
|
742
766
|
if (this.debugA11y) el.style.backgroundColor = "rgba(56, 189, 248, 0.2)";
|
|
743
|
-
node.dispatchEvent(new (0,
|
|
767
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("hover", node, e, false));
|
|
744
768
|
});
|
|
745
769
|
el.addEventListener("mouseleave", (e) => {
|
|
746
770
|
if (this.debugA11y) el.style.backgroundColor = "rgba(56, 189, 248, 0.05)";
|
|
747
|
-
node.dispatchEvent(new (0,
|
|
771
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("pointerleave", node, e, false));
|
|
748
772
|
});
|
|
749
773
|
const capEl = el;
|
|
750
774
|
el.addEventListener("pointerdown", (e) => {
|
|
751
775
|
if (typeof capEl.setPointerCapture === "function") capEl.setPointerCapture(e.pointerId);
|
|
752
|
-
node.dispatchEvent(new (0,
|
|
776
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("pointerdown", node, e));
|
|
753
777
|
});
|
|
754
778
|
el.addEventListener("pointerup", (e) => {
|
|
755
779
|
if (typeof capEl.releasePointerCapture === "function")
|
|
756
780
|
capEl.releasePointerCapture(e.pointerId);
|
|
757
|
-
node.dispatchEvent(new (0,
|
|
781
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("pointerup", node, e));
|
|
758
782
|
});
|
|
759
783
|
el.addEventListener(
|
|
760
784
|
"pointermove",
|
|
761
|
-
(e) => node.dispatchEvent(new (0,
|
|
785
|
+
(e) => node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("pointermove", node, e))
|
|
762
786
|
);
|
|
763
787
|
el.addEventListener(
|
|
764
788
|
"wheel",
|
|
765
789
|
(e) => {
|
|
766
|
-
node.dispatchEvent(new (0,
|
|
790
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("wheel", node, e));
|
|
767
791
|
},
|
|
768
792
|
{ passive: false }
|
|
769
793
|
);
|
|
770
794
|
el.addEventListener("keydown", (e) => {
|
|
771
|
-
node.dispatchEvent(new (0,
|
|
795
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("keydown", node, e));
|
|
772
796
|
});
|
|
773
797
|
el.addEventListener("keyup", (e) => {
|
|
774
|
-
node.dispatchEvent(new (0,
|
|
798
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("keyup", node, e));
|
|
775
799
|
});
|
|
776
800
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
777
801
|
const input = el;
|
|
@@ -797,7 +821,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
797
821
|
});
|
|
798
822
|
el.addEventListener("compositionupdate", (e) => {
|
|
799
823
|
const data = _nullishCoalesce(e.data, () => ( ""));
|
|
800
|
-
composition = { start: _nullishCoalesce(_optionalChain([composition, 'optionalAccess',
|
|
824
|
+
composition = { start: _nullishCoalesce(_optionalChain([composition, 'optionalAccess', _40 => _40.start]), () => ( 0)), length: data.length };
|
|
801
825
|
forward();
|
|
802
826
|
});
|
|
803
827
|
el.addEventListener("compositionend", () => {
|
|
@@ -843,7 +867,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
843
867
|
el.addEventListener("keydown", (e) => {
|
|
844
868
|
if (e.key === "Enter" || e.key === " ") {
|
|
845
869
|
e.preventDefault();
|
|
846
|
-
node.dispatchEvent(new (0,
|
|
870
|
+
node.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)("click", node, e));
|
|
847
871
|
}
|
|
848
872
|
});
|
|
849
873
|
}
|
|
@@ -868,7 +892,8 @@ var Scene = (_class2 = class _Scene {
|
|
|
868
892
|
if (el.placeholder !== attrs.placeholder) el.placeholder = attrs.placeholder;
|
|
869
893
|
}
|
|
870
894
|
if (attrs.href !== void 0 && el instanceof HTMLAnchorElement) {
|
|
871
|
-
|
|
895
|
+
const safeHref = _chunkTXA3LZDMjs.sanitizeUrl.call(void 0, attrs.href);
|
|
896
|
+
if (el.getAttribute("href") !== safeHref) el.setAttribute("href", safeHref);
|
|
872
897
|
}
|
|
873
898
|
if (el instanceof HTMLImageElement) {
|
|
874
899
|
if (attrs.src !== void 0 && el.src !== attrs.src) el.src = attrs.src;
|
|
@@ -929,12 +954,12 @@ var Scene = (_class2 = class _Scene {
|
|
|
929
954
|
el.style.height = `${this.height}px`;
|
|
930
955
|
el.style.transform = "";
|
|
931
956
|
} else {
|
|
932
|
-
const
|
|
933
|
-
el.style.left = `${
|
|
934
|
-
el.style.top = `${
|
|
935
|
-
el.style.width = `${node.width
|
|
936
|
-
el.style.height = `${node.height
|
|
937
|
-
el.style.transform = `
|
|
957
|
+
const { a, b, c, d, e, f } = node.getWorldTransform();
|
|
958
|
+
el.style.left = `${e + node.a11yOffsetX}px`;
|
|
959
|
+
el.style.top = `${f + node.a11yOffsetY}px`;
|
|
960
|
+
el.style.width = `${node.width}px`;
|
|
961
|
+
el.style.height = `${node.height}px`;
|
|
962
|
+
el.style.transform = `matrix(${a}, ${b}, ${c}, ${d}, 0, 0)`;
|
|
938
963
|
}
|
|
939
964
|
}
|
|
940
965
|
for (const child of node.children) this.syncA11y(child);
|
|
@@ -996,6 +1021,35 @@ var Scene = (_class2 = class _Scene {
|
|
|
996
1021
|
}
|
|
997
1022
|
this.a11yNeedsReorder = false;
|
|
998
1023
|
}
|
|
1024
|
+
/** Keep DOM/WebGL overlay layers aligned with the canvas's CSS box. */
|
|
1025
|
+
syncOverlayGeometry() {
|
|
1026
|
+
const parent = this.canvas.parentElement;
|
|
1027
|
+
if (!parent) return;
|
|
1028
|
+
const canvasRect = _optionalChain([this, 'access', _41 => _41.canvas, 'access', _42 => _42.getBoundingClientRect, 'optionalCall', _43 => _43()]);
|
|
1029
|
+
const parentRect = _optionalChain([parent, 'access', _44 => _44.getBoundingClientRect, 'optionalCall', _45 => _45()]);
|
|
1030
|
+
const cssWidth = _optionalChain([canvasRect, 'optionalAccess', _46 => _46.width]) || this.canvas.clientWidth || this.width;
|
|
1031
|
+
const cssHeight = _optionalChain([canvasRect, 'optionalAccess', _47 => _47.height]) || this.canvas.clientHeight || this.height;
|
|
1032
|
+
const left = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _48 => _48.left]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _49 => _49.left]), () => ( 0))) - (parent.clientLeft || 0) + parent.scrollLeft;
|
|
1033
|
+
const top = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _50 => _50.top]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _51 => _51.top]), () => ( 0))) - (parent.clientTop || 0) + parent.scrollTop;
|
|
1034
|
+
const scaleX = this.width > 0 ? cssWidth / this.width : 1;
|
|
1035
|
+
const scaleY = this.height > 0 ? cssHeight / this.height : 1;
|
|
1036
|
+
for (const root of [this.a11yRoot, this.portalRoot]) {
|
|
1037
|
+
if (!root) continue;
|
|
1038
|
+
root.style.left = `${left}px`;
|
|
1039
|
+
root.style.top = `${top}px`;
|
|
1040
|
+
root.style.width = `${this.width}px`;
|
|
1041
|
+
root.style.height = `${this.height}px`;
|
|
1042
|
+
root.style.transformOrigin = "0 0";
|
|
1043
|
+
root.style.transform = `scale(${scaleX}, ${scaleY})`;
|
|
1044
|
+
}
|
|
1045
|
+
for (const canvas of [this.glCanvas, this.gpuCanvas]) {
|
|
1046
|
+
if (!canvas) continue;
|
|
1047
|
+
canvas.style.left = `${left}px`;
|
|
1048
|
+
canvas.style.top = `${top}px`;
|
|
1049
|
+
canvas.style.width = `${cssWidth}px`;
|
|
1050
|
+
canvas.style.height = `${cssHeight}px`;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
999
1053
|
getA11yTree() {
|
|
1000
1054
|
const map = /* @__PURE__ */ new Map();
|
|
1001
1055
|
const roots = [];
|
|
@@ -1039,7 +1093,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1039
1093
|
traverse(this.root, null);
|
|
1040
1094
|
return roots;
|
|
1041
1095
|
}
|
|
1042
|
-
renderPortalDOM(portal, te, tf, a, b, c, d) {
|
|
1096
|
+
renderPortalDOM(portal, te, tf, a, b, c, d, opacity) {
|
|
1043
1097
|
if (!this.portalRoot) return;
|
|
1044
1098
|
this.activePortalsThisFrame.add(portal.id);
|
|
1045
1099
|
this.portalEntities.set(portal.id, portal);
|
|
@@ -1073,6 +1127,11 @@ var Scene = (_class2 = class _Scene {
|
|
|
1073
1127
|
portal.domElement.style.zIndex = zIndexStr;
|
|
1074
1128
|
portal.lastZIndex = zIndexStr;
|
|
1075
1129
|
}
|
|
1130
|
+
const opacityStr = String(opacity);
|
|
1131
|
+
if (portal.lastOpacity !== opacityStr) {
|
|
1132
|
+
portal.domElement.style.opacity = opacityStr;
|
|
1133
|
+
portal.lastOpacity = opacityStr;
|
|
1134
|
+
}
|
|
1076
1135
|
}
|
|
1077
1136
|
reconcilePortals() {
|
|
1078
1137
|
if (!this.portalRoot) return;
|
|
@@ -1096,7 +1155,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1096
1155
|
* (and {@link respectReducedMotion} is on). `0` means uncapped.
|
|
1097
1156
|
*/
|
|
1098
1157
|
effectiveMaxFPS() {
|
|
1099
|
-
const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access',
|
|
1158
|
+
const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access', _52 => _52.reducedMotionQuery, 'optionalAccess', _53 => _53.matches]);
|
|
1100
1159
|
if (reduced)
|
|
1101
1160
|
return this.maxFPS > 0 ? Math.min(this.maxFPS, REDUCED_MOTION_FPS) : REDUCED_MOTION_FPS;
|
|
1102
1161
|
return this.maxFPS;
|
|
@@ -1143,14 +1202,18 @@ var Scene = (_class2 = class _Scene {
|
|
|
1143
1202
|
* @param time - Current absolute time in milliseconds (default 0).
|
|
1144
1203
|
*/
|
|
1145
1204
|
render(renderer, dt = 0, time = 0) {
|
|
1146
|
-
|
|
1205
|
+
const isMainRenderer = renderer === this.renderer;
|
|
1206
|
+
if (isMainRenderer && this.a11yRoot && this.canvas.parentElement) {
|
|
1147
1207
|
const parentStyle = this.canvas.parentElement.style;
|
|
1148
1208
|
if (!parentStyle.position || parentStyle.position === "static") {
|
|
1149
1209
|
parentStyle.position = "relative";
|
|
1150
1210
|
}
|
|
1211
|
+
this.syncOverlayGeometry();
|
|
1212
|
+
}
|
|
1213
|
+
if (isMainRenderer) {
|
|
1214
|
+
this.renderOrderCounter = 0;
|
|
1215
|
+
this.activePortalsThisFrame.clear();
|
|
1151
1216
|
}
|
|
1152
|
-
this.renderOrderCounter = 0;
|
|
1153
|
-
this.activePortalsThisFrame.clear();
|
|
1154
1217
|
const computeEntities = [];
|
|
1155
1218
|
const collectComputeEntities = (node) => {
|
|
1156
1219
|
if (node instanceof ComputeParticleEntity) {
|
|
@@ -1165,7 +1228,8 @@ var Scene = (_class2 = class _Scene {
|
|
|
1165
1228
|
collectComputeEntities(overlay);
|
|
1166
1229
|
}
|
|
1167
1230
|
if (computeEntities.length > 0) {
|
|
1168
|
-
|
|
1231
|
+
const isMainRenderPath = renderer === this.renderer;
|
|
1232
|
+
if (isMainRenderPath && !this.device && !this.webgpuDisabled && !this.initializingWebGPU && !this.deviceLost) {
|
|
1169
1233
|
this.initializingWebGPU = true;
|
|
1170
1234
|
this.initWebGPUContext(computeEntities).then((newDevice) => {
|
|
1171
1235
|
this.device = newDevice;
|
|
@@ -1188,12 +1252,16 @@ var Scene = (_class2 = class _Scene {
|
|
|
1188
1252
|
}
|
|
1189
1253
|
}
|
|
1190
1254
|
}).catch((err) => {
|
|
1191
|
-
|
|
1255
|
+
if (this.particleBackend === "webgpu") {
|
|
1256
|
+
console.error("Failed to initialize WebGPU:", err);
|
|
1257
|
+
} else {
|
|
1258
|
+
console.warn("WebGPU unavailable; using CPU particle fallback.", err);
|
|
1259
|
+
}
|
|
1192
1260
|
this.webgpuDisabled = true;
|
|
1193
1261
|
this.initializingWebGPU = false;
|
|
1194
1262
|
});
|
|
1195
1263
|
}
|
|
1196
|
-
if (this.device && this.manager && !this.deviceLost && !this.webgpuDisabled) {
|
|
1264
|
+
if (isMainRenderPath && this.device && this.manager && !this.deviceLost && !this.webgpuDisabled) {
|
|
1197
1265
|
try {
|
|
1198
1266
|
const commandEncoder = this.device.createCommandEncoder();
|
|
1199
1267
|
const computePass = commandEncoder.beginComputePass();
|
|
@@ -1241,21 +1309,20 @@ var Scene = (_class2 = class _Scene {
|
|
|
1241
1309
|
this.device = null;
|
|
1242
1310
|
this.recreateWebGPUDeviceWithRetry(computeEntities);
|
|
1243
1311
|
}
|
|
1244
|
-
} else {
|
|
1312
|
+
} else if (isMainRenderPath) {
|
|
1245
1313
|
for (const entity of computeEntities) {
|
|
1246
1314
|
entity.updateCPU(dt / 1e3, this.mouseX, this.mouseY, this.width, this.height);
|
|
1247
1315
|
}
|
|
1248
1316
|
}
|
|
1249
1317
|
}
|
|
1250
1318
|
renderer.clear();
|
|
1251
|
-
const isMainRenderer = renderer === this.renderer;
|
|
1252
1319
|
if (isMainRenderer) {
|
|
1253
|
-
_optionalChain([this, 'access',
|
|
1320
|
+
_optionalChain([this, 'access', _54 => _54.pointRenderer, 'optionalAccess', _55 => _55.begin, 'call', _56 => _56()]);
|
|
1254
1321
|
}
|
|
1255
1322
|
const vw = this.width;
|
|
1256
1323
|
const vh = this.height;
|
|
1257
|
-
const renderNode = (node, pa, pb, pc, pd, pe, pf) => {
|
|
1258
|
-
node.update(dt, time);
|
|
1324
|
+
const renderNode = (node, pa, pb, pc, pd, pe, pf, parentOpacity) => {
|
|
1325
|
+
if (isMainRenderer) node.update(dt, time);
|
|
1259
1326
|
const cos = Math.cos(node.rotation);
|
|
1260
1327
|
const sin = Math.sin(node.rotation);
|
|
1261
1328
|
const te = pa * node.x + pc * node.y + pe;
|
|
@@ -1264,16 +1331,24 @@ var Scene = (_class2 = class _Scene {
|
|
|
1264
1331
|
const sxSin = node.scaleX * sin;
|
|
1265
1332
|
const syCos = node.scaleY * cos;
|
|
1266
1333
|
const sySin = node.scaleY * sin;
|
|
1267
|
-
const a = pa * sxCos + pc *
|
|
1268
|
-
const b = pb * sxCos + pd *
|
|
1269
|
-
const c = pa * -
|
|
1270
|
-
const d = pb * -
|
|
1271
|
-
const
|
|
1334
|
+
const a = pa * sxCos + pc * sySin;
|
|
1335
|
+
const b = pb * sxCos + pd * sySin;
|
|
1336
|
+
const c = pa * -sxSin + pc * syCos;
|
|
1337
|
+
const d = pb * -sxSin + pd * syCos;
|
|
1338
|
+
const worldScaleX = Math.hypot(a, b);
|
|
1339
|
+
const worldScaleY = Math.hypot(c, d);
|
|
1340
|
+
const worldOpacity = parentOpacity * node.opacity;
|
|
1341
|
+
const scaleTolerance = Math.max(1, worldScaleX, worldScaleY) * 1e-6;
|
|
1342
|
+
const orthogonalTolerance = Math.max(1, worldScaleX * worldScaleY) * 1e-6;
|
|
1343
|
+
const isSimilarityTransform = Number.isFinite(worldScaleX) && Number.isFinite(worldScaleY) && Math.abs(worldScaleX - worldScaleY) <= scaleTolerance && Math.abs(a * c + b * d) <= orthogonalTolerance;
|
|
1344
|
+
const a11yEl = isMainRenderer ? this.a11yElements.get(node.id) : void 0;
|
|
1272
1345
|
if (a11yEl) {
|
|
1273
1346
|
a11yEl.style.zIndex = String(this.renderOrderCounter++);
|
|
1274
1347
|
}
|
|
1275
1348
|
if (node.isDOMPortal) {
|
|
1276
|
-
|
|
1349
|
+
if (isMainRenderer) {
|
|
1350
|
+
this.renderPortalDOM(node, te, tf, a, b, c, d, worldOpacity);
|
|
1351
|
+
}
|
|
1277
1352
|
return;
|
|
1278
1353
|
}
|
|
1279
1354
|
let visible = true;
|
|
@@ -1299,33 +1374,27 @@ var Scene = (_class2 = class _Scene {
|
|
|
1299
1374
|
if (node.children.length === 0 && node.scaleX === node.scaleY) {
|
|
1300
1375
|
const bc = node.getBatchCircle();
|
|
1301
1376
|
if (bc) {
|
|
1302
|
-
if (visible)
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
bc.radius * Math.hypot(a, b),
|
|
1308
|
-
bc.color,
|
|
1309
|
-
node.opacity
|
|
1310
|
-
);
|
|
1311
|
-
} else {
|
|
1312
|
-
renderer.fillCircle(node.x, node.y, bc.radius * node.scaleX, bc.color, node.opacity);
|
|
1377
|
+
if (!visible) return;
|
|
1378
|
+
if (isMainRenderer && this.pointRenderer) {
|
|
1379
|
+
if (isSimilarityTransform) {
|
|
1380
|
+
this.pointRenderer.addCircle(te, tf, bc.radius * worldScaleX, bc.color, worldOpacity);
|
|
1381
|
+
return;
|
|
1313
1382
|
}
|
|
1383
|
+
} else {
|
|
1384
|
+
renderer.fillCircle(node.x, node.y, bc.radius * node.scaleX, bc.color, worldOpacity);
|
|
1385
|
+
return;
|
|
1314
1386
|
}
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
if (isMainRenderer && this.pointRenderer) {
|
|
1387
|
+
} else if (isMainRenderer && this.pointRenderer) {
|
|
1318
1388
|
const br = node.getBatchRect();
|
|
1319
|
-
if (br) {
|
|
1389
|
+
if (br && isSimilarityTransform && a * d - b * c >= 0) {
|
|
1320
1390
|
if (visible) {
|
|
1321
|
-
const ws = Math.hypot(a, b);
|
|
1322
1391
|
this.pointRenderer.addRect(
|
|
1323
1392
|
te,
|
|
1324
1393
|
tf,
|
|
1325
|
-
br.width *
|
|
1326
|
-
br.height *
|
|
1394
|
+
br.width * worldScaleX,
|
|
1395
|
+
br.height * worldScaleX,
|
|
1327
1396
|
br.color,
|
|
1328
|
-
|
|
1397
|
+
worldOpacity,
|
|
1329
1398
|
Math.atan2(b, a)
|
|
1330
1399
|
);
|
|
1331
1400
|
}
|
|
@@ -1338,11 +1407,11 @@ var Scene = (_class2 = class _Scene {
|
|
|
1338
1407
|
renderer.translate(node.x, node.y);
|
|
1339
1408
|
renderer.scale(node.scaleX, node.scaleY);
|
|
1340
1409
|
renderer.rotate(node.rotation);
|
|
1341
|
-
renderer.setGlobalAlpha(
|
|
1410
|
+
renderer.setGlobalAlpha(worldOpacity);
|
|
1342
1411
|
if (visible) {
|
|
1343
1412
|
if (node instanceof ComputeParticleEntity) {
|
|
1344
1413
|
if (this.deviceLost || this.webgpuDisabled || !this.device || !this.manager) {
|
|
1345
|
-
this.renderCPUParticles(renderer, node);
|
|
1414
|
+
this.renderCPUParticles(renderer, node, worldOpacity);
|
|
1346
1415
|
}
|
|
1347
1416
|
} else {
|
|
1348
1417
|
node.render(renderer);
|
|
@@ -1352,26 +1421,26 @@ var Scene = (_class2 = class _Scene {
|
|
|
1352
1421
|
renderer.clip(0, 0, node.width, node.height);
|
|
1353
1422
|
}
|
|
1354
1423
|
for (const child of node.children) {
|
|
1355
|
-
renderNode(child, a, b, c, d, te, tf);
|
|
1424
|
+
renderNode(child, a, b, c, d, te, tf, worldOpacity);
|
|
1356
1425
|
}
|
|
1357
1426
|
renderer.flush();
|
|
1358
1427
|
renderer.restore();
|
|
1359
1428
|
};
|
|
1360
|
-
renderNode(this.root, 1, 0, 0, 1, 0, 0);
|
|
1429
|
+
renderNode(this.root, 1, 0, 0, 1, 0, 0, 1);
|
|
1361
1430
|
for (const overlay of this.overlayRoot.children) {
|
|
1362
|
-
renderNode(overlay, 1, 0, 0, 1, 0, 0);
|
|
1431
|
+
renderNode(overlay, 1, 0, 0, 1, 0, 0, 1);
|
|
1363
1432
|
}
|
|
1364
|
-
this.reconcilePortals();
|
|
1433
|
+
if (isMainRenderer) this.reconcilePortals();
|
|
1365
1434
|
renderer.flush();
|
|
1366
1435
|
if (isMainRenderer) {
|
|
1367
|
-
_optionalChain([this, 'access',
|
|
1436
|
+
_optionalChain([this, 'access', _57 => _57.pointRenderer, 'optionalAccess', _58 => _58.flush, 'call', _59 => _59()]);
|
|
1368
1437
|
}
|
|
1369
1438
|
}
|
|
1370
1439
|
/**
|
|
1371
1440
|
* Export the current scene state to a lightweight, flat SVG XML string.
|
|
1372
1441
|
*/
|
|
1373
1442
|
toSVG() {
|
|
1374
|
-
const renderer = new (0,
|
|
1443
|
+
const renderer = new (0, _chunkTXA3LZDMjs.SVGRenderer)(this.width, this.height);
|
|
1375
1444
|
this.render(renderer, 0, 0);
|
|
1376
1445
|
return renderer.toXMLString();
|
|
1377
1446
|
}
|
|
@@ -1384,7 +1453,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1384
1453
|
if (typeof this.renderer.resize === "function") {
|
|
1385
1454
|
this.renderer.resize(width, height);
|
|
1386
1455
|
}
|
|
1387
|
-
_optionalChain([this, 'access',
|
|
1456
|
+
_optionalChain([this, 'access', _60 => _60.pointRenderer, 'optionalAccess', _61 => _61.resize, 'call', _62 => _62(width, height)]);
|
|
1388
1457
|
this.markDirty();
|
|
1389
1458
|
}
|
|
1390
1459
|
/**
|
|
@@ -1491,13 +1560,15 @@ var Scene = (_class2 = class _Scene {
|
|
|
1491
1560
|
this.manager.initPipelines(format);
|
|
1492
1561
|
for (const entity of entities) {
|
|
1493
1562
|
this.manager.setupEntityResources(entity);
|
|
1494
|
-
|
|
1563
|
+
if (entity.gpuStorageBuffer) {
|
|
1564
|
+
newDevice.queue.writeBuffer(entity.gpuStorageBuffer, 0, entity.particleData);
|
|
1565
|
+
}
|
|
1495
1566
|
}
|
|
1496
1567
|
}
|
|
1497
1568
|
}).catch(() => this.recreateWebGPUDeviceWithRetry(entities, attempt + 1));
|
|
1498
1569
|
}, backoff);
|
|
1499
1570
|
}
|
|
1500
|
-
renderCPUParticles(renderer, entity) {
|
|
1571
|
+
renderCPUParticles(renderer, entity, worldOpacity) {
|
|
1501
1572
|
const data = entity.particleData;
|
|
1502
1573
|
const size = entity.maxParticles;
|
|
1503
1574
|
const isMain = renderer === this.renderer;
|
|
@@ -1508,7 +1579,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1508
1579
|
const pSize = data[idx + 6];
|
|
1509
1580
|
const life = data[idx + 7];
|
|
1510
1581
|
if (life === 0) continue;
|
|
1511
|
-
const opacity = life < 0 ?
|
|
1582
|
+
const opacity = life < 0 ? worldOpacity : worldOpacity * Math.min(1, life);
|
|
1512
1583
|
const scale = life >= 0 ? Math.min(1, life) : 1;
|
|
1513
1584
|
if (isMain && this.pointRenderer) {
|
|
1514
1585
|
this.pointRenderer.addCircle(x, y, pSize * scale, entity.baseColor, opacity);
|
|
@@ -1532,10 +1603,10 @@ var Scene = (_class2 = class _Scene {
|
|
|
1532
1603
|
// src/components/TextEntity.ts
|
|
1533
1604
|
var sharedMeasurer;
|
|
1534
1605
|
function defaultMeasurer() {
|
|
1535
|
-
if (sharedMeasurer === void 0) sharedMeasurer =
|
|
1606
|
+
if (sharedMeasurer === void 0) sharedMeasurer = _chunkVVOQNUBKjs.createCanvasMeasurer.call(void 0, "sans-serif");
|
|
1536
1607
|
return sharedMeasurer;
|
|
1537
1608
|
}
|
|
1538
|
-
var TextEntity = (_class3 = class extends
|
|
1609
|
+
var TextEntity = (_class3 = class extends _chunkKPWVPGHRjs.Entity {
|
|
1539
1610
|
|
|
1540
1611
|
|
|
1541
1612
|
|
|
@@ -1552,7 +1623,7 @@ var TextEntity = (_class3 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
1552
1623
|
this.text = text;
|
|
1553
1624
|
this.atlas = atlas;
|
|
1554
1625
|
this.fontSize = fontSize;
|
|
1555
|
-
this.layout = new (0,
|
|
1626
|
+
this.layout = new (0, _chunkVVOQNUBKjs.LayoutEngine)(maxWidth, 1e4, defaultMeasurer());
|
|
1556
1627
|
this.prepared = this.layout.prepare(this.text, this.atlas, this.fontSize);
|
|
1557
1628
|
this.applyLayout();
|
|
1558
1629
|
this.interactive = true;
|
|
@@ -1592,10 +1663,9 @@ var TextEntity = (_class3 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
1592
1663
|
this.a11yOffsetY = 0;
|
|
1593
1664
|
}
|
|
1594
1665
|
isPointInside(globalX, globalY) {
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
return lx >= 0 && lx <= this.width && ly >= 0 && ly <= this.height;
|
|
1666
|
+
const local = this.worldToLocal(globalX, globalY);
|
|
1667
|
+
if (!local) return false;
|
|
1668
|
+
return local.x >= 0 && local.x <= this.width && local.y >= 0 && local.y <= this.height;
|
|
1599
1669
|
}
|
|
1600
1670
|
render(renderer) {
|
|
1601
1671
|
const currentFill = this.isHovered ? this.hoveredFillStyle : this.fillStyle;
|
|
@@ -1634,7 +1704,7 @@ var TextEntity = (_class3 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
1634
1704
|
}, _class3);
|
|
1635
1705
|
|
|
1636
1706
|
// src/components/GridTextEntity.ts
|
|
1637
|
-
var GridTextEntity = (_class4 = class extends
|
|
1707
|
+
var GridTextEntity = (_class4 = class extends _chunkKPWVPGHRjs.Entity {
|
|
1638
1708
|
|
|
1639
1709
|
__init54() {this.fillStyle = "#ffffff"}
|
|
1640
1710
|
__init55() {this.grid = []}
|
|
@@ -1653,7 +1723,7 @@ var GridTextEntity = (_class4 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
1653
1723
|
updateGrid(ascii) {
|
|
1654
1724
|
this.grid = ascii;
|
|
1655
1725
|
this.rows = ascii.length;
|
|
1656
|
-
this.cols = _optionalChain([ascii, 'access',
|
|
1726
|
+
this.cols = _optionalChain([ascii, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.length]) || 0;
|
|
1657
1727
|
}
|
|
1658
1728
|
isPointInside(_globalX, _globalY) {
|
|
1659
1729
|
return false;
|
|
@@ -1728,7 +1798,7 @@ function distSqToSegment(px, py, x1, y1, x2, y2) {
|
|
|
1728
1798
|
const ey = py - cy;
|
|
1729
1799
|
return ex * ex + ey * ey;
|
|
1730
1800
|
}
|
|
1731
|
-
var SplineEntity = (_class5 = class extends
|
|
1801
|
+
var SplineEntity = (_class5 = class extends _chunkKPWVPGHRjs.Entity {
|
|
1732
1802
|
|
|
1733
1803
|
|
|
1734
1804
|
|
|
@@ -1810,10 +1880,9 @@ var SplineEntity = (_class5 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
1810
1880
|
* this method already calls it as a refinement when it is overridden.
|
|
1811
1881
|
*/
|
|
1812
1882
|
isPointInside(globalX, globalY) {
|
|
1813
|
-
const
|
|
1814
|
-
|
|
1815
|
-
const
|
|
1816
|
-
const ly = (globalY - pos.y) / (scale.y || 1);
|
|
1883
|
+
const local = this.worldToLocal(globalX, globalY);
|
|
1884
|
+
if (!local) return false;
|
|
1885
|
+
const { x: lx, y: ly } = local;
|
|
1817
1886
|
const inAabb = lx >= this.bounds.x && lx <= this.bounds.x + this.bounds.width && ly >= this.bounds.y && ly <= this.bounds.y + this.bounds.height;
|
|
1818
1887
|
if (!inAabb) return false;
|
|
1819
1888
|
const refined = this.hitTestCurve(lx, ly);
|
|
@@ -2050,7 +2119,7 @@ var SpatialHashGrid = (_class6 = class {
|
|
|
2050
2119
|
const keys = this.entityCells.get(id);
|
|
2051
2120
|
if (!keys) return;
|
|
2052
2121
|
for (const key of keys) {
|
|
2053
|
-
_optionalChain([this, 'access',
|
|
2122
|
+
_optionalChain([this, 'access', _65 => _65.grid, 'access', _66 => _66.get, 'call', _67 => _67(key), 'optionalAccess', _68 => _68.delete, 'call', _69 => _69(id)]);
|
|
2054
2123
|
}
|
|
2055
2124
|
this.entityCells.delete(id);
|
|
2056
2125
|
}
|
|
@@ -2086,7 +2155,7 @@ var SpatialHashGrid = (_class6 = class {
|
|
|
2086
2155
|
}, _class6);
|
|
2087
2156
|
|
|
2088
2157
|
// src/tree/DOMPortalEntity.ts
|
|
2089
|
-
var DOMPortalEntity = (_class7 = class extends
|
|
2158
|
+
var DOMPortalEntity = (_class7 = class extends _chunkKPWVPGHRjs.Entity {
|
|
2090
2159
|
|
|
2091
2160
|
__init64() {this.isDOMPortal = true}
|
|
2092
2161
|
__init65() {this.domListeners = []}
|
|
@@ -2097,8 +2166,9 @@ var DOMPortalEntity = (_class7 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
2097
2166
|
__init70() {this.lastHeight = ""}
|
|
2098
2167
|
__init71() {this.lastTransform = ""}
|
|
2099
2168
|
__init72() {this.lastZIndex = ""}
|
|
2169
|
+
__init73() {this.lastOpacity = ""}
|
|
2100
2170
|
constructor(domElement, width, height, id) {
|
|
2101
|
-
super(id);_class7.prototype.__init64.call(this);_class7.prototype.__init65.call(this);_class7.prototype.__init66.call(this);_class7.prototype.__init67.call(this);_class7.prototype.__init68.call(this);_class7.prototype.__init69.call(this);_class7.prototype.__init70.call(this);_class7.prototype.__init71.call(this);_class7.prototype.__init72.call(this);;
|
|
2171
|
+
super(id);_class7.prototype.__init64.call(this);_class7.prototype.__init65.call(this);_class7.prototype.__init66.call(this);_class7.prototype.__init67.call(this);_class7.prototype.__init68.call(this);_class7.prototype.__init69.call(this);_class7.prototype.__init70.call(this);_class7.prototype.__init71.call(this);_class7.prototype.__init72.call(this);_class7.prototype.__init73.call(this);;
|
|
2102
2172
|
this.domElement = domElement;
|
|
2103
2173
|
this.width = _nullishCoalesce(width, () => ( 0));
|
|
2104
2174
|
this.height = _nullishCoalesce(height, () => ( 0));
|
|
@@ -2120,7 +2190,7 @@ var DOMPortalEntity = (_class7 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
2120
2190
|
const events = ["click", "pointerdown", "pointerup", "pointermove", "wheel"];
|
|
2121
2191
|
for (const type of events) {
|
|
2122
2192
|
const handler = (e) => {
|
|
2123
|
-
this.dispatchEvent(new (0,
|
|
2193
|
+
this.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)(type, this, e));
|
|
2124
2194
|
};
|
|
2125
2195
|
this.domElement.addEventListener(type, handler);
|
|
2126
2196
|
this.domListeners.push({ type, handler, capture: false });
|
|
@@ -2131,7 +2201,7 @@ var DOMPortalEntity = (_class7 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
2131
2201
|
];
|
|
2132
2202
|
for (const { native, vecto } of hoverEvents) {
|
|
2133
2203
|
const handler = (e) => {
|
|
2134
|
-
this.dispatchEvent(new (0,
|
|
2204
|
+
this.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)(vecto, this, e, false));
|
|
2135
2205
|
};
|
|
2136
2206
|
this.domElement.addEventListener(native, handler);
|
|
2137
2207
|
this.domListeners.push({ type: native, handler, capture: false });
|
|
@@ -2139,7 +2209,7 @@ var DOMPortalEntity = (_class7 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
2139
2209
|
const focusEvents = ["focus", "blur"];
|
|
2140
2210
|
for (const type of focusEvents) {
|
|
2141
2211
|
const handler = (e) => {
|
|
2142
|
-
this.dispatchEvent(new (0,
|
|
2212
|
+
this.dispatchEvent(new (0, _chunkKPWVPGHRjs.VectoJSEvent)(type, this, e, true));
|
|
2143
2213
|
};
|
|
2144
2214
|
this.domElement.addEventListener(type, handler, true);
|
|
2145
2215
|
this.domListeners.push({ type, handler, capture: true });
|
|
@@ -2147,22 +2217,15 @@ var DOMPortalEntity = (_class7 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
2147
2217
|
}
|
|
2148
2218
|
}
|
|
2149
2219
|
isPointInside(globalX, globalY) {
|
|
2150
|
-
const pos = this.getGlobalPosition();
|
|
2151
|
-
const scale = this.getWorldScale();
|
|
2152
|
-
const rot = this.getWorldRotation();
|
|
2153
|
-
const dx = globalX - pos.x;
|
|
2154
|
-
const dy = globalY - pos.y;
|
|
2155
|
-
const cos = Math.cos(-rot);
|
|
2156
|
-
const sin = Math.sin(-rot);
|
|
2157
|
-
const lx = (dx * cos - dy * sin) / scale.x;
|
|
2158
|
-
const ly = (dx * sin + dy * cos) / scale.y;
|
|
2159
2220
|
const w = this.width > 0 ? this.width : this.cachedWidth;
|
|
2160
2221
|
const h = this.height > 0 ? this.height : this.cachedHeight;
|
|
2161
|
-
|
|
2222
|
+
const local = this.worldToLocal(globalX, globalY);
|
|
2223
|
+
if (!local) return false;
|
|
2224
|
+
return local.x >= 0 && local.x <= w && local.y >= 0 && local.y <= h;
|
|
2162
2225
|
}
|
|
2163
|
-
add(
|
|
2226
|
+
add(_child) {
|
|
2164
2227
|
console.warn(`DOMPortalEntity (${this.id}) is a leaf node. Child entities are not supported.`);
|
|
2165
|
-
return
|
|
2228
|
+
return this;
|
|
2166
2229
|
}
|
|
2167
2230
|
render() {
|
|
2168
2231
|
}
|
|
@@ -2185,8 +2248,10 @@ var DOMPortalEntity = (_class7 = class extends _chunkLA3FJLP2js.Entity {
|
|
|
2185
2248
|
}, _class7);
|
|
2186
2249
|
|
|
2187
2250
|
// src/index.ts
|
|
2188
|
-
Scene.registerWebGLPointRendererCreator(
|
|
2189
|
-
Scene.registerWebGPUParticleSystemManager(
|
|
2251
|
+
Scene.registerWebGLPointRendererCreator(_chunkTXA3LZDMjs.createWebGLPointRenderer);
|
|
2252
|
+
Scene.registerWebGPUParticleSystemManager(_chunkTXA3LZDMjs.WebGPUParticleSystemManager);
|
|
2253
|
+
|
|
2254
|
+
|
|
2190
2255
|
|
|
2191
2256
|
|
|
2192
2257
|
|
|
@@ -2229,4 +2294,4 @@ Scene.registerWebGPUParticleSystemManager(_chunkLIX7DJTIjs.WebGPUParticleSystemM
|
|
|
2229
2294
|
|
|
2230
2295
|
|
|
2231
2296
|
|
|
2232
|
-
exports.ArabicShaper =
|
|
2297
|
+
exports.ArabicShaper = _chunk6I53LI3Zjs.ArabicShaper; exports.BidiResolver = _chunk6I53LI3Zjs.BidiResolver; exports.CanvasRenderer = _chunkTXA3LZDMjs.CanvasRenderer; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DOMPortalEntity = DOMPortalEntity; exports.Easing = _chunkKPWVPGHRjs.Easing; exports.Entity = _chunkKPWVPGHRjs.Entity; exports.GridTextEntity = GridTextEntity; exports.LayoutEngine = _chunkVVOQNUBKjs.LayoutEngine; exports.LayoutResultBuffer = _chunkVVOQNUBKjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunk6I53LI3Zjs.LayoutWorkerManager; exports.MSDFFont = _chunkKPWVPGHRjs.MSDFFont; exports.MSDFTextEntity = _chunkKPWVPGHRjs.MSDFTextEntity; exports.PARTICLE_OFFSET_LIFE = PARTICLE_OFFSET_LIFE; exports.PARTICLE_OFFSET_ORIGIN_X = PARTICLE_OFFSET_ORIGIN_X; exports.PARTICLE_OFFSET_ORIGIN_Y = PARTICLE_OFFSET_ORIGIN_Y; exports.PARTICLE_OFFSET_POSITION_X = PARTICLE_OFFSET_POSITION_X; exports.PARTICLE_OFFSET_POSITION_Y = PARTICLE_OFFSET_POSITION_Y; exports.PARTICLE_OFFSET_SIZE = PARTICLE_OFFSET_SIZE; exports.PARTICLE_OFFSET_VELOCITY_X = PARTICLE_OFFSET_VELOCITY_X; exports.PARTICLE_OFFSET_VELOCITY_Y = PARTICLE_OFFSET_VELOCITY_Y; exports.PARTICLE_STRIDE_FLOATS = PARTICLE_STRIDE_FLOATS; exports.REDUCED_MOTION_FPS = REDUCED_MOTION_FPS; exports.SVGEntity = _chunkKPWVPGHRjs.SVGEntity; exports.SVGRenderer = _chunkTXA3LZDMjs.SVGRenderer; exports.Scene = Scene; exports.SpatialHashGrid = SpatialHashGrid; exports.SplineEntity = SplineEntity; exports.SpringDriver = _chunkKPWVPGHRjs.SpringDriver; exports.SpringPhysics = _chunkKPWVPGHRjs.SpringPhysics; exports.TextEntity = TextEntity; exports.TweenDriver = _chunkKPWVPGHRjs.TweenDriver; exports.VectoJSEvent = _chunkKPWVPGHRjs.VectoJSEvent; exports.WebGPUParticleSystemManager = _chunkTXA3LZDMjs.WebGPUParticleSystemManager; exports.computeLineSegments = _chunkVVOQNUBKjs.computeLineSegments; exports.createCanvasMeasurer = _chunkVVOQNUBKjs.createCanvasMeasurer; exports.createWebGLPointRenderer = _chunkTXA3LZDMjs.createWebGLPointRenderer; exports.isSafeUrl = _chunkTXA3LZDMjs.isSafeUrl; exports.isTweenConfig = _chunkKPWVPGHRjs.isTweenConfig; exports.loadSpline = loadSpline; exports.parseColorToRGBA = _chunkTXA3LZDMjs.parseColorToRGBA; exports.polySegmentToBezier = polySegmentToBezier; exports.sanitizeUrl = _chunkTXA3LZDMjs.sanitizeUrl;
|