@weasel-js/core 1.7.2 → 1.8.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/animation/colorHelpers.js +58 -58
  3. package/dist/animation/colorHelpers.js.map +1 -1
  4. package/dist/animation/engine/axes.js +36 -0
  5. package/dist/animation/engine/axes.js.map +1 -0
  6. package/dist/animation/engine/codec.js +170 -0
  7. package/dist/animation/engine/codec.js.map +1 -0
  8. package/dist/animation/engine/integrator.js +12 -0
  9. package/dist/animation/engine/integrator.js.map +1 -0
  10. package/dist/animation/useAnimator.js +199 -157
  11. package/dist/animation/useAnimator.js.map +1 -1
  12. package/dist/{builtins-C-gRyVRx.d.ts → builtins-BW32dOXy.d.ts} +74 -8
  13. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +12 -12
  14. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  15. package/dist/canvas/pickWalk.js +2 -2
  16. package/dist/canvas/pickWalk.js.map +1 -1
  17. package/dist/canvas/sceneSlotWiring.js +1 -1
  18. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  19. package/dist/canvas/sceneViewRender.js +1 -1
  20. package/dist/canvas/sceneViewRender.js.map +1 -1
  21. package/dist/core/scene/effectivePose.js +1 -1
  22. package/dist/core/scene/effectivePose.js.map +1 -1
  23. package/dist/core/scene/poseOverrides.js +42 -22
  24. package/dist/core/scene/poseOverrides.js.map +1 -1
  25. package/dist/core/scene/types.js.map +1 -1
  26. package/dist/index.d.ts +28 -18
  27. package/dist/renderer/WeaselRenderer.js +4 -1
  28. package/dist/renderer/WeaselRenderer.js.map +1 -1
  29. package/dist/renderer/batchClip.js +46 -0
  30. package/dist/renderer/batchClip.js.map +1 -0
  31. package/dist/renderer/draw.js +367 -294
  32. package/dist/renderer/draw.js.map +1 -1
  33. package/dist/renderer/drawBatch.js +75 -45
  34. package/dist/renderer/drawBatch.js.map +1 -1
  35. package/dist/renderer.d.ts +1 -1
  36. package/dist/tools/builtin/text/useTextTool.js +8 -8
  37. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  38. package/dist/tools/prefs.js.map +1 -1
  39. package/dist/version.js +1 -1
  40. package/package.json +16 -15
