rendx-engine 0.3.0 → 0.4.0
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/main.cjs +65 -17
- package/dist/main.d.cts +10 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.js +63 -15
- package/package.json +3 -3
package/dist/main.cjs
CHANGED
|
@@ -477,7 +477,7 @@ getEmitter_fn = function() {
|
|
|
477
477
|
};
|
|
478
478
|
|
|
479
479
|
// src/core/graphics.ts
|
|
480
|
-
var _nameMap, _classlist, _Graphics_instances, removeFromNameMap_fn, updateMat2d_fn, updateWorldMatrix_fn, updateEZ_fn;
|
|
480
|
+
var _nameMap, _classlist, _Graphics_instances, removeFromNameMap_fn, inheritState_fn, updateMat2d_fn, updateWorldMatrix_fn, updateEZ_fn;
|
|
481
481
|
var Graphics = class extends EventTarget {
|
|
482
482
|
constructor() {
|
|
483
483
|
super(...arguments);
|
|
@@ -593,6 +593,7 @@ var Graphics = class extends EventTarget {
|
|
|
593
593
|
this.children.push(child);
|
|
594
594
|
if (__privateGet(this, _nameMap).has(child.name)) throw new Error(`The name "${child.name}" is already used.`);
|
|
595
595
|
if (child.name) __privateGet(this, _nameMap).set(child.name, child);
|
|
596
|
+
__privateMethod(this, _Graphics_instances, inheritState_fn).call(this, child);
|
|
596
597
|
this.setDirty(true);
|
|
597
598
|
return this;
|
|
598
599
|
}
|
|
@@ -601,6 +602,7 @@ var Graphics = class extends EventTarget {
|
|
|
601
602
|
child.parent = this;
|
|
602
603
|
this.children.unshift(child);
|
|
603
604
|
__privateMethod(this, _Graphics_instances, removeFromNameMap_fn).call(this, child);
|
|
605
|
+
__privateMethod(this, _Graphics_instances, inheritState_fn).call(this, child);
|
|
604
606
|
this.setDirty(true);
|
|
605
607
|
return this;
|
|
606
608
|
}
|
|
@@ -843,6 +845,22 @@ _Graphics_instances = new WeakSet();
|
|
|
843
845
|
removeFromNameMap_fn = function(g) {
|
|
844
846
|
if (__privateGet(this, _nameMap).has(g.name)) __privateGet(this, _nameMap).delete(g.name);
|
|
845
847
|
};
|
|
848
|
+
/**
|
|
849
|
+
* 将父节点的可继承状态(visible / display / pointerEvents)传播给新增子节点。
|
|
850
|
+
* 模拟 DOM 中 CSS 继承属性的行为:
|
|
851
|
+
* - 父级 pointer-events: none → 子级默认继承 none,除非子级显式覆盖
|
|
852
|
+
* - 父级 visibility: hidden → 同上
|
|
853
|
+
* - 父级 display: none → 整棵子树不渲染
|
|
854
|
+
*
|
|
855
|
+
* 使用 bySelf=false 调用,尊重子节点的 autoX 标记:
|
|
856
|
+
* - autoX=true(默认)→ 接受父级值
|
|
857
|
+
* - autoX=false(子节点显式设置过)→ 保持自身值不变
|
|
858
|
+
*/
|
|
859
|
+
inheritState_fn = function(child) {
|
|
860
|
+
if (!this.visible) child.setVisible(false, false);
|
|
861
|
+
if (!this.display) child.setDisplay(false, false);
|
|
862
|
+
if (!this.pointerEvents) child.setPointerEvents(false, false);
|
|
863
|
+
};
|
|
846
864
|
updateMat2d_fn = function() {
|
|
847
865
|
if (!this.needUpdate) return;
|
|
848
866
|
import_gl_matrix.mat2d.identity(this.matrix);
|
|
@@ -1252,7 +1270,7 @@ var Group = class extends Graphics {
|
|
|
1252
1270
|
|
|
1253
1271
|
// src/scene/node.ts
|
|
1254
1272
|
var import_gl_matrix3 = require("gl-matrix");
|
|
1255
|
-
var
|
|
1273
|
+
var import_rendx_bounding16 = require("rendx-bounding");
|
|
1256
1274
|
|
|
1257
1275
|
// src/shapes/symbol.ts
|
|
1258
1276
|
var import_rendx_bounding2 = require("rendx-bounding");
|
|
@@ -1649,6 +1667,8 @@ var ArcShape = class extends Shape {
|
|
|
1649
1667
|
};
|
|
1650
1668
|
|
|
1651
1669
|
// src/shapes/path.ts
|
|
1670
|
+
var import_rendx_bounding9 = require("rendx-bounding");
|
|
1671
|
+
var import_rendx_path9 = require("rendx-path");
|
|
1652
1672
|
var PathShape = class extends Shape {
|
|
1653
1673
|
constructor() {
|
|
1654
1674
|
super(...arguments);
|
|
@@ -1657,11 +1677,19 @@ var PathShape = class extends Shape {
|
|
|
1657
1677
|
from(d) {
|
|
1658
1678
|
this.d = d;
|
|
1659
1679
|
this.p = null;
|
|
1680
|
+
if (this.autoNeedUpdate) this.needUpdate = true;
|
|
1681
|
+
}
|
|
1682
|
+
box() {
|
|
1683
|
+
const result = (0, import_rendx_path9.pathBBox)(this.d);
|
|
1684
|
+
if (result) {
|
|
1685
|
+
this.boundingBox = import_rendx_bounding9.BoundingBox.fromPoints(result[0], result[1], result[2], result[3]);
|
|
1686
|
+
}
|
|
1687
|
+
return this.boundingBox;
|
|
1660
1688
|
}
|
|
1661
1689
|
};
|
|
1662
1690
|
|
|
1663
1691
|
// src/shapes/text.ts
|
|
1664
|
-
var
|
|
1692
|
+
var import_rendx_bounding10 = require("rendx-bounding");
|
|
1665
1693
|
var _attrs;
|
|
1666
1694
|
var _TextShape = class _TextShape extends Shape {
|
|
1667
1695
|
constructor() {
|
|
@@ -1694,7 +1722,7 @@ var _TextShape = class _TextShape extends Shape {
|
|
|
1694
1722
|
if (measureFn && this.text) {
|
|
1695
1723
|
const bb = measureFn(this.text, __privateGet(this, _attrs));
|
|
1696
1724
|
if (bb) {
|
|
1697
|
-
this.boundingBox =
|
|
1725
|
+
this.boundingBox = import_rendx_bounding10.BoundingBox.fromRect(this.x, this.y - bb.height, bb.width, bb.height);
|
|
1698
1726
|
return this.boundingBox;
|
|
1699
1727
|
}
|
|
1700
1728
|
}
|
|
@@ -1725,7 +1753,7 @@ _TextShape.defaultMeasure = null;
|
|
|
1725
1753
|
var TextShape = _TextShape;
|
|
1726
1754
|
|
|
1727
1755
|
// src/shapes/line.ts
|
|
1728
|
-
var
|
|
1756
|
+
var import_rendx_bounding11 = require("rendx-bounding");
|
|
1729
1757
|
var LineShape = class extends Shape {
|
|
1730
1758
|
constructor() {
|
|
1731
1759
|
super(...arguments);
|
|
@@ -1757,13 +1785,13 @@ var LineShape = class extends Shape {
|
|
|
1757
1785
|
}
|
|
1758
1786
|
box() {
|
|
1759
1787
|
const { x1, y1, x2, y2 } = this;
|
|
1760
|
-
this.boundingBox =
|
|
1788
|
+
this.boundingBox = import_rendx_bounding11.BoundingBox.fromPoints(x1, y1, x2, y2);
|
|
1761
1789
|
return this.boundingBox;
|
|
1762
1790
|
}
|
|
1763
1791
|
};
|
|
1764
1792
|
|
|
1765
1793
|
// src/shapes/rect.ts
|
|
1766
|
-
var
|
|
1794
|
+
var import_rendx_bounding12 = require("rendx-bounding");
|
|
1767
1795
|
var RectShape = class extends Shape {
|
|
1768
1796
|
constructor() {
|
|
1769
1797
|
super(...arguments);
|
|
@@ -1793,13 +1821,13 @@ var RectShape = class extends Shape {
|
|
|
1793
1821
|
}
|
|
1794
1822
|
box() {
|
|
1795
1823
|
const { x, y, width, height } = this;
|
|
1796
|
-
this.boundingBox =
|
|
1824
|
+
this.boundingBox = import_rendx_bounding12.BoundingBox.fromRect(x, y, width, height);
|
|
1797
1825
|
return this.boundingBox;
|
|
1798
1826
|
}
|
|
1799
1827
|
};
|
|
1800
1828
|
|
|
1801
1829
|
// src/shapes/circle.ts
|
|
1802
|
-
var
|
|
1830
|
+
var import_rendx_bounding13 = require("rendx-bounding");
|
|
1803
1831
|
var CircleShape = class extends Shape {
|
|
1804
1832
|
constructor() {
|
|
1805
1833
|
super(...arguments);
|
|
@@ -1826,13 +1854,13 @@ var CircleShape = class extends Shape {
|
|
|
1826
1854
|
}
|
|
1827
1855
|
box() {
|
|
1828
1856
|
const { cx, cy, r } = this;
|
|
1829
|
-
this.boundingBox =
|
|
1857
|
+
this.boundingBox = import_rendx_bounding13.BoundingBox.fromPoints(cx - r, cy - r, cx + r, cy + r);
|
|
1830
1858
|
return this.boundingBox;
|
|
1831
1859
|
}
|
|
1832
1860
|
};
|
|
1833
1861
|
|
|
1834
1862
|
// src/shapes/image.ts
|
|
1835
|
-
var
|
|
1863
|
+
var import_rendx_bounding14 = require("rendx-bounding");
|
|
1836
1864
|
var ImageShape = class extends Shape {
|
|
1837
1865
|
constructor() {
|
|
1838
1866
|
super(...arguments);
|
|
@@ -1876,15 +1904,15 @@ var ImageShape = class extends Shape {
|
|
|
1876
1904
|
}
|
|
1877
1905
|
box() {
|
|
1878
1906
|
const { x, y, width, height } = this;
|
|
1879
|
-
this.boundingBox =
|
|
1907
|
+
this.boundingBox = import_rendx_bounding14.BoundingBox.fromRect(x, y, width, height);
|
|
1880
1908
|
return this.boundingBox;
|
|
1881
1909
|
}
|
|
1882
1910
|
};
|
|
1883
1911
|
|
|
1884
1912
|
// src/shapes/rect-buffer.ts
|
|
1885
|
-
var
|
|
1913
|
+
var import_rendx_bounding15 = require("rendx-bounding");
|
|
1886
1914
|
var import_rendx_shape8 = require("rendx-shape");
|
|
1887
|
-
var
|
|
1915
|
+
var import_rendx_path10 = require("rendx-path");
|
|
1888
1916
|
var RectBufferShape = class extends Shape {
|
|
1889
1917
|
constructor() {
|
|
1890
1918
|
super(...arguments);
|
|
@@ -1901,7 +1929,7 @@ var RectBufferShape = class extends Shape {
|
|
|
1901
1929
|
build() {
|
|
1902
1930
|
if (!this.needUpdate) return;
|
|
1903
1931
|
if (this.mode === "render") {
|
|
1904
|
-
if (!this.creator) this.creator = new
|
|
1932
|
+
if (!this.creator) this.creator = new import_rendx_path10.Path();
|
|
1905
1933
|
else this.creator.clear();
|
|
1906
1934
|
const { buffer } = this;
|
|
1907
1935
|
for (let i = 0; i < buffer.length; i += 4) {
|
|
@@ -1948,7 +1976,7 @@ var RectBufferShape = class extends Shape {
|
|
|
1948
1976
|
x1 = Math.max(x1, x + width);
|
|
1949
1977
|
y1 = Math.max(y1, y + height);
|
|
1950
1978
|
}
|
|
1951
|
-
this.boundingBox =
|
|
1979
|
+
this.boundingBox = import_rendx_bounding15.BoundingBox.fromPoints(x0, y0, x1, y1);
|
|
1952
1980
|
return this.boundingBox;
|
|
1953
1981
|
}
|
|
1954
1982
|
};
|
|
@@ -2051,7 +2079,7 @@ var _Node = class _Node extends Graphics {
|
|
|
2051
2079
|
if (wx > maxX) maxX = wx;
|
|
2052
2080
|
if (wy < minY) minY = wy;
|
|
2053
2081
|
if (wy > maxY) maxY = wy;
|
|
2054
|
-
return
|
|
2082
|
+
return import_rendx_bounding16.BoundingBox.fromPoints(minX, minY, maxX, maxY);
|
|
2055
2083
|
}
|
|
2056
2084
|
/**
|
|
2057
2085
|
* 命中检测:将屏幕坐标通过逆世界矩阵变换为本地坐标,然后检测是否命中
|
|
@@ -2997,6 +3025,26 @@ var _App = class _App {
|
|
|
2997
3025
|
plugin.resize?.(width, height);
|
|
2998
3026
|
}
|
|
2999
3027
|
}
|
|
3028
|
+
// ========================
|
|
3029
|
+
// Cursor
|
|
3030
|
+
// ========================
|
|
3031
|
+
/**
|
|
3032
|
+
* 设置容器的鼠标光标样式。
|
|
3033
|
+
* @param cursor - CSS cursor 值(如 'pointer'、'crosshair'、'grab')
|
|
3034
|
+
*/
|
|
3035
|
+
setCursor(cursor) {
|
|
3036
|
+
if (__privateGet(this, _container)) {
|
|
3037
|
+
__privateGet(this, _container).style.cursor = cursor;
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
/**
|
|
3041
|
+
* 重置鼠标光标为默认值。
|
|
3042
|
+
*/
|
|
3043
|
+
resetCursor() {
|
|
3044
|
+
if (__privateGet(this, _container)) {
|
|
3045
|
+
__privateGet(this, _container).style.cursor = "";
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3000
3048
|
clear() {
|
|
3001
3049
|
if (__privateGet(this, _rafId) !== null) {
|
|
3002
3050
|
cancelAnimationFrame(__privateGet(this, _rafId));
|
package/dist/main.d.cts
CHANGED
|
@@ -618,6 +618,7 @@ declare class ArcShape extends Shape {
|
|
|
618
618
|
declare class PathShape extends Shape {
|
|
619
619
|
command: "path";
|
|
620
620
|
from(d: string): void;
|
|
621
|
+
box(): BoundingBox;
|
|
621
622
|
}
|
|
622
623
|
|
|
623
624
|
/**
|
|
@@ -946,6 +947,15 @@ declare class App {
|
|
|
946
947
|
* @param height - 新高度(像素)
|
|
947
948
|
*/
|
|
948
949
|
resize(width: number, height: number): void;
|
|
950
|
+
/**
|
|
951
|
+
* 设置容器的鼠标光标样式。
|
|
952
|
+
* @param cursor - CSS cursor 值(如 'pointer'、'crosshair'、'grab')
|
|
953
|
+
*/
|
|
954
|
+
setCursor(cursor: string): void;
|
|
955
|
+
/**
|
|
956
|
+
* 重置鼠标光标为默认值。
|
|
957
|
+
*/
|
|
958
|
+
resetCursor(): void;
|
|
949
959
|
clear(): void;
|
|
950
960
|
dispose(): void;
|
|
951
961
|
/** 将所有渲染层合成到一个 Canvas 上并返回 */
|
package/dist/main.d.ts
CHANGED
|
@@ -618,6 +618,7 @@ declare class ArcShape extends Shape {
|
|
|
618
618
|
declare class PathShape extends Shape {
|
|
619
619
|
command: "path";
|
|
620
620
|
from(d: string): void;
|
|
621
|
+
box(): BoundingBox;
|
|
621
622
|
}
|
|
622
623
|
|
|
623
624
|
/**
|
|
@@ -946,6 +947,15 @@ declare class App {
|
|
|
946
947
|
* @param height - 新高度(像素)
|
|
947
948
|
*/
|
|
948
949
|
resize(width: number, height: number): void;
|
|
950
|
+
/**
|
|
951
|
+
* 设置容器的鼠标光标样式。
|
|
952
|
+
* @param cursor - CSS cursor 值(如 'pointer'、'crosshair'、'grab')
|
|
953
|
+
*/
|
|
954
|
+
setCursor(cursor: string): void;
|
|
955
|
+
/**
|
|
956
|
+
* 重置鼠标光标为默认值。
|
|
957
|
+
*/
|
|
958
|
+
resetCursor(): void;
|
|
949
959
|
clear(): void;
|
|
950
960
|
dispose(): void;
|
|
951
961
|
/** 将所有渲染层合成到一个 Canvas 上并返回 */
|
package/dist/main.js
CHANGED
|
@@ -403,7 +403,7 @@ getEmitter_fn = function() {
|
|
|
403
403
|
};
|
|
404
404
|
|
|
405
405
|
// src/core/graphics.ts
|
|
406
|
-
var _nameMap, _classlist, _Graphics_instances, removeFromNameMap_fn, updateMat2d_fn, updateWorldMatrix_fn, updateEZ_fn;
|
|
406
|
+
var _nameMap, _classlist, _Graphics_instances, removeFromNameMap_fn, inheritState_fn, updateMat2d_fn, updateWorldMatrix_fn, updateEZ_fn;
|
|
407
407
|
var Graphics = class extends EventTarget {
|
|
408
408
|
constructor() {
|
|
409
409
|
super(...arguments);
|
|
@@ -519,6 +519,7 @@ var Graphics = class extends EventTarget {
|
|
|
519
519
|
this.children.push(child);
|
|
520
520
|
if (__privateGet(this, _nameMap).has(child.name)) throw new Error(`The name "${child.name}" is already used.`);
|
|
521
521
|
if (child.name) __privateGet(this, _nameMap).set(child.name, child);
|
|
522
|
+
__privateMethod(this, _Graphics_instances, inheritState_fn).call(this, child);
|
|
522
523
|
this.setDirty(true);
|
|
523
524
|
return this;
|
|
524
525
|
}
|
|
@@ -527,6 +528,7 @@ var Graphics = class extends EventTarget {
|
|
|
527
528
|
child.parent = this;
|
|
528
529
|
this.children.unshift(child);
|
|
529
530
|
__privateMethod(this, _Graphics_instances, removeFromNameMap_fn).call(this, child);
|
|
531
|
+
__privateMethod(this, _Graphics_instances, inheritState_fn).call(this, child);
|
|
530
532
|
this.setDirty(true);
|
|
531
533
|
return this;
|
|
532
534
|
}
|
|
@@ -769,6 +771,22 @@ _Graphics_instances = new WeakSet();
|
|
|
769
771
|
removeFromNameMap_fn = function(g) {
|
|
770
772
|
if (__privateGet(this, _nameMap).has(g.name)) __privateGet(this, _nameMap).delete(g.name);
|
|
771
773
|
};
|
|
774
|
+
/**
|
|
775
|
+
* 将父节点的可继承状态(visible / display / pointerEvents)传播给新增子节点。
|
|
776
|
+
* 模拟 DOM 中 CSS 继承属性的行为:
|
|
777
|
+
* - 父级 pointer-events: none → 子级默认继承 none,除非子级显式覆盖
|
|
778
|
+
* - 父级 visibility: hidden → 同上
|
|
779
|
+
* - 父级 display: none → 整棵子树不渲染
|
|
780
|
+
*
|
|
781
|
+
* 使用 bySelf=false 调用,尊重子节点的 autoX 标记:
|
|
782
|
+
* - autoX=true(默认)→ 接受父级值
|
|
783
|
+
* - autoX=false(子节点显式设置过)→ 保持自身值不变
|
|
784
|
+
*/
|
|
785
|
+
inheritState_fn = function(child) {
|
|
786
|
+
if (!this.visible) child.setVisible(false, false);
|
|
787
|
+
if (!this.display) child.setDisplay(false, false);
|
|
788
|
+
if (!this.pointerEvents) child.setPointerEvents(false, false);
|
|
789
|
+
};
|
|
772
790
|
updateMat2d_fn = function() {
|
|
773
791
|
if (!this.needUpdate) return;
|
|
774
792
|
mat2d.identity(this.matrix);
|
|
@@ -1178,7 +1196,7 @@ var Group = class extends Graphics {
|
|
|
1178
1196
|
|
|
1179
1197
|
// src/scene/node.ts
|
|
1180
1198
|
import { mat2d as mat2d3, vec2 as vec23 } from "gl-matrix";
|
|
1181
|
-
import { BoundingBox as
|
|
1199
|
+
import { BoundingBox as BoundingBox16 } from "rendx-bounding";
|
|
1182
1200
|
|
|
1183
1201
|
// src/shapes/symbol.ts
|
|
1184
1202
|
import { BoundingBox as BoundingBox2 } from "rendx-bounding";
|
|
@@ -1575,6 +1593,8 @@ var ArcShape = class extends Shape {
|
|
|
1575
1593
|
};
|
|
1576
1594
|
|
|
1577
1595
|
// src/shapes/path.ts
|
|
1596
|
+
import { BoundingBox as BoundingBox9 } from "rendx-bounding";
|
|
1597
|
+
import { pathBBox } from "rendx-path";
|
|
1578
1598
|
var PathShape = class extends Shape {
|
|
1579
1599
|
constructor() {
|
|
1580
1600
|
super(...arguments);
|
|
@@ -1583,11 +1603,19 @@ var PathShape = class extends Shape {
|
|
|
1583
1603
|
from(d) {
|
|
1584
1604
|
this.d = d;
|
|
1585
1605
|
this.p = null;
|
|
1606
|
+
if (this.autoNeedUpdate) this.needUpdate = true;
|
|
1607
|
+
}
|
|
1608
|
+
box() {
|
|
1609
|
+
const result = pathBBox(this.d);
|
|
1610
|
+
if (result) {
|
|
1611
|
+
this.boundingBox = BoundingBox9.fromPoints(result[0], result[1], result[2], result[3]);
|
|
1612
|
+
}
|
|
1613
|
+
return this.boundingBox;
|
|
1586
1614
|
}
|
|
1587
1615
|
};
|
|
1588
1616
|
|
|
1589
1617
|
// src/shapes/text.ts
|
|
1590
|
-
import { BoundingBox as
|
|
1618
|
+
import { BoundingBox as BoundingBox10 } from "rendx-bounding";
|
|
1591
1619
|
var _attrs;
|
|
1592
1620
|
var _TextShape = class _TextShape extends Shape {
|
|
1593
1621
|
constructor() {
|
|
@@ -1620,7 +1648,7 @@ var _TextShape = class _TextShape extends Shape {
|
|
|
1620
1648
|
if (measureFn && this.text) {
|
|
1621
1649
|
const bb = measureFn(this.text, __privateGet(this, _attrs));
|
|
1622
1650
|
if (bb) {
|
|
1623
|
-
this.boundingBox =
|
|
1651
|
+
this.boundingBox = BoundingBox10.fromRect(this.x, this.y - bb.height, bb.width, bb.height);
|
|
1624
1652
|
return this.boundingBox;
|
|
1625
1653
|
}
|
|
1626
1654
|
}
|
|
@@ -1651,7 +1679,7 @@ _TextShape.defaultMeasure = null;
|
|
|
1651
1679
|
var TextShape = _TextShape;
|
|
1652
1680
|
|
|
1653
1681
|
// src/shapes/line.ts
|
|
1654
|
-
import { BoundingBox as
|
|
1682
|
+
import { BoundingBox as BoundingBox11 } from "rendx-bounding";
|
|
1655
1683
|
var LineShape = class extends Shape {
|
|
1656
1684
|
constructor() {
|
|
1657
1685
|
super(...arguments);
|
|
@@ -1683,13 +1711,13 @@ var LineShape = class extends Shape {
|
|
|
1683
1711
|
}
|
|
1684
1712
|
box() {
|
|
1685
1713
|
const { x1, y1, x2, y2 } = this;
|
|
1686
|
-
this.boundingBox =
|
|
1714
|
+
this.boundingBox = BoundingBox11.fromPoints(x1, y1, x2, y2);
|
|
1687
1715
|
return this.boundingBox;
|
|
1688
1716
|
}
|
|
1689
1717
|
};
|
|
1690
1718
|
|
|
1691
1719
|
// src/shapes/rect.ts
|
|
1692
|
-
import { BoundingBox as
|
|
1720
|
+
import { BoundingBox as BoundingBox12 } from "rendx-bounding";
|
|
1693
1721
|
var RectShape = class extends Shape {
|
|
1694
1722
|
constructor() {
|
|
1695
1723
|
super(...arguments);
|
|
@@ -1719,13 +1747,13 @@ var RectShape = class extends Shape {
|
|
|
1719
1747
|
}
|
|
1720
1748
|
box() {
|
|
1721
1749
|
const { x, y, width, height } = this;
|
|
1722
|
-
this.boundingBox =
|
|
1750
|
+
this.boundingBox = BoundingBox12.fromRect(x, y, width, height);
|
|
1723
1751
|
return this.boundingBox;
|
|
1724
1752
|
}
|
|
1725
1753
|
};
|
|
1726
1754
|
|
|
1727
1755
|
// src/shapes/circle.ts
|
|
1728
|
-
import { BoundingBox as
|
|
1756
|
+
import { BoundingBox as BoundingBox13 } from "rendx-bounding";
|
|
1729
1757
|
var CircleShape = class extends Shape {
|
|
1730
1758
|
constructor() {
|
|
1731
1759
|
super(...arguments);
|
|
@@ -1752,13 +1780,13 @@ var CircleShape = class extends Shape {
|
|
|
1752
1780
|
}
|
|
1753
1781
|
box() {
|
|
1754
1782
|
const { cx, cy, r } = this;
|
|
1755
|
-
this.boundingBox =
|
|
1783
|
+
this.boundingBox = BoundingBox13.fromPoints(cx - r, cy - r, cx + r, cy + r);
|
|
1756
1784
|
return this.boundingBox;
|
|
1757
1785
|
}
|
|
1758
1786
|
};
|
|
1759
1787
|
|
|
1760
1788
|
// src/shapes/image.ts
|
|
1761
|
-
import { BoundingBox as
|
|
1789
|
+
import { BoundingBox as BoundingBox14 } from "rendx-bounding";
|
|
1762
1790
|
var ImageShape = class extends Shape {
|
|
1763
1791
|
constructor() {
|
|
1764
1792
|
super(...arguments);
|
|
@@ -1802,13 +1830,13 @@ var ImageShape = class extends Shape {
|
|
|
1802
1830
|
}
|
|
1803
1831
|
box() {
|
|
1804
1832
|
const { x, y, width, height } = this;
|
|
1805
|
-
this.boundingBox =
|
|
1833
|
+
this.boundingBox = BoundingBox14.fromRect(x, y, width, height);
|
|
1806
1834
|
return this.boundingBox;
|
|
1807
1835
|
}
|
|
1808
1836
|
};
|
|
1809
1837
|
|
|
1810
1838
|
// src/shapes/rect-buffer.ts
|
|
1811
|
-
import { BoundingBox as
|
|
1839
|
+
import { BoundingBox as BoundingBox15 } from "rendx-bounding";
|
|
1812
1840
|
import { createShape as createShape7 } from "rendx-shape";
|
|
1813
1841
|
import { Path as Path9 } from "rendx-path";
|
|
1814
1842
|
var RectBufferShape = class extends Shape {
|
|
@@ -1874,7 +1902,7 @@ var RectBufferShape = class extends Shape {
|
|
|
1874
1902
|
x1 = Math.max(x1, x + width);
|
|
1875
1903
|
y1 = Math.max(y1, y + height);
|
|
1876
1904
|
}
|
|
1877
|
-
this.boundingBox =
|
|
1905
|
+
this.boundingBox = BoundingBox15.fromPoints(x0, y0, x1, y1);
|
|
1878
1906
|
return this.boundingBox;
|
|
1879
1907
|
}
|
|
1880
1908
|
};
|
|
@@ -1977,7 +2005,7 @@ var _Node = class _Node extends Graphics {
|
|
|
1977
2005
|
if (wx > maxX) maxX = wx;
|
|
1978
2006
|
if (wy < minY) minY = wy;
|
|
1979
2007
|
if (wy > maxY) maxY = wy;
|
|
1980
|
-
return
|
|
2008
|
+
return BoundingBox16.fromPoints(minX, minY, maxX, maxY);
|
|
1981
2009
|
}
|
|
1982
2010
|
/**
|
|
1983
2011
|
* 命中检测:将屏幕坐标通过逆世界矩阵变换为本地坐标,然后检测是否命中
|
|
@@ -2923,6 +2951,26 @@ var _App = class _App {
|
|
|
2923
2951
|
plugin.resize?.(width, height);
|
|
2924
2952
|
}
|
|
2925
2953
|
}
|
|
2954
|
+
// ========================
|
|
2955
|
+
// Cursor
|
|
2956
|
+
// ========================
|
|
2957
|
+
/**
|
|
2958
|
+
* 设置容器的鼠标光标样式。
|
|
2959
|
+
* @param cursor - CSS cursor 值(如 'pointer'、'crosshair'、'grab')
|
|
2960
|
+
*/
|
|
2961
|
+
setCursor(cursor) {
|
|
2962
|
+
if (__privateGet(this, _container)) {
|
|
2963
|
+
__privateGet(this, _container).style.cursor = cursor;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
/**
|
|
2967
|
+
* 重置鼠标光标为默认值。
|
|
2968
|
+
*/
|
|
2969
|
+
resetCursor() {
|
|
2970
|
+
if (__privateGet(this, _container)) {
|
|
2971
|
+
__privateGet(this, _container).style.cursor = "";
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2926
2974
|
clear() {
|
|
2927
2975
|
if (__privateGet(this, _rafId) !== null) {
|
|
2928
2976
|
cancelAnimationFrame(__privateGet(this, _rafId));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rendx-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "2D scene graph engine with animation, events, and plugin system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "wei.liang (https://github.com/weiliang0121)",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"rendx-canvas": "^0.1.1",
|
|
37
37
|
"rendx-ease": "^0.1.1",
|
|
38
38
|
"rendx-interpolate": "^0.1.1",
|
|
39
|
-
"rendx-path": "^0.
|
|
40
|
-
"rendx-shape": "^0.1.
|
|
39
|
+
"rendx-path": "^0.2.0",
|
|
40
|
+
"rendx-shape": "^0.1.2",
|
|
41
41
|
"rendx-svg": "^0.1.1",
|
|
42
42
|
"rendx-core": "^0.1.1"
|
|
43
43
|
},
|