A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(render): filled polygons and joined strokes as a path on a mesh
yhh18a2654bb3c7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 113b74885..d4b1ddcc1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ published separately; it ships inside the editor.### Added+- **Filled polygons and joined strokes.** `setPath(app, entity, points, style)` draws a path on a MeshRenderer: an ear-clipped fill of any simple polygon (concave ones, holes), and a stroke with mitered, rounded or bevelled corners and butt, round or square caps that does not overlap itself at a corner, so a translucent line is even; `feather` fades the outer edge for a quality level without multisampling. It sorts, batches and saves with the scene like any mesh. `Graphics` still fills only rects and circles; `buildPathGeometry`, `cubicBezier`, `quadraticBezier` and `circlePoints` are the pieces. The same picture on WebGL2 and WebGPU.- **Toon and Matcap materials.** `builtin:toon` lights in steps: each lamp's light is cut into flat bands with a shade colour where no lamp reaches, a flat highlight and a rim, and a lamp's shadow is part of its step; the same picture on WebGL2 and WebGPU. `builtin:matcap` shows a picture of a lit sphere looked up by the way the surface faces the camera, with no lamp asked and one texture read, for phones.- **Drawing only the frames that can look different.** `quality.renderOnDemand` (off unless a game turns it on): a still screen costs the game's logic and nothing else. A frame is drawn when the player did something (a key, a button, a finger, the pointer moved), the surface changed size, entities were created or destroyed, shaders are still compiling, or the game asked (`app.pipeline.demand.request()`), and for `renderOnDemandTail` frames (30) after the last of those; `demand.hold()` keeps every frame drawn while a tween, a video or an animation the engine cannot see move is playing. On the UI template a still screen made 11,600 draw calls in 3 seconds before and none with this on, and a click drew again at once. What the engine does not see is a script changing a value or an animation playing, which is what `request` and `hold` are for.- **Shaders that compile without stopping the frame.** `quality.asyncShaderCompile` (off unless a game turns it on): a draw whose shader the browser is still compiling is left out until it is ready, and every shader asked for in the meantime compiles at once, where before each was waited for in turn. On a first visit the Terrain & Water example's shaders took 43 seconds of a frozen page on Chrome and D3D11 (the heavy lit ones 3 to 10 seconds each, the worst frame 10 seconds); with this on the page was blocked for about a second in all and the whole scene was drawn at 20 seconds, not 56. The same scene, once everything has compiled, is the same picture. `renderer_getPendingShaders()` says how many are still compiling, for a loading screen. Off, nothing changes. WebGL2 only (a WebGPU pipeline is not compiled this way). With `quality.prewarmShaders` (and `prewarmTimeoutMs`, default 30 s) a packaged game draws its first scene out of sight behind the loading screen until nothing is compiling, and opens complete; `warmShaders(app)` does the same from code, `shadersCompiled(module)` waits for the queue, and a scene prepared ahead (`readyRenderPrograms`) now claims its programs ready only once they have compiled. The lit shaders also link about 23% faster on a first visit: a light that comes from the tiles no longer carries a second copy of the shadow lookup in the program.diff --git a/docs/astro/src/content/docs/graphics/drawing.mdx b/docs/astro/src/content/docs/graphics/drawing.mdxindex 320850ecc..473e15770 100644--- a/docs/astro/src/content/docs/graphics/drawing.mdx+++ b/docs/astro/src/content/docs/graphics/drawing.mdx@@ -89,6 +89,41 @@ Path methods: `moveTo` / `lineTo`, `curveTo` (quadratic) / `cubicCurveTo`,fill **rects and circles** (path outlines stay strokes). The path is retained —build it once, `flush()` it every frame.+## Filled polygons and joined strokes: `setPath`++`Graphics` draws immediately and fills only rects and circles. For a shape that lives in the scene (it sorts with the other renderables, batches, and a+scene saves it), or that needs an arbitrary polygon fill or a stroke with real corners, build the path's geometry and let a `MeshRenderer` draw it:++```typescript+import { setPath, circlePoints, cubicBezier } from 'esengine';++// A star with a round hole, filled orange and outlined with mitered corners.+setPath(app, entity, starPoints, {+ fill: { color: [1, 0.55, 0.1, 1], holes: [circlePoints(0, 0, 14)] },+ stroke: { color: [0.2, 0.1, 0.05, 1], width: 8, join: 'miter' },+ closed: true,+});++// An open curve with round caps and joins.+setPath(app, other, cubicBezier(p0, p1, p2, p3), {+ stroke: { color: [0.2, 0.8, 0.9, 1], width: 14, join: 'round', cap: 'round' },+});+```++`setPath` gives the entity a `MeshRenderer` if it has none and uploads the geometry; call it again with new points to change the shape (the cost is the+tessellation, and nothing while the path stands still). `buildPathGeometry(points, style)` is the same without the entity, for building geometry of your own.++| Style | Meaning |+|---|---|+| `fill: { color, holes? }` | Ear-clipped fill of any simple polygon, concave ones included. `holes` are rings cut out of it. |+| `stroke: { color, width, join?, cap?, miterLimit? }` | `join`: `'miter'` (default), `'round'`, `'bevel'`; a miter longer than `miterLimit` (4) half-widths is bevelled. `cap`: `'butt'` (default), `'round'`, `'square'`. A stroke does not overlap itself at a corner, so a translucent one is even. |+| `closed` | Joins the last point to the first: the stroke has no caps. The fill always closes. |+| `feather` | A fade to transparent over this many units along every outer edge: anti-aliasing for a quality level without multisampling. Default `0`. |+| `arcStep` | The angle one slice of a round join or cap may turn through, in radians (default `0.25`). |++`cubicBezier`, `quadraticBezier` and `circlePoints` flatten curves into the points a path takes. Self-intersecting polygons are filled by their ear clip+(a figure-eight loses its crossing), and a hole must lie inside the outline.+## Custom meshes: `MeshRenderer``MeshRenderer` is a component that renders an arbitrary indexed triangle list —diff --git a/docs/astro/src/content/docs/zh-cn/graphics/drawing.mdx b/docs/astro/src/content/docs/zh-cn/graphics/drawing.mdxindex ea1fe8ae8..59338ab89 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/drawing.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/drawing.mdx@@ -84,6 +84,38 @@ registerDrawCallback('hud-shape', () => g.flush());`lineStyle(thickness, color)` 设描边;`beginFill(color)` / `endFill()` 的填充支持**矩形和圆**(路径轮廓保持描边)。路径是保留的——构建一次,每帧 `flush()`。+## 多边形填充和带拐角的描边:`setPath`++`Graphics` 是立即模式,只填充矩形和圆。要让一个形状**留在场景里**(和别的可渲染物一起排序、合批,随场景保存),或者需要任意多边形填充、有真正拐角的描边,就生成路径的几何体,交给 `MeshRenderer` 画:++```typescript+import { setPath, circlePoints, cubicBezier } from 'esengine';++// 一颗中间有圆孔的星,橙色填充,尖角描边。+setPath(app, entity, starPoints, {+ fill: { color: [1, 0.55, 0.1, 1], holes: [circlePoints(0, 0, 14)] },+ stroke: { color: [0.2, 0.1, 0.05, 1], width: 8, join: 'miter' },+ closed: true,+});++// 一条开放曲线,圆头圆角。+setPath(app, other, cubicBezier(p0, p1, p2, p3), {+ stroke: { color: [0.2, 0.8, 0.9, 1], width: 14, join: 'round', cap: 'round' },+});+```++`setPath` 在实体没有 `MeshRenderer` 时给它加一个,并上传几何体;点变了就再调一次(代价是一次镶嵌,路径不动时不花任何东西)。`buildPathGeometry(points, style)` 是不带实体的同一件事,用来自己拼几何体。++| 样式 | 含义 |+|---|---|+| `fill: { color, holes? }` | 对任意简单多边形(含凹多边形)做耳切填充;`holes` 是挖掉的环。 |+| `stroke: { color, width, join?, cap?, miterLimit? }` | `join`:`'miter'`(默认)、`'round'`、`'bevel'`;尖角超过 `miterLimit`(4 个半宽)就改成平角。`cap`:`'butt'`(默认)、`'round'`、`'square'`。拐角处描边不会自己叠自己,半透明的也均匀。 |+| `closed` | 把最后一点连回第一点:描边没有端帽。填充总是闭合的。 |+| `feather` | 沿每条外缘向外渐隐到透明的宽度:没有多重采样的画质档用它做抗锯齿。默认 `0`。 |+| `arcStep` | 圆角或圆头每一片弧所转过的角度,弧度(默认 `0.25`)。 |++`cubicBezier`、`quadraticBezier`、`circlePoints` 把曲线展平成路径要的点。自交的多边形按耳切结果填(八字形会丢掉交叉处),孔必须在外轮廓里面。+## 自定义网格:`MeshRenderer``MeshRenderer` 组件渲染任意的索引三角形列表——程序化地形切片、径向血条弧、水面。diff --git a/fixtures/scenes/vector-paths.esscene b/fixtures/scenes/vector-paths.esscenenew file mode 100644index 000000000..673619c1e--- /dev/null+++ b/fixtures/scenes/vector-paths.esscene@@ -0,0 +1 @@+{"version":"1.0","name":"vector-paths","entities":[{"id":0,"name":"Camera","parent":null,"children":[],"visible":true,"components":[{"type":"Transform","data":{"position":{"x":0,"y":0,"z":10}}},{"type":"Camera","data":{"projectionType":1,"orthoSize":130,"isActive":true,"priority":0}}]},{"id":1,"name":"Star","parent":null,"children":[],"visible":true,"components":[{"type":"Transform","data":{"position":{"x":-250,"y":0,"z":0}}},{"type":"MeshRenderer","data":{"color":{"r":1,"g":1,"b":1,"a":1},"layer":0,"enabled":true,"geometry":{"positions":[5.5109105961630896e-15,90,-22.335839587113973,30.742645786248005,-85.59508646656381,27.811529493745276,-36.14014761921584,-11.742645786247996,-52.900672706322595,-72.81152949374525,-6.980486755139913e-15,-38,-2.5717582782094417e-15,-14,-5.357568053111264,-12.934313455158012,-9.899494936611667,-9.899494936611664,-12.934313455158016,-5.3575680531112555,-14,1.7145055188062944e-15,-12.934313455158014,5.357568053111258,-9.899494936611664,9.899494936611665,-5.357568053111256,12.934313455158014,8.572527594031472e-16,14,5.357568053111258,12.934313455158014,9.899494936611665,9.899494936611664,12.934313455158014,5.357568053111257,14,0,12.934313455158012,-5.357568053111265,9.899494936611664,-9.899494936611667,5.35756805311126,-12.934313455158012,-2.5717582782094417e-15,-14,-6.980486755139913e-15,-38,52.90067270632256,-72.81152949374528,36.14014761921583,-11.74264578624801,85.59508646656383,27.811529493745244,22.335839587113988,30.742645786247994,1.94110067258445e-15,78.65910245470413,9.080720519741729e-15,101.34089754529587,-25.150378124287567,34.61652574328313,-19.52130104994038,26.868765829212883,-74.80925195547447,24.306999420783722,-96.38092097765316,31.31605956670683,-40.694166635009125,-13.222336261498429,-31.58612860342255,-10.262955310997564,-46.23466038143776,-63.63655064813577,-59.56668503120743,-81.98650833935474,-8.25327824394178e-15,-42.78837896356937,-5.707695266338046e-15,-33.21162103643063,46.234660381437735,-63.63655064813579,59.566685031207385,-81.98650833935478,40.69416663500912,-13.222336261498445,31.586128603422544,-10.262955310997576,74.80925195547447,24.306999420783693,96.38092097765319,31.316059566706794,25.150378124287585,34.61652574328311,19.52130104994039,26.868765829212876],"colors":[1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,1,0.55,0.1,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1,0.2,0.1,0.05,1],"indices":[27,0,1,27,1,2,3,4,5,3,5,6,3,6,7,3,7,8,3,8,9,3,9,10,3,10,11,3,11,12,21,22,23,21,23,24,21,24,25,21,25,26,26,27,2,2,3,12,2,12,13,2,13,14,20,21,26,26,2,14,26,14,15,26,15,16,26,16,17,26,17,18,26,18,19,26,19,20,28,29,30,28,30,31,31,30,33,31,33,32,32,33,34,32,34,35,35,34,37,35,37,36,36,37,38,36,38,39,39,38,41,39,41,40,40,41,42,40,42,43,43,42,45,43,45,44,44,45,46,44,46,47,47,46,29,47,29,28]}}}]},{"id":2,"name":"Wave","parent":null,"children":[],"visible":true,"components":[{"type":"Transform","data":{"position":{"x":0,"y":0,"z":0}}},{"type":"MeshRenderer","data":{"color":{"r":1,"g":1,"b":1,"a":1},"layer":0,"enabled":true,"geometry":{"positions":[-106.25709608986084,3.1382715819776,-93.74290391013916,-3.1382715819776,-90.13443176675075,4.056311916923847,-102.51077784143148,10.607693093563329,-102.21151891642366,11.144224406585144,-86.57160425505329,9.832607072791067,-98.2954410881855,17.493232691433015,-97.88042446535985,18.093607037072807,-82.97962480964571,14.489653163719538,-93.80329267679036,23.379659183733477,-93.23983584178613,24.024434897460885,-79.39716933804293,18.115368474979423,-89.0103557123626,28.304987994485018,-88.27378427208069,28.95268389589952,-75.84668385634471,20.820993907747983,-83.90066142128049,32.28519503183777,-82.99191501203249,32.872555373461005,-72.31633768253708,22.73331209587744,-78.48385505933302,35.31448163686402,-77.44547016788073,35.77233420491311,-68.75191492881372,23.970704691158733,-72.81117873275934,37.381132684331575,-71.7243759652313,37.66309955024296,-65.0726722460119,24.615779850995327,-66.97255866716543,38.496227334227534,-65.92914677561843,38.59944325255738,-61.204477584618076,24.707230900900516,-61.06850923408537,38.7143574296587,-60.13745838879393,38.67431903768588,-57.105157876806395,24.25617384501319,-55.176706223271104,38.12847669645462,-54.38977688470224,37.99613084093762,-52.76776644181862,23.269610371001036,-49.33761571466697,36.84698906992442,-48.69594845981334,36.668544831112996,-48.209144654378115,21.764840104799283,-43.561083904743036,34.97356071886854,-43.04924420096591,34.7821438311365,-43.45675741403035,19.77280881809307,-37.84038188033794,32.598774466211445,-37.43761718281277,32.41476356485234,-38.53999280816635,17.33566260988241,-32.163462716104505,29.800466035797335,-31.849818058475062,29.634972439310395,-33.48603969532521,14.50302781130797,-26.519077065163902,26.647203834676112,-26.277784091350043,26.505553825625718,-28.31857269683477,11.328945708377642,-20.8991621909133,23.201771233962802,-20.717097465207544,23.08603771785525,-23.05774173697623,7.869815506812383,-15.299300277122647,19.523698227714377,-15.166670279051594,19.434303718767126,-17.72061464119338,4.183146995216757,-9.71840342279588,15.670864418698924,-9.628231125251085,15.607522908872959,-12.321681566006976,0.3268480602401125,-4.158200220301934,11.700440887428108,-4.105852338975166,11.662684667768747,-6.873270484134726,-3.6411638422549366,1.377236995190045,7.669417013497917,1.3944006454098918,7.656877008025761,6.873270484134731,3.6411638422549295,-1.3944006454098847,-7.656877008025768,-1.377236995190036,-7.6694170134979265,12.32168156600698,-0.3268480602401125,4.105852338975169,-11.662684667768751,4.158200220301933,-11.700440887428108,17.720614641193386,-4.183146995216765,9.62823112525109,-15.607522908872966,9.718403422795888,-15.670864418698931,23.057741736976215,-7.869815506812377,15.16667027905158,-19.43430371876712,15.299300277122631,-19.523698227714366,28.318572696834778,-11.328945708377645,20.717097465207544,-23.086037717855252,20.89916219091331,-23.20177123396281,33.48603969532521,-14.503027811307971,26.277784091350043,-26.505553825625725,26.519077065163902,-26.647203834676112,38.539992808166375,-17.335662609882426,31.84981805847509,-29.634972439310413,32.16346271610455,-29.80046603579736,43.45675741403036,-19.77280881809307,37.43761718281281,-32.41476356485235,37.84038188033795,-32.598774466211445,48.20914465437812,-21.764840104799283,43.0492442009659,-34.7821438311365,43.561083904743036,-34.97356071886854,52.767766441818615,-23.269610371001036,48.69594845981334,-36.668544831112996,49.337615714666974,-36.84698906992442,57.10515787680638,-24.256173845013183,54.389776884702236,-37.99613084093761,55.176706223271076,-38.128476696454605,61.20447758461807,-24.707230900900512,60.13745838879392,-38.67431903768588,61.06850923408539,-38.7143574296587,65.07267224601192,-24.61577985099531,65.92914677561846,-38.599443252557364,66.9725586671654,-38.49622733422752,68.75191492881375,-23.970704691158733,71.72437596523129,-37.66309955024297,72.81117873275936,-37.381132684331575,72.31633768253707,-22.73331209587745,77.44547016788073,-35.772334204913115,78.48385505933304,-35.31448163686402,75.84668385634471,-20.82099390774798,82.9919150120325,-32.87255537346099,83.90066142128049,-32.285195031837766,79.39716933804293,-18.115368474979416,88.27378427208069,-28.95268389589951,89.0103557123626,-28.30498799448501,82.97962480964571,-14.489653163719526,93.23983584178613,-24.02443489746088,93.80329267679033,-23.379659183733487,86.5716042550533,-9.83260707279107,97.88042446535985,-18.093607037072832,98.29544108818553,-17.49323269143301,90.13443176675075,-4.0563119169238595,102.21151891642367,-11.144224406585138,102.51077784143148,-10.607693093563334,93.74290391013916,3.138271581977599,106.25709608986084,-3.138271581977599,-100,0,-106.82631379765466,1.5496580061257386,-106.99881096016986,-0.12901606026449117,-106.76456266932274,-1.8001921821864468,-106.13718258431943,-3.3667476779120644,-105.1531317552665,-4.7376400362273134,-103.86959963946929,-5.833197976257888,-102.36118045804852,-6.58975165272029,-100.71553805094771,-6.963332915899249,-99.02831117320082,-6.932230580691445,-97.39755531812233,-6.498252201766765,-95.91804408845303,-5.686619025061091,-94.6757612990568,-4.544500220637991,100,0,106.82631379765466,-1.5496580061257337,106.99881096016986,0.1290160602644946,106.76456266932274,1.800192182186449,106.13718258431943,3.366747677912067,105.1531317552665,4.737640036227319,103.86959963946929,5.833197976257891,102.36118045804851,6.589751652720292,100.71553805094771,6.963332915899249,99.02831117320082,6.932230580691445,97.39755531812231,6.498252201766763,95.91804408845303,5.686619025061089,94.6757612990568,4.544500220637986],"colors":[0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1,0.2,0.8,0.9,1],"indices":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,0,1,2,0,2,3,4,2,5,4,5,6,7,5,8,7,8,9,10,8,11,10,11,12,13,11,14,13,14,15,16,14,17,16,17,18,19,17,20,19,20,21,22,20,23,22,23,24,25,23,26,25,26,27,28,26,29,28,29,30,31,29,32,31,32,33,34,32,35,34,35,36,37,35,38,37,38,39,40,38,41,40,41,42,43,41,44,43,44,45,46,44,47,46,47,48,49,47,50,49,50,51,52,50,53,52,53,54,55,53,56,55,56,57,58,56,59,58,59,60,61,59,63,61,63,62,62,64,66,62,66,65,65,67,69,65,69,68,68,70,72,68,72,71,71,73,75,71,75,74,74,76,78,74,78,77,77,79,81,77,81,80,80,82,84,80,84,83,83,85,87,83,87,86,86,88,90,86,90,89,89,91,93,89,93,92,92,94,96,92,96,95,95,97,99,95,99,98,98,100,102,98,102,101,101,103,105,101,105,104,104,106,108,104,108,107,107,109,111,107,111,110,110,112,114,110,114,113,113,115,117,113,117,116,116,118,120,116,120,119,119,121,123,119,123,122,124,0,125,124,125,126,124,126,127,124,127,128,124,128,129,124,129,130,124,130,131,124,131,132,124,132,133,124,133,134,124,134,135,124,135,136,124,136,1,137,123,138,137,138,139,137,139,140,137,140,141,137,141,142,137,142,143,137,143,144,137,144,145,137,145,146,137,146,147,137,147,148,137,148,149,137,149,122]}}}]},{"id":3,"name":"Hex","parent":null,"children":[],"visible":true,"components":[{"type":"Transform","data":{"position":{"x":250,"y":0,"z":0}}},{"type":"MeshRenderer","data":{"color":{"r":1,"g":1,"b":1,"a":1},"layer":0,"enabled":true,"geometry":{"positions":[80,0,40.00000000000001,69.28203230275508,-39.999999999999986,69.2820323027551,-80,9.797174393178826e-15,-40.000000000000036,-69.28203230275508,40.00000000000001,-69.28203230275508,80,0,81.73205080756888,0,40.00000000000001,69.28203230275508,40.86602540378445,70.78203230275508,-39.999999999999986,69.2820323027551,-40.86602540378443,70.7820323027551,-80,9.797174393178826e-15,-81.73205080756888,1.0352285905491404e-14,-40.000000000000036,-69.28203230275508,-40.86602540378448,-70.78203230275508,40.00000000000001,-69.28203230275508,40.86602540378445,-70.78203230275508,74.22649730810375,0,84.3301270189222,-2.5,84.3301270189222,2.5,37.11324865405188,64.28203230275508,44.3301270189222,71.78203230275508,40.00000000000001,74.28203230275508,-37.11324865405186,64.2820323027551,-39.999999999999986,74.2820323027551,-44.33012701892218,71.7820323027551,-74.22649730810375,7.946802685470233e-15,-84.3301270189222,2.5000000000000107,-84.3301270189222,-2.4999999999999885,-37.11324865405191,-64.28203230275508,-44.33012701892223,-71.78203230275508,-40.000000000000036,-74.28203230275508,37.11324865405188,-64.28203230275508,40.00000000000001,-74.28203230275508,44.3301270189222,-71.78203230275508,72.72649730810375,0,36.36324865405188,62.982994197078426,-36.36324865405186,62.98299419707844,-72.72649730810375,7.466062013874341e-15,-36.36324865405191,-62.982994197078426,36.36324865405188,-62.982994197078426,85.62916512459886,-3.25,85.62916512459886,3.25,45.629165124598856,72.53203230275508,40.00000000000001,75.78203230275508,-39.999999999999986,75.7820323027551,-45.629165124598835,72.5320323027551,-85.62916512459886,3.250000000000011,-85.62916512459886,-3.249999999999988,-45.629165124598885,-72.53203230275508,-40.000000000000036,-75.78203230275508,40.00000000000001,-75.78203230275508,45.629165124598856,-72.53203230275508],"colors":[0.4,0.4,1,0.55,0.4,0.4,1,0.55,0.4,0.4,1,0.55,0.4,0.4,1,0.55,0.4,0.4,1,0.55,0.4,0.4,1,0.55,0.4,0.4,1,0.55,0.4,0.4,1,0,0.4,0.4,1,0.55,0.4,0.4,1,0,0.4,0.4,1,0.55,0.4,0.4,1,0,0.4,0.4,1,0.55,0.4,0.4,1,0,0.4,0.4,1,0.55,0.4,0.4,1,0,0.4,0.4,1,0.55,0.4,0.4,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0],"indices":[5,0,1,5,1,2,5,2,3,5,3,4,6,7,9,6,9,8,8,9,11,8,11,10,10,11,13,10,13,12,12,13,15,12,15,14,14,15,17,14,17,16,16,17,7,16,7,6,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,18,20,22,18,22,21,21,23,25,21,25,24,24,26,28,24,28,27,27,29,31,27,31,30,30,32,34,30,34,33,33,35,19,33,19,18,18,36,37,18,37,21,21,37,38,21,38,24,24,38,39,24,39,27,27,39,40,27,40,30,30,40,41,30,41,33,33,41,36,33,36,18,19,42,43,19,43,20,20,43,44,20,44,22,22,44,45,22,45,23,23,45,46,23,46,25,25,46,47,25,47,26,26,47,48,26,48,28,28,48,49,28,49,29,29,49,50,29,50,31,31,50,51,31,51,32,32,51,52,32,52,34,34,52,53,34,53,35,35,53,42,35,42,19]}}}]}]}\ No newline at end of filediff --git a/fixtures/scenes/vector-paths.textures.json b/fixtures/scenes/vector-paths.textures.jsonnew file mode 100644index 000000000..9e26dfeeb--- /dev/null+++ b/fixtures/scenes/vector-paths.textures.json@@ -0,0 +1 @@+{}\ No newline at end of filediff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex b2a36d48d..6c506128e 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -1,7 +1,7 @@# API surface — esengine/index<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1874 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1887 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -5236,6 +5236,16 @@ Point = 0Spot = 3```+## LineCap — type @experimental+```+'butt' | 'round' | 'square'+```++## LineJoin — type @experimental+```+'miter' | 'round' | 'bevel'+```+## LinearFillDirection — type @experimental```'right' | 'left' | 'up' | 'down'@@ -6397,6 +6407,35 @@ x: numberz: number```+## PathColor — type @experimental+```+readonly [number, number, number, number]+```++## PathFill — interface @experimental+```+color: PathColor+holes: readonly (readonly Vec2[])[] | undefined+```++## PathStroke — interface @experimental+```+cap: LineCap | undefined+color: PathColor+join: LineJoin | undefined+miterLimit: number | undefined+width: number+```++## PathStyle — interface @experimental+```+arcStep: number | undefined+closed: boolean | undefined+feather: number | undefined+fill: PathFill | undefined+stroke: PathStroke | undefined+```+## Physics2D — const @beta```ResourceDef<Physics2DAPI>@@ -13038,6 +13077,11 @@ MotionDriver<AnimatorBlend2DMotion>(cells: number, flipped?: boolean): MeshData```+## buildPathGeometry — function @experimental+```+(points: readonly Vec2[], style: PathStyle): MeshRendererGeometry+```+## buildText — function @experimental```(init?: TextInit): TextData@@ -13158,6 +13202,11 @@ MotionDriver<AnimatorBlend2DMotion>(app: App): ProceduralChunks```+## circlePoints — function @experimental+```+(cx: number, cy: number, radius: number, segments?: number, startAngle?: number, endAngle?: number): Vec2[]+```+## clearAnimatorControllerStore — function @experimental```(): void@@ -13168,6 +13217,11 @@ MotionDriver<AnimatorBlend2DMotion>(): void```+## clearPath — function @experimental+```+(app: App, entity: Entity): void+```+## clearProjectSideModules — function @experimental```(): void@@ -13488,6 +13542,11 @@ Plugin(module: ESEngineModule, options?: CreateWebAppOptions): App```+## cubicBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, tolerance?: number): Vec2[]+```+## currentShare — function @experimental```(width: number, widest: number): number@@ -14588,6 +14647,11 @@ Logger(text: string, opts: MeasureTextOptions): TextMetrics```+## mergeGeometry — function @experimental+```+(parts: readonly MeshRendererGeometry[]): MeshRendererGeometry+```+## mergeMeshes — function @experimental```(parts: readonly BatchPart[]): MeshData@@ -15118,6 +15182,11 @@ PrefabsPlugin{ create(w?: number, x?: number, y?: number, z?: number): Quat; clone(a: Quat): Quat; mul(a: Quat, b: Quat): Quat; axis(axis: "x" | "y" | "z", rad: number): Quat; normalize(a: Quat): Quat; dot(a: Quat, b: Quat): number; neg(a: Quat): Quat; conjugate(a: Quat): Quat; rotate(a: Quat, v: Vec3): Vec3; toEuler(a: Quat): [number, number, number]; fromEuler(deg: readonly number[]): Quat; rotationTo(from: Vec3, to: Vec3): Quat; setAngleZ(a: Quat | undefined, deg: number): Quat; angleZ(a: Pick<Quat, "z" | "w">): number; scaled(a: Quat, t: number): Quat; }```+## quadraticBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, tolerance?: number): Vec2[]+```+## quat — const @experimental```(w?: number, x?: number, y?: number, z?: number) => Quat@@ -15683,6 +15752,11 @@ ServicesPlugin(level: LogLevel): void```+## setPath — function @experimental+```+(app: App, entity: Entity, points: readonly Vec2[], style: PathStyle): void+```+## setPlayMode — function @experimental```(active: boolean): voiddiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex b6624bdc7..4fd4545c1 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.native<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 164 beta · 1893 experimental · 3 deprecated+Symbols: 115 public · 164 beta · 1906 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -5244,6 +5244,16 @@ Point = 0Spot = 3```+## LineCap — type @experimental+```+'butt' | 'round' | 'square'+```++## LineJoin — type @experimental+```+'miter' | 'round' | 'bevel'+```+## LinearFillDirection — type @experimental```'right' | 'left' | 'up' | 'down'@@ -6600,6 +6610,35 @@ x: numberz: number```+## PathColor — type @experimental+```+readonly [number, number, number, number]+```++## PathFill — interface @experimental+```+color: PathColor+holes: readonly (readonly Vec2[])[] | undefined+```++## PathStroke — interface @experimental+```+cap: LineCap | undefined+color: PathColor+join: LineJoin | undefined+miterLimit: number | undefined+width: number+```++## PathStyle — interface @experimental+```+arcStep: number | undefined+closed: boolean | undefined+feather: number | undefined+fill: PathFill | undefined+stroke: PathStroke | undefined+```+## Physics2D — const @beta```ResourceDef<Physics2DAPI>@@ -13266,6 +13305,11 @@ MotionDriver<AnimatorBlend2DMotion>(cells: number, flipped?: boolean): MeshData```+## buildPathGeometry — function @experimental+```+(points: readonly Vec2[], style: PathStyle): MeshRendererGeometry+```+## buildText — function @experimental```(init?: TextInit): TextData@@ -13386,6 +13430,11 @@ MotionDriver<AnimatorBlend2DMotion>(app: App): ProceduralChunks```+## circlePoints — function @experimental+```+(cx: number, cy: number, radius: number, segments?: number, startAngle?: number, endAngle?: number): Vec2[]+```+## clearAnimatorControllerStore — function @experimental```(): void@@ -13396,6 +13445,11 @@ MotionDriver<AnimatorBlend2DMotion>(): void```+## clearPath — function @experimental+```+(app: App, entity: Entity): void+```+## clearProjectSideModules — function @experimental```(): void@@ -13741,6 +13795,11 @@ Plugin(module: ESEngineModule, options?: CreateWebAppOptions): App```+## cubicBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, tolerance?: number): Vec2[]+```+## currentShare — function @experimental```(width: number, widest: number): number@@ -14851,6 +14910,11 @@ Logger(text: string, opts: MeasureTextOptions): TextMetrics```+## mergeGeometry — function @experimental+```+(parts: readonly MeshRendererGeometry[]): MeshRendererGeometry+```+## mergeMeshes — function @experimental```(parts: readonly BatchPart[]): MeshData@@ -15381,6 +15445,11 @@ PrefabsPlugin{ create(w?: number, x?: number, y?: number, z?: number): Quat; clone(a: Quat): Quat; mul(a: Quat, b: Quat): Quat; axis(axis: "x" | "y" | "z", rad: number): Quat; normalize(a: Quat): Quat; dot(a: Quat, b: Quat): number; neg(a: Quat): Quat; conjugate(a: Quat): Quat; rotate(a: Quat, v: Vec3): Vec3; toEuler(a: Quat): [number, number, number]; fromEuler(deg: readonly number[]): Quat; rotationTo(from: Vec3, to: Vec3): Quat; setAngleZ(a: Quat | undefined, deg: number): Quat; angleZ(a: Pick<Quat, "z" | "w">): number; scaled(a: Quat, t: number): Quat; }```+## quadraticBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, tolerance?: number): Vec2[]+```+## quat — const @experimental```(w?: number, x?: number, y?: number, z?: number) => Quat@@ -15946,6 +16015,11 @@ ServicesPlugin(level: LogLevel): void```+## setPath — function @experimental+```+(app: App, entity: Entity, points: readonly Vec2[], style: PathStyle): void+```+## setPlayMode — function @experimental```(active: boolean): voiddiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 84c5b5c0d..c14da7ce0 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.node<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 161 beta · 1873 experimental · 3 deprecated+Symbols: 115 public · 161 beta · 1886 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -5231,6 +5231,16 @@ Point = 0Spot = 3```+## LineCap — type @experimental+```+'butt' | 'round' | 'square'+```++## LineJoin — type @experimental+```+'miter' | 'round' | 'bevel'+```+## LinearFillDirection — type @experimental```'right' | 'left' | 'up' | 'down'@@ -6392,6 +6402,35 @@ x: numberz: number```+## PathColor — type @experimental+```+readonly [number, number, number, number]+```++## PathFill — interface @experimental+```+color: PathColor+holes: readonly (readonly Vec2[])[] | undefined+```++## PathStroke — interface @experimental+```+cap: LineCap | undefined+color: PathColor+join: LineJoin | undefined+miterLimit: number | undefined+width: number+```++## PathStyle — interface @experimental+```+arcStep: number | undefined+closed: boolean | undefined+feather: number | undefined+fill: PathFill | undefined+stroke: PathStroke | undefined+```+## Physics2D — const @beta```ResourceDef<Physics2DAPI>@@ -13033,6 +13072,11 @@ MotionDriver<AnimatorBlend2DMotion>(cells: number, flipped?: boolean): MeshData```+## buildPathGeometry — function @experimental+```+(points: readonly Vec2[], style: PathStyle): MeshRendererGeometry+```+## buildText — function @experimental```(init?: TextInit): TextData@@ -13153,6 +13197,11 @@ MotionDriver<AnimatorBlend2DMotion>(app: App): ProceduralChunks```+## circlePoints — function @experimental+```+(cx: number, cy: number, radius: number, segments?: number, startAngle?: number, endAngle?: number): Vec2[]+```+## clearAnimatorControllerStore — function @experimental```(): void@@ -13163,6 +13212,11 @@ MotionDriver<AnimatorBlend2DMotion>(): void```+## clearPath — function @experimental+```+(app: App, entity: Entity): void+```+## clearProjectSideModules — function @experimental```(): void@@ -13483,6 +13537,11 @@ Plugin(module: ESEngineModule, options?: CreateWebAppOptions): App```+## cubicBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, tolerance?: number): Vec2[]+```+## currentShare — function @experimental```(width: number, widest: number): number@@ -14588,6 +14647,11 @@ Logger(text: string, opts: MeasureTextOptions): TextMetrics```+## mergeGeometry — function @experimental+```+(parts: readonly MeshRendererGeometry[]): MeshRendererGeometry+```+## mergeMeshes — function @experimental```(parts: readonly BatchPart[]): MeshData@@ -15123,6 +15187,11 @@ PrefabsPlugin{ create(w?: number, x?: number, y?: number, z?: number): Quat; clone(a: Quat): Quat; mul(a: Quat, b: Quat): Quat; axis(axis: "x" | "y" | "z", rad: number): Quat; normalize(a: Quat): Quat; dot(a: Quat, b: Quat): number; neg(a: Quat): Quat; conjugate(a: Quat): Quat; rotate(a: Quat, v: Vec3): Vec3; toEuler(a: Quat): [number, number, number]; fromEuler(deg: readonly number[]): Quat; rotationTo(from: Vec3, to: Vec3): Quat; setAngleZ(a: Quat | undefined, deg: number): Quat; angleZ(a: Pick<Quat, "z" | "w">): number; scaled(a: Quat, t: number): Quat; }```+## quadraticBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, tolerance?: number): Vec2[]+```+## quat — const @experimental```(w?: number, x?: number, y?: number, z?: number) => Quat@@ -15688,6 +15757,11 @@ ServicesPlugin(level: LogLevel): void```+## setPath — function @experimental+```+(app: App, entity: Entity, points: readonly Vec2[], style: PathStyle): void+```+## setPlayMode — function @experimental```(active: boolean): voiddiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 7a1968eba..53b6c461e 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -1,7 +1,7 @@# API surface — esengine/minigame<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1895 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1908 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -5231,6 +5231,16 @@ Point = 0Spot = 3```+## LineCap — type @experimental+```+'butt' | 'round' | 'square'+```++## LineJoin — type @experimental+```+'miter' | 'round' | 'bevel'+```+## LinearFillDirection — type @experimental```'right' | 'left' | 'up' | 'down'@@ -6685,6 +6695,35 @@ x: numberz: number```+## PathColor — type @experimental+```+readonly [number, number, number, number]+```++## PathFill — interface @experimental+```+color: PathColor+holes: readonly (readonly Vec2[])[] | undefined+```++## PathStroke — interface @experimental+```+cap: LineCap | undefined+color: PathColor+join: LineJoin | undefined+miterLimit: number | undefined+width: number+```++## PathStyle — interface @experimental+```+arcStep: number | undefined+closed: boolean | undefined+feather: number | undefined+fill: PathFill | undefined+stroke: PathStroke | undefined+```+## Physics2D — const @beta```ResourceDef<Physics2DAPI>@@ -13332,6 +13371,11 @@ MotionDriver<AnimatorBlend2DMotion>(cells: number, flipped?: boolean): MeshData```+## buildPathGeometry — function @experimental+```+(points: readonly Vec2[], style: PathStyle): MeshRendererGeometry+```+## buildText — function @experimental```(init?: TextInit): TextData@@ -13452,6 +13496,11 @@ MotionDriver<AnimatorBlend2DMotion>(app: App): ProceduralChunks```+## circlePoints — function @experimental+```+(cx: number, cy: number, radius: number, segments?: number, startAngle?: number, endAngle?: number): Vec2[]+```+## clearAnimatorControllerStore — function @experimental```(): void@@ -13462,6 +13511,11 @@ MotionDriver<AnimatorBlend2DMotion>(): void```+## clearPath — function @experimental+```+(app: App, entity: Entity): void+```+## clearProjectSideModules — function @experimental```(): void@@ -13787,6 +13841,11 @@ Plugin(module: ESEngineModule, options?: CreateWebAppOptions): App```+## cubicBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, tolerance?: number): Vec2[]+```+## currentShare — function @experimental```(width: number, widest: number): number@@ -14897,6 +14956,11 @@ Logger(text: string, opts: MeasureTextOptions): TextMetrics```+## mergeGeometry — function @experimental+```+(parts: readonly MeshRendererGeometry[]): MeshRendererGeometry+```+## mergeMeshes — function @experimental```(parts: readonly BatchPart[]): MeshData@@ -15427,6 +15491,11 @@ PrefabsPlugin{ create(w?: number, x?: number, y?: number, z?: number): Quat; clone(a: Quat): Quat; mul(a: Quat, b: Quat): Quat; axis(axis: "x" | "y" | "z", rad: number): Quat; normalize(a: Quat): Quat; dot(a: Quat, b: Quat): number; neg(a: Quat): Quat; conjugate(a: Quat): Quat; rotate(a: Quat, v: Vec3): Vec3; toEuler(a: Quat): [number, number, number]; fromEuler(deg: readonly number[]): Quat; rotationTo(from: Vec3, to: Vec3): Quat; setAngleZ(a: Quat | undefined, deg: number): Quat; angleZ(a: Pick<Quat, "z" | "w">): number; scaled(a: Quat, t: number): Quat; }```+## quadraticBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, tolerance?: number): Vec2[]+```+## quat — const @experimental```(w?: number, x?: number, y?: number, z?: number) => Quat@@ -15992,6 +16061,11 @@ ServicesPlugin(level: LogLevel): void```+## setPath — function @experimental+```+(app: App, entity: Entity, points: readonly Vec2[], style: PathStyle): void+```+## setPlayMode — function @experimental```(active: boolean): voiddiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex cd0bc2fe7..5c942f1ee 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -1,7 +1,7 @@# API surface — esengine/wechat<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1886 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1899 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -5238,6 +5238,16 @@ Point = 0Spot = 3```+## LineCap — type @experimental+```+'butt' | 'round' | 'square'+```++## LineJoin — type @experimental+```+'miter' | 'round' | 'bevel'+```+## LinearFillDirection — type @experimental```'right' | 'left' | 'up' | 'down'@@ -6399,6 +6409,35 @@ x: numberz: number```+## PathColor — type @experimental+```+readonly [number, number, number, number]+```++## PathFill — interface @experimental+```+color: PathColor+holes: readonly (readonly Vec2[])[] | undefined+```++## PathStroke — interface @experimental+```+cap: LineCap | undefined+color: PathColor+join: LineJoin | undefined+miterLimit: number | undefined+width: number+```++## PathStyle — interface @experimental+```+arcStep: number | undefined+closed: boolean | undefined+feather: number | undefined+fill: PathFill | undefined+stroke: PathStroke | undefined+```+## Physics2D — const @beta```ResourceDef<Physics2DAPI>@@ -13064,6 +13103,11 @@ MotionDriver<AnimatorBlend2DMotion>(cells: number, flipped?: boolean): MeshData```+## buildPathGeometry — function @experimental+```+(points: readonly Vec2[], style: PathStyle): MeshRendererGeometry+```+## buildText — function @experimental```(init?: TextInit): TextData@@ -13184,6 +13228,11 @@ MotionDriver<AnimatorBlend2DMotion>(app: App): ProceduralChunks```+## circlePoints — function @experimental+```+(cx: number, cy: number, radius: number, segments?: number, startAngle?: number, endAngle?: number): Vec2[]+```+## clearAnimatorControllerStore — function @experimental```(): void@@ -13194,6 +13243,11 @@ MotionDriver<AnimatorBlend2DMotion>(): void```+## clearPath — function @experimental+```+(app: App, entity: Entity): void+```+## clearProjectSideModules — function @experimental```(): void@@ -13514,6 +13568,11 @@ Plugin(module: ESEngineModule, options?: CreateWebAppOptions): App```+## cubicBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, tolerance?: number): Vec2[]+```+## currentShare — function @experimental```(width: number, widest: number): number@@ -14624,6 +14683,11 @@ Logger(text: string, opts: MeasureTextOptions): TextMetrics```+## mergeGeometry — function @experimental+```+(parts: readonly MeshRendererGeometry[]): MeshRendererGeometry+```+## mergeMeshes — function @experimental```(parts: readonly BatchPart[]): MeshData@@ -15154,6 +15218,11 @@ PrefabsPlugin{ create(w?: number, x?: number, y?: number, z?: number): Quat; clone(a: Quat): Quat; mul(a: Quat, b: Quat): Quat; axis(axis: "x" | "y" | "z", rad: number): Quat; normalize(a: Quat): Quat; dot(a: Quat, b: Quat): number; neg(a: Quat): Quat; conjugate(a: Quat): Quat; rotate(a: Quat, v: Vec3): Vec3; toEuler(a: Quat): [number, number, number]; fromEuler(deg: readonly number[]): Quat; rotationTo(from: Vec3, to: Vec3): Quat; setAngleZ(a: Quat | undefined, deg: number): Quat; angleZ(a: Pick<Quat, "z" | "w">): number; scaled(a: Quat, t: number): Quat; }```+## quadraticBezier — function @experimental+```+(p0: Vec2, p1: Vec2, p2: Vec2, tolerance?: number): Vec2[]+```+## quat — const @experimental```(w?: number, x?: number, y?: number, z?: number) => Quat@@ -15719,6 +15788,11 @@ ServicesPlugin(level: LogLevel): void```+## setPath — function @experimental+```+(app: App, entity: Entity, points: readonly Vec2[], style: PathStyle): void+```+## setPlayMode — function @experimental```(active: boolean): voiddiff --git a/sdk/src/core-render.ts b/sdk/src/core-render.tsindex 66762a8a8..c330bbca7 100644--- a/sdk/src/core-render.ts+++ b/sdk/src/core-render.ts@@ -343,5 +343,8 @@ export type {export { Quality } from './render/qualityRuntime';export { warmShaders, shadersCompiled, pendingShaders } from './render/shaderWarmup';export { RenderDemand } from './render/renderDemand';+export { buildPathGeometry, mergeGeometry, cubicBezier, quadraticBezier, circlePoints } from './render/vectorPath';+export type { PathStyle, PathFill, PathStroke, PathColor, LineJoin, LineCap } from './render/vectorPath';+export { setPath, clearPath } from './render/pathRenderer';export type { RenderOnDemandOptions } from './render/renderDemand';export type { ShaderWarmup, ShaderWarmupOptions } from './render/shaderWarmup';diff --git a/sdk/src/render/pathRenderer.ts b/sdk/src/render/pathRenderer.tsnew file mode 100644index 000000000..8d6307271--- /dev/null+++ b/sdk/src/render/pathRenderer.ts@@ -0,0 +1,34 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file pathRenderer.ts+ * @brief Drawing a path on an entity: the points in, a MeshRenderer's geometry out.+ *+ * The geometry belongs to the entity's MeshRenderer, so a path sorts, batches and clips like any other renderable and a scene saves it as the+ * mesh geometry it is. To change a path, call {@link setPath} again with the new points: the mesh is rebuilt and uploaded, which costs the+ * tessellation of the path and nothing while it stands still.+ */+import type { App } from '../app/app';+import type { Entity } from '../types';+import type { Vec2 } from '../types';+import { MeshRenderer } from '../ecs/component';+import { MeshRenderers } from './meshRenderer';+import { buildPathGeometry, type PathStyle } from './vectorPath';++/**+ * Draws `points` as a path on `entity`, giving it a MeshRenderer if it has none. An empty result (a stroke of one point) clears what was drawn.+ * @experimental+ */+export function setPath(app: App, entity: Entity, points: readonly Vec2[], style: PathStyle): void {+ const world = app.world;+ if (!world.has(entity, MeshRenderer)) world.insert(entity, MeshRenderer, { enabled: true });+ const api = app.getResource(MeshRenderers);+ const geometry = buildPathGeometry(points, style);+ if (geometry.indices.length === 0) api.clearGeometry(entity);+ else api.setGeometry(entity, geometry);+}++/** Stops drawing the path on `entity` (its MeshRenderer stays). @experimental */+export function clearPath(app: App, entity: Entity): void {+ app.getResource(MeshRenderers).clearGeometry(entity);+}diff --git a/sdk/src/render/vectorPath.ts b/sdk/src/render/vectorPath.tsnew file mode 100644index 000000000..83e4ba02b--- /dev/null+++ b/sdk/src/render/vectorPath.ts@@ -0,0 +1,500 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file vectorPath.ts+ * @brief Polygons, polylines and strokes as geometry a MeshRenderer draws.+ *+ * A path is a list of points. {@link buildPathGeometry} turns it into the triangles of its fill (ear clipping, holes allowed) and of its+ * stroke (a width, a join at every corner, a cap at each end), with an optional feathered edge standing in for anti-aliasing where the+ * quality level draws without multisampling. The result is a {@link MeshRendererGeometry}: a MeshRenderer draws it, sorts it with every other+ * renderable, batches it, and a scene saves it the way it saves any mesh geometry, so a path costs no renderer of its own.+ *+ * Pure: no engine, no DOM. Curves are flattened here ({@link cubicBezier}, {@link quadraticBezier}, {@link circlePoints}) into the points a+ * stroke and a fill take.+ */+import type { MeshRendererGeometry } from '../ecs/component';+import type { Vec2 } from '../types';++/** Red, green, blue and alpha, each 0 to 1. */+export type PathColor = readonly [number, number, number, number];++/** How two stroked segments meet at a corner. */+export type LineJoin = 'miter' | 'round' | 'bevel';+/** How an open stroke ends. */+export type LineCap = 'butt' | 'round' | 'square';++/** @experimental */+export interface PathFill {+ color: PathColor;+ /** Rings cut out of the fill. Each is a list of points inside the outline. */+ holes?: readonly (readonly Vec2[])[];+}++/** @experimental */+export interface PathStroke {+ color: PathColor;+ /** The full width of the line, in the units of the points. */+ width: number;+ join?: LineJoin;+ cap?: LineCap;+ /** How far a miter may reach, as a multiple of half the width, before the corner is bevelled instead. Default 4. */+ miterLimit?: number;+}++/** @experimental */+export interface PathStyle {+ fill?: PathFill;+ stroke?: PathStroke;+ /** The outline joins its last point back to its first: a stroke has no caps, a fill needs it either way. Default false. */+ closed?: boolean;+ /** Width of a fade to transparent along every outer edge, in the units of the points: anti-aliasing for a surface drawn without multisampling. 0 (default) draws hard edges. */+ feather?: number;+ /** How finely a round join or cap is cut, as the angle one slice may turn through, in radians. Default 0.25. */+ arcStep?: number;+}++const EPS = 1e-6;++interface Builder {+ positions: number[];+ colors: number[];+ indices: number[];+}++const newBuilder = (): Builder => ({ positions: [], colors: [], indices: [] });++function vertex(b: Builder, x: number, y: number, c: PathColor, alpha = 1): number {+ b.positions.push(x, y);+ b.colors.push(c[0], c[1], c[2], c[3] * alpha);+ return b.positions.length / 2 - 1;+}++const tri = (b: Builder, a: number, c: number, d: number): void => { b.indices.push(a, c, d); };++/** Consecutive points nearer than this are one point. */+function dedupe(points: readonly Vec2[], closed: boolean): Vec2[] {+ const out: Vec2[] = [];+ for (const p of points) {+ const last = out[out.length - 1];+ if (!last || Math.hypot(p.x - last.x, p.y - last.y) > EPS) out.push({ x: p.x, y: p.y });+ }+ if (closed && out.length > 1) {+ const first = out[0]!;+ const last = out[out.length - 1]!;+ if (Math.hypot(first.x - last.x, first.y - last.y) <= EPS) out.pop();+ }+ return out;+}++const signedArea = (ring: readonly Vec2[]): number => {+ let sum = 0;+ for (let i = 0; i < ring.length; i++) {+ const a = ring[i]!;+ const b = ring[(i + 1) % ring.length]!;+ sum += a.x * b.y - b.x * a.y;+ }+ return sum / 2;+};++// ---------------------------------------------------------------------------------------------------------------------+// Fill+// ---------------------------------------------------------------------------------------------------------------------++const cross2 = (ax: number, ay: number, bx: number, by: number): number => ax * by - ay * bx;++function segmentsCross(a: Vec2, b: Vec2, c: Vec2, d: Vec2): boolean {+ const d1 = cross2(b.x - a.x, b.y - a.y, c.x - a.x, c.y - a.y);+ const d2 = cross2(b.x - a.x, b.y - a.y, d.x - a.x, d.y - a.y);+ const d3 = cross2(d.x - c.x, d.y - c.y, a.x - c.x, a.y - c.y);+ const d4 = cross2(d.x - c.x, d.y - c.y, b.x - c.x, b.y - c.y);+ return ((d1 > EPS && d2 < -EPS) || (d1 < -EPS && d2 > EPS)) && ((d3 > EPS && d4 < -EPS) || (d3 < -EPS && d4 > EPS));+}++/**+ * Joins each hole to the outline by a bridge (the shortest segment from a hole's point to the ring that crosses no edge), so the ring and its+ * holes are one ring that visits the bridge twice. Both are made counter-clockwise (outline) and clockwise (holes) first.+ */+function bridgeHoles(outline: Vec2[], holes: readonly (readonly Vec2[])[]): Vec2[] {+ let ring = outline.slice();+ const rings = holes+ .map((h) => dedupe(h, true))+ .filter((h) => h.length >= 3)+ .map((h) => (signedArea(h) > 0 ? h.slice().reverse() : h))+ // The hole furthest right first: it cannot be hidden behind another that is joined already.+ .sort((a, b) => Math.max(...b.map((p) => p.x)) - Math.max(...a.map((p) => p.x)));+ for (const hole of rings) {+ let best: { r: number; h: number; d: number } | null = null;+ for (let h = 0; h < hole.length; h++) {+ for (let r = 0; r < ring.length; r++) {+ const d = Math.hypot(hole[h]!.x - ring[r]!.x, hole[h]!.y - ring[r]!.y);+ if (best && d >= best.d) continue;+ if (blocked(ring, rings, hole[h]!, ring[r]!)) continue;+ best = { r, h, d };+ }+ }+ if (!best) continue;+ const spliced: Vec2[] = [];+ for (let i = 0; i <= best.r; i++) spliced.push(ring[i]!);+ for (let k = 0; k <= hole.length; k++) spliced.push(hole[(best.h + k) % hole.length]!);+ spliced.push(ring[best.r]!);+ for (let i = best.r + 1; i < ring.length; i++) spliced.push(ring[i]!);+ ring = spliced;+ }+ return ring;+}++function blocked(ring: readonly Vec2[], holes: readonly (readonly Vec2[])[], a: Vec2, b: Vec2): boolean {+ const crossesRing = (pts: readonly Vec2[]): boolean => {+ for (let i = 0; i < pts.length; i++) if (segmentsCross(a, b, pts[i]!, pts[(i + 1) % pts.length]!)) return true;+ return false;+ };+ if (crossesRing(ring)) return true;+ for (const h of holes) if (crossesRing(h)) return true;+ return false;+}++function pointInTriangle(p: Vec2, a: Vec2, b: Vec2, c: Vec2): boolean {+ const d1 = cross2(b.x - a.x, b.y - a.y, p.x - a.x, p.y - a.y);+ const d2 = cross2(c.x - b.x, c.y - b.y, p.x - b.x, p.y - b.y);+ const d3 = cross2(a.x - c.x, a.y - c.y, p.x - c.x, p.y - c.y);+ return d1 >= -EPS && d2 >= -EPS && d3 >= -EPS;+}++/** Triangles (as indices into `ring`) covering a counter-clockwise ring, which may visit a point twice (a bridge). */+function earClip(ring: readonly Vec2[]): number[] {+ const n = ring.length;+ const next: number[] = [];+ const prev: number[] = [];+ for (let i = 0; i < n; i++) { next.push((i + 1) % n); prev.push((i + n - 1) % n); }+ const out: number[] = [];+ let remaining = n;+ let i = 0;+ let guard = 0;+ const same = (p: Vec2, q: Vec2): boolean => Math.abs(p.x - q.x) <= EPS && Math.abs(p.y - q.y) <= EPS;+ while (remaining > 3 && guard++ < n * n) {+ const a = prev[i]!;+ const c = next[i]!;+ const pa = ring[a]!, pb = ring[i]!, pc = ring[c]!;+ let ear = cross2(pb.x - pa.x, pb.y - pa.y, pc.x - pb.x, pc.y - pb.y) > EPS;+ if (ear) {+ for (let k = next[c]!; k !== a; k = next[k]!) {+ const q = ring[k]!;+ // A point shared with the triangle is a bridge's other end, not something in the way.+ if (same(q, pa) || same(q, pb) || same(q, pc)) continue;+ if (pointInTriangle(q, pa, pb, pc)) { ear = false; break; }+ }+ }+ if (ear) {+ out.push(a, i, c);+ next[a] = c;+ prev[c] = a;+ --remaining;+ i = c;+ guard = 0;+ } else {+ i = next[i]!;+ }+ }+ if (remaining === 3) {+ const a = prev[i]!;+ out.push(a, i, next[i]!);+ } else if (remaining > 3) {+ // No ear was found (a ring that crosses itself): fan what is left rather than lose the shape.+ for (let k = next[i]!; next[k]! !== i; k = next[k]!) out.push(i, k, next[k]!);+ }+ return out;+}++function emitFill(b: Builder, outline: readonly Vec2[], fill: PathFill, feather: number): void {+ let ring = dedupe(outline, true);+ if (ring.length < 3) return;+ if (signedArea(ring) < 0) ring = ring.slice().reverse();+ const holes = (fill.holes ?? []).map((h) => dedupe(h, true)).filter((h) => h.length >= 3);+ const joined = holes.length ? bridgeHoles(ring, holes) : ring;+ const base = b.positions.length / 2;+ for (const p of joined) vertex(b, p.x, p.y, fill.color);+ for (const i of earClip(joined)) b.indices.push(base + i);+ if (feather <= 0) return;+ // A fade outward from the outline and inward from each hole: the edge of the fill is where the colour is a half.+ fringe(b, ring, fill.color, feather, 1);+ for (const h of holes) fringe(b, signedArea(h) > 0 ? h.slice().reverse() : h, fill.color, feather, -1);+}++/** A band of transparent-to-opaque quads along a counter-clockwise ring, `side` 1 outside it and -1 inside. */+function fringe(b: Builder, ring: readonly Vec2[], color: PathColor, width: number, side: 1 | -1): void {+ const n = ring.length;+ const inner: number[] = [];+ const outer: number[] = [];+ for (let i = 0; i < n; i++) {+ const p = ring[i]!, a = ring[(i + n - 1) % n]!, c = ring[(i + 1) % n]!;+ // Outward normals of the two edges at this point (counter-clockwise: outward is to the right of travel).+ const e0x = p.x - a.x, e0y = p.y - a.y, e1x = c.x - p.x, e1y = c.y - p.y;+ const l0 = Math.hypot(e0x, e0y) || 1, l1 = Math.hypot(e1x, e1y) || 1;+ let nx = e0y / l0 + e1y / l1;+ let ny = -(e0x / l0) - e1x / l1;+ const nl = Math.hypot(nx, ny);+ if (nl < EPS) { nx = e0y / l0; ny = -e0x / l0; } else { nx /= nl; ny /= nl; }+ // Where the two edges bend sharply the offset along the bisector grows by 1 / cos(half the turn); bounded so a spike stays a spike.+ const cosHalf = Math.max(nx * (e0y / l0) + ny * (-e0x / l0), 0.3);+ const d = (width / cosHalf) * side;+ inner.push(vertex(b, p.x, p.y, color));+ outer.push(vertex(b, p.x + nx * d, p.y + ny * d, color, 0));+ }+ for (let i = 0; i < n; i++) {+ const j = (i + 1) % n;+ tri(b, inner[i]!, outer[i]!, outer[j]!);+ tri(b, inner[i]!, outer[j]!, inner[j]!);+ }+}++// ---------------------------------------------------------------------------------------------------------------------+// Stroke+// ---------------------------------------------------------------------------------------------------------------------++/** One point of a stroke's outline with the direction that points away from the line there, for the feathered edge. */+interface Edge { index: number; x: number; y: number; ox: number; oy: number }++function emitStroke(b: Builder, input: readonly Vec2[], stroke: PathStroke, closed: boolean, feather: number, arcStep: number): void {+ const pts = dedupe(input, closed);+ const half = stroke.width / 2;+ if (pts.length < 2 || half <= 0) return;+ const n = pts.length;+ const join = stroke.join ?? 'miter';+ const cap = stroke.cap ?? 'butt';+ const limit = Math.max(stroke.miterLimit ?? 4, 1);+ const color = stroke.color;+ const segs = closed ? n : n - 1;++ // Direction and left normal of each segment.+ const dx: number[] = [], dy: number[] = [], len: number[] = [];+ for (let i = 0; i < segs; i++) {+ const a = pts[i]!, c = pts[(i + 1) % n]!;+ const l = Math.hypot(c.x - a.x, c.y - a.y);+ len.push(l);+ dx.push((c.x - a.x) / l);+ dy.push((c.y - a.y) / l);+ }++ // Per point: the point on the inside of the turn, and what the outside needs. `left`/`right` chains run along the line, in order, and hold+ // each outline point with its outward direction (the feathered edge is made from them).+ const leftIn: number[] = new Array(n).fill(-1), leftOut: number[] = new Array(n).fill(-1);+ const rightIn: number[] = new Array(n).fill(-1), rightOut: number[] = new Array(n).fill(-1);+ const left: Edge[] = [];+ const right: Edge[] = [];++ const push = (chain: Edge[], x: number, y: number, ox: number, oy: number): number => {+ const index = vertex(b, x, y, color);+ chain.push({ index, x, y, ox, oy });+ return index;+ };++ for (let i = 0; i < n; i++) {+ const p = pts[i]!;+ const hasPrev = closed || i > 0;+ const hasNext = closed || i < n - 1;+ const s0 = hasPrev ? (i + segs - 1) % segs : -1;+ const s1 = hasNext ? i % segs : -1;+ if (!hasPrev || !hasNext) {+ // An end: the normal of the one segment, set back by a square cap and fanned by a round one in {@link emitCap}.+ const s = hasNext ? s1 : s0;+ const ndx = dx[s]!, ndy = dy[s]!;+ const lx = -ndy, ly = ndx;+ const back = hasNext ? -1 : 1;+ const push0 = cap === 'square' ? half * back : 0;+ const bx = p.x + ndx * push0, by = p.y + ndy * push0;+ const l = push(left, bx + lx * half, by + ly * half, lx, ly);+ const r = push(right, bx - lx * half, by - ly * half, -lx, -ly);+ leftIn[i] = leftOut[i] = l;+ rightIn[i] = rightOut[i] = r;+ continue;+ }+ const d0x = dx[s0]!, d0y = dy[s0]!, d1x = dx[s1]!, d1y = dy[s1]!;+ const turn = cross2(d0x, d0y, d1x, d1y);+ const l0x = -d0y, l0y = d0x, l1x = -d1y, l1y = d1x;+ let mx = l0x + l1x, my = l0y + l1y;+ const ml = Math.hypot(mx, my);+ if (ml < EPS) { mx = l0x; my = l0y; } else { mx /= ml; my /= ml; }+ const cosHalf = Math.max(mx * l0x + my * l0y, 1e-3);+ // The inside of the turn: one point, where the two inner edges meet, held back so a short segment is not overrun.+ const reach = Math.min(half / cosHalf, Math.max(Math.min(len[s0]!, len[s1]!) / Math.max(Math.sqrt(1 - cosHalf * cosHalf) / cosHalf, 1e-3), half));+ // turn > 0: a left turn, the left side is the inside.+ const insideLeft = turn > 0;+ const straight = Math.abs(turn) < 1e-5 && d0x * d1x + d0y * d1y > 0;+ const miterRatio = 1 / cosHalf;+ const useMiter = straight || (join === 'miter' && miterRatio <= limit);+ const sign = insideLeft ? 1 : -1; // +1: the left side is the inside+ const insideChain = insideLeft ? left : right;+ const outsideChain = insideLeft ? right : left;+ const insideIdx = insideLeft ? leftIn : rightIn, insideOut = insideLeft ? leftOut : rightOut;+ const outsideIdx = insideLeft ? rightIn : leftIn, outsideOutIdx = insideLeft ? rightOut : leftOut;+ // Inside point.+ const ip = push(insideChain, p.x + sign * mx * reach, p.y + sign * my * reach, sign * mx, sign * my);+ insideIdx[i] = insideOut[i] = ip;+ if (useMiter) {+ const oreach = half / cosHalf;+ const op = push(outsideChain, p.x - sign * mx * oreach, p.y - sign * my * oreach, -sign * mx, -sign * my);+ outsideIdx[i] = outsideOutIdx[i] = op;+ continue;+ }+ // The outside of the turn: the end of the incoming edge, an arc or nothing, the start of the outgoing one.+ const o0x = -sign * l0x, o0y = -sign * l0y, o1x = -sign * l1x, o1y = -sign * l1y;+ const first = push(outsideChain, p.x + o0x * half, p.y + o0y * half, o0x, o0y);+ outsideIdx[i] = first;+ let last = first;+ if (join === 'round') {+ const a0 = Math.atan2(o0y, o0x);+ let a1 = Math.atan2(o1y, o1x);+ let delta = a1 - a0;+ while (delta > Math.PI) delta -= Math.PI * 2;+ while (delta < -Math.PI) delta += Math.PI * 2;+ const steps = Math.max(1, Math.ceil(Math.abs(delta) / arcStep));+ let prevIdx = first;+ for (let k = 1; k < steps; k++) {+ const a = a0 + (delta * k) / steps;+ const ax = Math.cos(a), ay = Math.sin(a);+ const mid = push(outsideChain, p.x + ax * half, p.y + ay * half, ax, ay);+ tri(b, ip, prevIdx, mid);+ prevIdx = mid;+ }+ last = push(outsideChain, p.x + o1x * half, p.y + o1y * half, o1x, o1y);+ tri(b, ip, prevIdx, last);+ } else {+ // Bevel (and a miter past its limit): the two outer corners joined by a straight edge.+ last = push(outsideChain, p.x + o1x * half, p.y + o1y * half, o1x, o1y);+ tri(b, ip, first, last);+ }+ outsideOutIdx[i] = last;+ }++ // The body: a quad per segment, from the end of one point's outline to the start of the next.+ for (let s = 0; s < segs; s++) {+ const i = s, j = (s + 1) % n;+ const lA = leftOut[i]!, rA = rightOut[i]!, lB = leftIn[j]!, rB = rightIn[j]!;+ tri(b, lA, rA, rB);+ tri(b, lA, rB, lB);+ }++ // Caps.+ if (!closed && cap === 'round') {+ emitRoundCap(b, pts[0]!, -dx[0]!, -dy[0]!, half, color, arcStep, leftIn[0]!, rightIn[0]!);+ emitRoundCap(b, pts[n - 1]!, dx[segs - 1]!, dy[segs - 1]!, half, color, arcStep, rightOut[n - 1]!, leftOut[n - 1]!);+ }++ if (feather > 0) {+ // The line's edge fades over `feather` beyond the outline. A closed line has two loops (outer and inner); an open one has one outline.+ const bandEdge = (chain: readonly Edge[]): void => {+ const outs: number[] = [];+ for (const e of chain) outs.push(vertex(b, e.x + e.ox * feather, e.y + e.oy * feather, color, 0));+ for (let k = 0; k + 1 < chain.length; k++) {+ tri(b, chain[k]!.index, outs[k]!, outs[k + 1]!);+ tri(b, chain[k]!.index, outs[k + 1]!, chain[k + 1]!.index);+ }+ if (closed && chain.length > 2) {+ const k = chain.length - 1;+ tri(b, chain[k]!.index, outs[k]!, outs[0]!);+ tri(b, chain[k]!.index, outs[0]!, chain[0]!.index);+ }+ };+ bandEdge(left);+ bandEdge(right);+ if (!closed) {+ // Butt and square ends fade across the end face.+ if (cap !== 'round') {+ for (const [first, second, dirx, diry] of [+ [left[0]!, right[0]!, -dx[0]!, -dy[0]!],+ [left[left.length - 1]!, right[right.length - 1]!, dx[segs - 1]!, dy[segs - 1]!],+ ] as const) {+ const a = vertex(b, first.x + dirx * feather, first.y + diry * feather, color, 0);+ const c = vertex(b, second.x + dirx * feather, second.y + diry * feather, color, 0);+ tri(b, first.index, a, c);+ tri(b, first.index, c, second.index);+ }+ }+ }+ }+}++/** A half circle of `radius` at `center` bulging along (dirx, diry), between two outline points already placed. */+function emitRoundCap(b: Builder, center: Vec2, dirx: number, diry: number, radius: number, color: PathColor, arcStep: number, from: number, to: number): void {+ const a0 = Math.atan2(diry, dirx) - Math.PI / 2;+ const steps = Math.max(2, Math.ceil(Math.PI / arcStep));+ const c = vertex(b, center.x, center.y, color);+ let prev = from;+ for (let k = 1; k < steps; k++) {+ const a = a0 + (Math.PI * k) / steps;+ const v = vertex(b, center.x + Math.cos(a) * radius, center.y + Math.sin(a) * radius, color);+ tri(b, c, prev, v);+ prev = v;+ }+ tri(b, c, prev, to);+}++// ---------------------------------------------------------------------------------------------------------------------+// Entry points+// ---------------------------------------------------------------------------------------------------------------------++/**+ * The geometry of a path: its fill, then its stroke on top, as one mesh in the path's own coordinates.+ * An empty result (fewer than the points a shape needs) is a mesh with nothing in it, which draws nothing.+ * @experimental+ */+export function buildPathGeometry(points: readonly Vec2[], style: PathStyle): MeshRendererGeometry {+ const b = newBuilder();+ const feather = Math.max(style.feather ?? 0, 0);+ const arcStep = Math.max(style.arcStep ?? 0.25, 0.05);+ const closed = style.closed ?? false;+ if (style.fill) emitFill(b, points, style.fill, feather);+ if (style.stroke) emitStroke(b, points, style.stroke, closed, feather, arcStep);+ return { positions: b.positions, colors: b.colors, indices: b.indices };+}++/** The geometry of several paths drawn into one mesh, in order. */+export function mergeGeometry(parts: readonly MeshRendererGeometry[]): MeshRendererGeometry {+ const out: MeshRendererGeometry = { positions: [], colors: [], indices: [] };+ for (const part of parts) {+ const base = out.positions.length / 2;+ for (const v of part.positions) out.positions.push(v);+ for (const c of part.colors ?? []) out.colors!.push(c);+ for (const i of part.indices) out.indices.push(base + i);+ }+ return out;+}++/** A cubic Bezier curve as points, cut finely enough that no point is further than `tolerance` from the curve. @experimental */+export function cubicBezier(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, tolerance = 0.25): Vec2[] {+ // The flatness bound of a Bezier: the control polygon's distance from its chord says how many pieces keep the error under tolerance.+ const ux = 3 * p1.x - 2 * p0.x - p3.x, uy = 3 * p1.y - 2 * p0.y - p3.y;+ const vx = 3 * p2.x - 2 * p3.x - p0.x, vy = 3 * p2.y - 2 * p3.y - p0.y;+ const dev = Math.sqrt(Math.max(ux * ux, vx * vx) + Math.max(uy * uy, vy * vy));+ const steps = Math.min(Math.max(Math.ceil(Math.sqrt(dev / (4 * Math.max(tolerance, 1e-4)))), 1), 256);+ const out: Vec2[] = [];+ for (let i = 0; i <= steps; i++) {+ const t = i / steps, m = 1 - t;+ out.push({+ x: m * m * m * p0.x + 3 * m * m * t * p1.x + 3 * m * t * t * p2.x + t * t * t * p3.x,+ y: m * m * m * p0.y + 3 * m * m * t * p1.y + 3 * m * t * t * p2.y + t * t * t * p3.y,+ });+ }+ return out;+}++/** A quadratic Bezier curve as points. @experimental */+export function quadraticBezier(p0: Vec2, p1: Vec2, p2: Vec2, tolerance = 0.25): Vec2[] {+ // Raised to a cubic: one flattening to keep right.+ const c1 = { x: p0.x + (2 / 3) * (p1.x - p0.x), y: p0.y + (2 / 3) * (p1.y - p0.y) };+ const c2 = { x: p2.x + (2 / 3) * (p1.x - p2.x), y: p2.y + (2 / 3) * (p1.y - p2.y) };+ return cubicBezier(p0, c1, c2, p2, tolerance);+}++/** The points of a circle (or a slice of one: angles in radians, counter-clockwise from +x). @experimental */+export function circlePoints(cx: number, cy: number, radius: number, segments = 0, startAngle = 0, endAngle = Math.PI * 2): Vec2[] {+ const full = Math.abs(endAngle - startAngle) >= Math.PI * 2 - 1e-9;+ const n = segments > 0 ? segments : Math.max(Math.ceil(Math.abs(endAngle - startAngle) / Math.max(Math.acos(1 - 0.25 / Math.max(radius, 0.25)) * 2, 0.05)), 8);+ const out: Vec2[] = [];+ const count = full ? n : n + 1;+ for (let i = 0; i < count; i++) {+ const a = startAngle + ((endAngle - startAngle) * i) / n;+ out.push({ x: cx + Math.cos(a) * radius, y: cy + Math.sin(a) * radius });+ }+ return out;+}diff --git a/sdk/tests/path-renderer.test.ts b/sdk/tests/path-renderer.test.tsnew file mode 100644index 000000000..9b174c667--- /dev/null+++ b/sdk/tests/path-renderer.test.ts@@ -0,0 +1,44 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+import { describe, expect, it, vi } from 'vitest';+import type { App } from '../src/app/app';+import { MeshRenderer } from '../src/ecs/component';+import { MeshRenderers } from '../src/render/meshRenderer';+import { clearPath, setPath } from '../src/render/pathRenderer';++function fakeApp(hasMesh: boolean) {+ const api = { setGeometry: vi.fn(), clearGeometry: vi.fn() };+ const world = { has: vi.fn(() => hasMesh), insert: vi.fn() };+ const app = { world, getResource: vi.fn((res: unknown) => (res === MeshRenderers ? api : undefined)) } as unknown as App;+ return { app, api, world };+}++const triangle = [{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 0, y: 10 }];+const white = [1, 1, 1, 1] as const;++describe('setPath', () => {+ it('uploads the fill of the points to the entity\'s mesh', () => {+ const { app, api, world } = fakeApp(true);+ setPath(app, 7, triangle, { fill: { color: white } });+ expect(world.insert).not.toHaveBeenCalled();+ expect(api.setGeometry).toHaveBeenCalledTimes(1);+ const [entity, geometry] = api.setGeometry.mock.calls[0]!;+ expect(entity).toBe(7);+ expect(geometry.indices.length).toBe(3);+ });++ it('gives an entity without a MeshRenderer one', () => {+ const { app, world } = fakeApp(false);+ setPath(app, 3, triangle, { stroke: { color: white, width: 2 }, closed: true });+ expect(world.insert).toHaveBeenCalledWith(3, MeshRenderer, expect.objectContaining({ enabled: true }));+ });++ it('clears what was drawn when the path has nothing to draw', () => {+ const { app, api } = fakeApp(true);+ setPath(app, 1, [{ x: 0, y: 0 }], { stroke: { color: white, width: 2 } });+ expect(api.setGeometry).not.toHaveBeenCalled();+ expect(api.clearGeometry).toHaveBeenCalledWith(1);+ clearPath(app, 2);+ expect(api.clearGeometry).toHaveBeenCalledWith(2);+ });+});diff --git a/sdk/tests/vector-path.test.ts b/sdk/tests/vector-path.test.tsnew file mode 100644index 000000000..a636ee2dc--- /dev/null+++ b/sdk/tests/vector-path.test.ts@@ -0,0 +1,181 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+import { describe, expect, it } from 'vitest';+import {+ buildPathGeometry, circlePoints, cubicBezier, mergeGeometry, quadraticBezier, type PathStroke,+} from '../src/render/vectorPath';+import type { MeshRendererGeometry } from '../src/ecs/component';++const white = [1, 1, 1, 1] as const;+const P = (x: number, y: number) => ({ x, y });++/** Sum of the triangles' areas: equals the covered area exactly where nothing overlaps. */+function area(g: MeshRendererGeometry, onlyOpaque = false): number {+ let sum = 0;+ for (let t = 0; t < g.indices.length; t += 3) {+ const [a, b, c] = [g.indices[t]!, g.indices[t + 1]!, g.indices[t + 2]!];+ if (onlyOpaque && [a, b, c].some((i) => (g.colors![i * 4 + 3] ?? 1) < 1)) continue;+ const ax = g.positions[a * 2]!, ay = g.positions[a * 2 + 1]!;+ const bx = g.positions[b * 2]!, by = g.positions[b * 2 + 1]!;+ const cx = g.positions[c * 2]!, cy = g.positions[c * 2 + 1]!;+ sum += Math.abs((bx - ax) * (cy - ay) - (cx - ax) * (by - ay)) / 2;+ }+ return sum;+}++function valid(g: MeshRendererGeometry): void {+ const n = g.positions.length / 2;+ expect(g.colors!.length).toBe(n * 4);+ expect(g.indices.length % 3).toBe(0);+ for (const i of g.indices) { expect(i).toBeGreaterThanOrEqual(0); expect(i).toBeLessThan(n); }+ for (const v of g.positions) expect(Number.isFinite(v)).toBe(true);+}++const square = [P(0, 0), P(10, 0), P(10, 10), P(0, 10)];++describe('path fill', () => {+ it('covers a convex polygon exactly, whichever way it winds', () => {+ const g = buildPathGeometry(square, { fill: { color: white } });+ valid(g);+ expect(area(g)).toBeCloseTo(100, 6);+ expect(area(buildPathGeometry([...square].reverse(), { fill: { color: white } }))).toBeCloseTo(100, 6);+ });++ it('covers a concave polygon without spilling into its notch', () => {+ // An L: 10x10 with the top-right 5x5 taken out.+ const L = [P(0, 0), P(10, 0), P(10, 5), P(5, 5), P(5, 10), P(0, 10)];+ const g = buildPathGeometry(L, { fill: { color: white } });+ valid(g);+ expect(area(g)).toBeCloseTo(75, 6);+ });++ it('leaves a hole empty', () => {+ const hole = [P(3, 3), P(7, 3), P(7, 7), P(3, 7)];+ const g = buildPathGeometry(square, { fill: { color: white, holes: [hole] } });+ valid(g);+ expect(area(g)).toBeCloseTo(84, 6);+ });++ it('leaves two holes empty', () => {+ const h1 = [P(1, 1), P(3, 1), P(3, 3), P(1, 3)];+ const h2 = [P(6, 6), P(9, 6), P(9, 9), P(6, 9)];+ const g = buildPathGeometry(square, { fill: { color: white, holes: [h1, h2] } });+ valid(g);+ expect(area(g)).toBeCloseTo(100 - 4 - 9, 6);+ });++ it('draws nothing for fewer than three points', () => {+ expect(buildPathGeometry([P(0, 0), P(1, 1)], { fill: { color: white } }).indices.length).toBe(0);+ });++ it('feathers the edge: a fringe of transparent vertices, the opaque core unchanged', () => {+ const g = buildPathGeometry(square, { fill: { color: white }, feather: 1 });+ valid(g);+ expect(area(g, true)).toBeCloseTo(100, 6);+ const transparent = g.colors!.filter((v, i) => i % 4 === 3 && v === 0).length;+ expect(transparent).toBe(4);+ expect(area(g)).toBeGreaterThan(100 + 40);+ });+});++describe('path stroke', () => {+ const stroke = (over: Partial<PathStroke> = {}): PathStroke => ({ color: white, width: 2, ...over });++ it('is a rectangle for a straight segment, longer by the cap', () => {+ const line = [P(0, 0), P(10, 0)];+ expect(area(buildPathGeometry(line, { stroke: stroke() }))).toBeCloseTo(20, 6);+ expect(area(buildPathGeometry(line, { stroke: stroke({ cap: 'square' }) }))).toBeCloseTo(24, 6);+ const round = area(buildPathGeometry(line, { stroke: stroke({ cap: 'round' }), arcStep: 0.05 }));+ expect(round).toBeGreaterThan(20 + Math.PI * 0.98);+ expect(round).toBeLessThan(20 + Math.PI + 1e-6);+ });++ it('lays a closed square out with no overlap, by join', () => {+ const miter = buildPathGeometry(square, { stroke: stroke({ join: 'miter' }), closed: true });+ valid(miter);+ expect(area(miter)).toBeCloseTo(144 - 64, 6);+ const bevel = buildPathGeometry(square, { stroke: stroke({ join: 'bevel' }), closed: true });+ valid(bevel);+ expect(area(bevel)).toBeCloseTo(80 - 4 * 0.5, 6);+ const round = buildPathGeometry(square, { stroke: stroke({ join: 'round' }), closed: true, arcStep: 0.05 });+ valid(round);+ expect(area(round)).toBeGreaterThan(80 - 4 * (1 - Math.PI / 4) - 0.01);+ expect(area(round)).toBeLessThan(80 - 4 * (1 - Math.PI / 4) + 1e-6);+ });++ it('bevels a miter past its limit', () => {+ // A hairpin: the miter of this corner is far longer than the line is wide.+ const spike = [P(0, 0), P(10, 0), P(0, 3.6)];+ const limited = buildPathGeometry(spike, { stroke: stroke({ join: 'miter', miterLimit: 2 }) });+ const open = buildPathGeometry(spike, { stroke: stroke({ join: 'miter', miterLimit: 100 }) });+ valid(limited);+ valid(open);+ const maxX = (g: MeshRendererGeometry) => Math.max(...g.positions.filter((_, i) => i % 2 === 0));+ expect(maxX(open)).toBeGreaterThan(maxX(limited) + 1);+ });++ it('draws every segment of a bent open line', () => {+ const g = buildPathGeometry([P(0, 0), P(10, 0), P(10, 10)], { stroke: stroke() });+ valid(g);+ // Two 10-long segments of width 2, the corner shared once: the outer 1x1 corner added, the inner 1x1 taken away.+ expect(area(g)).toBeCloseTo(40, 6);+ });++ it('survives repeated points, one point and zero width', () => {+ valid(buildPathGeometry([P(0, 0), P(0, 0), P(5, 0), P(5, 0)], { stroke: stroke() }));+ expect(buildPathGeometry([P(1, 1)], { stroke: stroke() }).indices.length).toBe(0);+ expect(buildPathGeometry([P(0, 0), P(5, 0)], { stroke: stroke({ width: 0 }) }).indices.length).toBe(0);+ });++ it('feathers the sides: transparent fringe vertices, the opaque core unchanged', () => {+ const g = buildPathGeometry([P(0, 0), P(10, 0)], { stroke: stroke(), feather: 0.5 });+ valid(g);+ expect(area(g, true)).toBeCloseTo(20, 6);+ expect(area(g)).toBeGreaterThan(20);+ });++ it('stays finite on a smooth curve at every join and cap', () => {+ const curve = cubicBezier(P(0, 0), P(10, 20), P(20, -20), P(30, 0), 0.05);+ for (const join of ['miter', 'round', 'bevel'] as const) {+ for (const cap of ['butt', 'round', 'square'] as const) {+ valid(buildPathGeometry(curve, { stroke: stroke({ join, cap }), feather: 0.3 }));+ }+ }+ });+});++describe('path helpers', () => {+ it('cuts a Bezier through its end points, finer where it bends', () => {+ const flat = cubicBezier(P(0, 0), P(3, 0), P(6, 0), P(9, 0));+ const bent = cubicBezier(P(0, 0), P(0, 30), P(30, 30), P(30, 0));+ expect(flat[0]).toEqual(P(0, 0));+ expect(flat[flat.length - 1]!.x).toBeCloseTo(9, 9);+ expect(bent.length).toBeGreaterThan(flat.length);+ const q = quadraticBezier(P(0, 0), P(5, 10), P(10, 0));+ expect(q[Math.floor(q.length / 2)]!.y).toBeGreaterThan(4);+ });++ it('makes a circle and an arc', () => {+ const c = circlePoints(0, 0, 10, 32);+ expect(c.length).toBe(32);+ for (const p of c) expect(Math.hypot(p.x, p.y)).toBeCloseTo(10, 9);+ const arc = circlePoints(0, 0, 10, 8, 0, Math.PI);+ expect(arc.length).toBe(9);+ expect(arc[8]!.x).toBeCloseTo(-10, 9);+ });++ it('merges geometries with their indices shifted', () => {+ const a = buildPathGeometry(square, { fill: { color: white } });+ const g = mergeGeometry([a, a]);+ valid(g);+ expect(area(g)).toBeCloseTo(200, 6);+ });++ it('builds a four-hundred-point fill and stroke quickly', () => {+ const ring = circlePoints(0, 0, 50, 400);+ const t = performance.now();+ const g = buildPathGeometry(ring, { fill: { color: white }, stroke: { color: white, width: 2 }, closed: true, feather: 0.5 });+ valid(g);+ expect(performance.now() - t).toBeLessThan(500);+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex f1eb0ce2b..ead889c8e 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -3004,4 +3004,6 @@ export const NOTED = {{"note":"Drawing only the frames that can look different."},"feat(render): toon and matcap materials":{"note":"Toon and Matcap materials."},+ "feat(render): filled polygons and joined strokes as a path on a mesh":+ {"note":"Filled polygons and joined strokes."},};diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex d7f78c068..9b121ac76 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -658,6 +658,7 @@ export const SCENES = [{ id: "mat-model-env", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-model-env.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,101,0],\"tol\":20},{\"x\":0.75,\"y\":0.5,\"rgb\":[4,106,4],\"tol\":20},{\"x\":0.5,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },{ id: "material-builtin-lit", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-builtin-lit.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-builtin-lit.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":30}]" } },{ id: "material-toon", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/toon.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/toon.textures.json", ESTELLA_VERIFY_W: "900", ESTELLA_VERIFY_H: "360", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.2,\"y\":0.45,\"rgb\":[229,136,80],\"tol\":20},{\"x\":0.27,\"y\":0.4,\"rgb\":[195,114,74],\"tol\":20},{\"x\":0.3,\"y\":0.62,\"rgb\":[126,70,62],\"tol\":20},{\"x\":0.67,\"y\":0.42,\"rgb\":[255,255,255],\"tol\":20},{\"x\":0.77,\"y\":0.65,\"rgb\":[37,37,37],\"tol\":20},{\"x\":0.05,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":10}]" } },+ { id: "vector-paths", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/vector-paths.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/vector-paths.textures.json", ESTELLA_VERIFY_W: "900", ESTELLA_VERIFY_H: "300", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.2,\"y\":0.55,\"rgb\":[255,140,26],\"tol\":20},{\"x\":0.168,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":10},{\"x\":0.5,\"y\":0.5,\"rgb\":[51,204,230],\"tol\":20},{\"x\":0.82,\"y\":0.52,\"rgb\":[56,56,140],\"tol\":20},{\"x\":0.05,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":10}]" } },{ id: "material-dissolve", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-dissolve.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-dissolve.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":30}]" } },{ id: "material-graph", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-graph.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-graph.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" } },{ id: "material-preview", tier: "pr", host: "editor", webgpu: { ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" }, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-tint.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-tint.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_PREVIEW: "{\"w\":64,\"h\":64,\"rgb\":[255,0,0],\"tol\":45}" } },