@@ -0,0 +1,46 @@
1
+ //#region src/renderer/batchClip.ts
2
+ function e(e, t) {
3
+ if (e.kind !== "rect" || !(t[1] === 0 && t[3] === 0 || t[0] === 0 && t[4] === 0)) return null;
4
+ let n = t[0] * e.x + t[3] * e.y + t[6], r = t[1] * e.x + t[4] * e.y + t[7], i = e.x + e.width, a = e.y + e.height, o = t[0] * i + t[3] * a + t[6], s = t[1] * i + t[4] * a + t[7];
5
+ return {
6
+ x0: Math.min(n, o),
7
+ y0: Math.min(r, s),
8
+ x1: Math.max(n, o),
9
+ y1: Math.max(r, s)
10
+ };
11
+ }
12
+ function t(e, t) {
13
+ return {
14
+ x0: Math.max(e.x0, t.x0),
15
+ y0: Math.max(e.y0, t.y0),
16
+ x1: Math.min(e.x1, t.x1),
17
+ y1: Math.min(e.y1, t.y1)
18
+ };
19
+ }
20
+ function n(e, t, n, i, a, o) {
21
+ let s = r(e, t, n, 0, i.x0, 1, o);
22
+ return s = r(o, s, n, 0, i.x1, -1, a), s = r(a, s, n, 1, i.y0, 1, o), r(o, s, n, 1, i.y1, -1, a);
23
+ }
24
+ function r(e, t, n, r, i, a, o) {
25
+ if (t === 0) return 0;
26
+ let s = 0, c = t - 1, l = a * (e[c * n + r] - i) >= 0;
27
+ for (let u = 0; u < t; u++) {
28
+ let t = a * (e[u * n + r] - i) >= 0;
29
+ if (t !== l) {
30
+ let t = c * n, a = u * n, l = (i - e[t + r]) / (e[a + r] - e[t + r]), d = s * n;
31
+ for (let r = 0; r < n; r++) o[d + r] = e[t + r] + l * (e[a + r] - e[t + r]);
32
+ o[d + r] = i, s++;
33
+ }
34
+ if (t) {
35
+ let t = s * n, r = u * n;
36
+ for (let i = 0; i < n; i++) o[t + i] = e[r + i];
37
+ s++;
38
+ }
39
+ c = u, l = t;
40
+ }
41
+ return s;
42
+ }
43
+ //#endregion
44
+ export { e as axisAlignedClipRect, n as clipConvexPolygon, t as intersectClipRects };
45
+
46
+ //# sourceMappingURL=batchClip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batchClip.js","names":["axisAlignedClipRect","path","m","ax","ay","x1","y1","bx","by","intersectClipRects","a","b","clipConvexPolygon","count","clipEdge","src","n","stride","rect","tmp","dst","prev","prevIn","sign","axis","at","cur","curIn","t","o","k","c"],"sources":["../../src/renderer/batchClip.ts"],"sourcesContent":["/**\n * Clipping staged geometry to an axis-aligned rect on the CPU, so a rect clip\n * needs no stencil and does not break the run.\n *\n * A stencil clip is GL state, so content inside one cannot share a draw with\n * content outside it, and every clipped group paid a flush on the way in and\n * another on the way out. A rect under a transform that keeps it axis-aligned\n * is the common clip, and for that one the clip can ride the geometry instead:\n * cut each staged polygon to the rect before it joins the run.\n *\n * Exact, not approximate: every attribute a batch vertex carries is affine\n * across the polygon it belongs to, so interpolating along a cut edge gives\n * the value the rasterizer would have produced there, and the cut polygon\n * covers the same pixel centers the stencil would have passed.\n */\n\nimport type { Path } from '@weasel-js/geom';\nimport type { GlMat3 } from './math/mat3';\n\n/** In the space batch vertices are staged in: after the model transform,\n * before the projection. */\nexport interface ClipRect {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\n/**\n * `path` under `m` as a `ClipRect`, or `null` when it is not one: not a rect\n * path, or a transform that rotates or skews it off the axes.\n */\nexport function axisAlignedClipRect(path: Path, m: GlMat3): ClipRect | null {\n if (path.kind !== 'rect') return null;\n const keepsAxes = (m[1] === 0 && m[3] === 0) || (m[0] === 0 && m[4] === 0);\n if (!keepsAxes) return null;\n const ax = m[0] * path.x + m[3] * path.y + m[6];\n const ay = m[1] * path.x + m[4] * path.y + m[7];\n const x1 = path.x + path.width;\n const y1 = path.y + path.height;\n const bx = m[0] * x1 + m[3] * y1 + m[6];\n const by = m[1] * x1 + m[4] * y1 + m[7];\n return {\n x0: Math.min(ax, bx), y0: Math.min(ay, by),\n x1: Math.max(ax, bx), y1: Math.max(ay, by),\n };\n}\n\nexport function intersectClipRects(a: ClipRect, b: ClipRect): ClipRect {\n return {\n x0: Math.max(a.x0, b.x0), y0: Math.max(a.y0, b.y0),\n x1: Math.min(a.x1, b.x1), y1: Math.min(a.y1, b.y1),\n };\n}\n\n/**\n * Cut the convex polygon of `n` vertices in `src` (each `stride` floats, x and\n * y first) to `rect`, writing the result to `dst`. Returns the vertex count,\n * which is below 3 when nothing is left. `tmp` must hold as many floats as\n * `dst`; both need room for `n + 4` vertices.\n */\nexport function clipConvexPolygon(\n src: Float32Array, n: number, stride: number, rect: ClipRect,\n dst: Float32Array, tmp: Float32Array,\n): number {\n // Four passes, ping-ponging so the last one lands in `dst`.\n let count = clipEdge(src, n, stride, 0, rect.x0, 1, tmp);\n count = clipEdge(tmp, count, stride, 0, rect.x1, -1, dst);\n count = clipEdge(dst, count, stride, 1, rect.y0, 1, tmp);\n return clipEdge(tmp, count, stride, 1, rect.y1, -1, dst);\n}\n\n/** One Sutherland–Hodgman pass: keep the side of `axis = at` where\n * `sign * (v - at) >= 0`. */\nfunction clipEdge(\n src: Float32Array, n: number, stride: number,\n axis: 0 | 1, at: number, sign: 1 | -1, out: Float32Array,\n): number {\n if (n === 0) return 0;\n let m = 0;\n let prev = n - 1;\n let prevIn = sign * (src[prev * stride + axis] - at) >= 0;\n for (let cur = 0; cur < n; cur++) {\n const curIn = sign * (src[cur * stride + axis] - at) >= 0;\n if (curIn !== prevIn) {\n const a = prev * stride;\n const b = cur * stride;\n const t = (at - src[a + axis]) / (src[b + axis] - src[a + axis]);\n const o = m * stride;\n for (let k = 0; k < stride; k++) out[o + k] = src[a + k] + t * (src[b + k] - src[a + k]);\n // On the line exactly, whatever the interpolation rounded to.\n out[o + axis] = at;\n m++;\n }\n if (curIn) {\n const o = m * stride;\n const c = cur * stride;\n for (let k = 0; k < st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