@motionscript/layout-grid 0.0.0-stage → 0.1.0-alpha.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 (132) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +201 -0
  3. package/dist/browser/chunks/chunk-PB3E5HQV.js +2 -0
  4. package/dist/browser/chunks/chunk-PB3E5HQV.js.map +7 -0
  5. package/dist/browser/index.js +2 -0
  6. package/dist/browser/index.js.map +7 -0
  7. package/dist/browser/kit.js +2 -0
  8. package/dist/browser/kit.js.map +7 -0
  9. package/dist/browser/manifest.json +12 -0
  10. package/dist/engine.d.ts +13 -0
  11. package/dist/engine.d.ts.map +1 -0
  12. package/dist/engine.js +13 -0
  13. package/dist/engine.js.map +1 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +7 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/kit/index.d.ts +7 -0
  19. package/dist/kit/index.d.ts.map +1 -0
  20. package/dist/kit/index.js +7 -0
  21. package/dist/kit/index.js.map +1 -0
  22. package/dist/kit/item-effects.d.ts +37 -0
  23. package/dist/kit/item-effects.d.ts.map +1 -0
  24. package/dist/kit/item-effects.js +76 -0
  25. package/dist/kit/item-effects.js.map +1 -0
  26. package/dist/kit/layout-grid.d.ts +243 -0
  27. package/dist/kit/layout-grid.d.ts.map +1 -0
  28. package/dist/kit/layout-grid.js +542 -0
  29. package/dist/kit/layout-grid.js.map +1 -0
  30. package/dist/kit/order.d.ts +13 -0
  31. package/dist/kit/order.d.ts.map +1 -0
  32. package/dist/kit/order.js +43 -0
  33. package/dist/kit/order.js.map +1 -0
  34. package/dist/kit/random.d.ts +7 -0
  35. package/dist/kit/random.d.ts.map +1 -0
  36. package/dist/kit/random.js +29 -0
  37. package/dist/kit/random.js.map +1 -0
  38. package/dist/kit/slots/index.d.ts +22 -0
  39. package/dist/kit/slots/index.d.ts.map +1 -0
  40. package/dist/kit/slots/index.js +28 -0
  41. package/dist/kit/slots/index.js.map +1 -0
  42. package/dist/kit/slots/path-templates.d.ts +15 -0
  43. package/dist/kit/slots/path-templates.d.ts.map +1 -0
  44. package/dist/kit/slots/path-templates.js +113 -0
  45. package/dist/kit/slots/path-templates.js.map +1 -0
  46. package/dist/kit/slots/path.d.ts +45 -0
  47. package/dist/kit/slots/path.d.ts.map +1 -0
  48. package/dist/kit/slots/path.js +87 -0
  49. package/dist/kit/slots/path.js.map +1 -0
  50. package/dist/kit/slots/radial.d.ts +30 -0
  51. package/dist/kit/slots/radial.d.ts.map +1 -0
  52. package/dist/kit/slots/radial.js +45 -0
  53. package/dist/kit/slots/radial.js.map +1 -0
  54. package/dist/kit/slots/rectangular.d.ts +42 -0
  55. package/dist/kit/slots/rectangular.d.ts.map +1 -0
  56. package/dist/kit/slots/rectangular.js +79 -0
  57. package/dist/kit/slots/rectangular.js.map +1 -0
  58. package/dist/kit/slots/slot.d.ts +62 -0
  59. package/dist/kit/slots/slot.d.ts.map +1 -0
  60. package/dist/kit/slots/slot.js +41 -0
  61. package/dist/kit/slots/slot.js.map +1 -0
  62. package/dist/kit/slots/sphere.d.ts +36 -0
  63. package/dist/kit/slots/sphere.d.ts.map +1 -0
  64. package/dist/kit/slots/sphere.js +68 -0
  65. package/dist/kit/slots/sphere.js.map +1 -0
  66. package/dist/kit/stagger.d.ts +24 -0
  67. package/dist/kit/stagger.d.ts.map +1 -0
  68. package/dist/kit/stagger.js +90 -0
  69. package/dist/kit/stagger.js.map +1 -0
  70. package/dist/nodes.d.ts +15 -0
  71. package/dist/nodes.d.ts.map +1 -0
  72. package/dist/nodes.js +15 -0
  73. package/dist/nodes.js.map +1 -0
  74. package/dist/path-grid/index.d.ts +2 -0
  75. package/dist/path-grid/index.d.ts.map +1 -0
  76. package/dist/path-grid/index.js +2 -0
  77. package/dist/path-grid/index.js.map +1 -0
  78. package/dist/path-grid/path-grid.d.ts +82 -0
  79. package/dist/path-grid/path-grid.d.ts.map +1 -0
  80. package/dist/path-grid/path-grid.js +192 -0
  81. package/dist/path-grid/path-grid.js.map +1 -0
  82. package/dist/radial-grid/index.d.ts +2 -0
  83. package/dist/radial-grid/index.d.ts.map +1 -0
  84. package/dist/radial-grid/index.js +2 -0
  85. package/dist/radial-grid/index.js.map +1 -0
  86. package/dist/radial-grid/radial-grid.d.ts +51 -0
  87. package/dist/radial-grid/radial-grid.d.ts.map +1 -0
  88. package/dist/radial-grid/radial-grid.js +95 -0
  89. package/dist/radial-grid/radial-grid.js.map +1 -0
  90. package/dist/rectangular-grid/index.d.ts +2 -0
  91. package/dist/rectangular-grid/index.d.ts.map +1 -0
  92. package/dist/rectangular-grid/index.js +2 -0
  93. package/dist/rectangular-grid/index.js.map +1 -0
  94. package/dist/rectangular-grid/rectangular-grid.d.ts +79 -0
  95. package/dist/rectangular-grid/rectangular-grid.d.ts.map +1 -0
  96. package/dist/rectangular-grid/rectangular-grid.js +156 -0
  97. package/dist/rectangular-grid/rectangular-grid.js.map +1 -0
  98. package/dist/sphere-grid/index.d.ts +2 -0
  99. package/dist/sphere-grid/index.d.ts.map +1 -0
  100. package/dist/sphere-grid/index.js +2 -0
  101. package/dist/sphere-grid/index.js.map +1 -0
  102. package/dist/sphere-grid/sphere-grid.d.ts +68 -0
  103. package/dist/sphere-grid/sphere-grid.d.ts.map +1 -0
  104. package/dist/sphere-grid/sphere-grid.js +149 -0
  105. package/dist/sphere-grid/sphere-grid.js.map +1 -0
  106. package/package.json +69 -3
  107. package/registry.json +32 -0
  108. package/src/engine.ts +12 -0
  109. package/src/index.ts +6 -0
  110. package/src/kit/index.ts +6 -0
  111. package/src/kit/item-effects.ts +114 -0
  112. package/src/kit/layout-grid.ts +605 -0
  113. package/src/kit/order.ts +41 -0
  114. package/src/kit/random.ts +29 -0
  115. package/src/kit/slots/index.ts +39 -0
  116. package/src/kit/slots/path-templates.ts +120 -0
  117. package/src/kit/slots/path.ts +120 -0
  118. package/src/kit/slots/radial.ts +62 -0
  119. package/src/kit/slots/rectangular.ts +108 -0
  120. package/src/kit/slots/slot.ts +82 -0
  121. package/src/kit/slots/sphere.ts +94 -0
  122. package/src/kit/stagger.ts +96 -0
  123. package/src/nodes.ts +15 -0
  124. package/src/path-grid/index.ts +1 -0
  125. package/src/path-grid/path-grid.ts +213 -0
  126. package/src/radial-grid/index.ts +1 -0
  127. package/src/radial-grid/radial-grid.ts +90 -0
  128. package/src/rectangular-grid/index.ts +1 -0
  129. package/src/rectangular-grid/rectangular-grid.ts +160 -0
  130. package/src/sphere-grid/index.ts +1 -0
  131. package/src/sphere-grid/sphere-grid.ts +143 -0
  132. package/README.md +0 -4
@@ -0,0 +1,143 @@
1
+ import { command, node, property, type Command, type CommandArgs, type NodeConfig } from "@motionscript/core"
2
+
3
+ import {
4
+ LayoutGrid,
5
+ normalizeOrder,
6
+ SPHERE_AXES,
7
+ SPHERE_FACINGS,
8
+ sphereFaceForward,
9
+ wrapDegrees,
10
+ type LayoutGridProps,
11
+ type SphereArrangement,
12
+ type SphereAxis,
13
+ type SphereFacing,
14
+ } from "../kit"
15
+
16
+ export interface SphereGridProps extends LayoutGridProps {
17
+ radius: number
18
+ yaw: number
19
+ pitch: number
20
+ roll: number
21
+ facing: SphereFacing
22
+ focalLength: number
23
+ depthFade: number
24
+ cullBackfaces: boolean
25
+ spinSpeed: number
26
+ }
27
+
28
+ const AXIS_PROP: Record<SphereAxis, "yaw" | "pitch" | "roll"> = { x: "pitch", y: "yaw", z: "roll" }
29
+
30
+ /**
31
+ * Children spread over a sphere — a Fibonacci lattice, as even as any number
32
+ * of points gets — and seen through a camera of the grid's own, so the far
33
+ * side is smaller, drawn first, and hidden where a face turns away.
34
+ *
35
+ * `outward` lays each item flat on the surface; `billboard` keeps each one
36
+ * facing the viewer, like labels on a globe. {@link turnTo} brings any item
37
+ * round to the front.
38
+ */
39
+ @node({
40
+ key: "sphereGrid",
41
+ parentKey: "node",
42
+ forkable: true,
43
+ layout: {
44
+ children: "flow",
45
+ acceptsChildren: true,
46
+ defaultWidthMode: "hug",
47
+ defaultHeightMode: "hug",
48
+ },
49
+ })
50
+ export class SphereGrid extends LayoutGrid<SphereGridProps> {
51
+ @property({ default: 220, min: 0, step: 1 }) declare radius: number
52
+ @property({ default: 0, step: 1, unit: "°" }) declare yaw: number
53
+ @property({ default: 0, step: 1, unit: "°" }) declare pitch: number
54
+ @property({ default: 0, step: 1, unit: "°" }) declare roll: number
55
+ @property({ default: "outward", kind: "enum", options: SPHERE_FACINGS }) declare facing: SphereFacing
56
+ @property({ default: 900, min: 100, step: 10 }) declare focalLength: number
57
+ @property({ default: 0.5, min: 0, max: 1, step: 0.05 }) declare depthFade: number
58
+ @property({ default: false }) declare cullBackfaces: boolean
59
+ @property({ default: 0, step: 1, unit: "°/s" }) declare spinSpeed: number
60
+
61
+ constructor(props?: NodeConfig<SphereGrid, SphereGridProps>) {
62
+ super(props)
63
+ }
64
+
65
+ /** Turn the sphere about an axis by `degrees` — `y` spins it like a globe. */
66
+ @command({
67
+ args: [
68
+ { key: "axis", kind: "enum", options: SPHERE_AXES, default: "y" },
69
+ { key: "degrees", step: 15, unit: "°", default: 360 },
70
+ ],
71
+ })
72
+ spin(args: CommandArgs<{ axis?: SphereAxis; degrees?: number }> & { duration: number }): Command<SphereGridProps> {
73
+ const key = AXIS_PROP[args.data?.axis ?? "y"] ?? "yaw"
74
+ const degrees = args.data?.degrees ?? 360
75
+ return this.to({ data: { [key]: this[key] + degrees }, duration: args.duration, easing: args.easing })
76
+ }
77
+
78
+ /** Turn the sphere to a set orientation. */
79
+ @command({
80
+ args: [
81
+ { key: "yaw", unit: "°", default: 45 },
82
+ { key: "pitch", unit: "°", default: 20 },
83
+ { key: "roll", unit: "°", default: 0 },
84
+ ],
85
+ })
86
+ orientTo(args: CommandArgs<{ yaw?: number; pitch?: number; roll?: number }> & { duration: number }): Command<SphereGridProps> {
87
+ return this.to({
88
+ data: { yaw: args.data?.yaw ?? this.yaw, pitch: args.data?.pitch ?? this.pitch, roll: args.data?.roll ?? this.roll },
89
+ duration: args.duration,
90
+ easing: args.easing,
91
+ })
92
+ }
93
+
94
+ /** Turn the sphere the shorter way until an item (by its place in the layers) faces the viewer. */
95
+ @command({ args: [{ key: "item", min: 0, step: 1, default: 0 }] })
96
+ turnTo(args: CommandArgs<{ item?: number }> & { duration: number }): Command<SphereGridProps> {
97
+ const count = this._itemCount()
98
+ const slot = normalizeOrder(this.order, count).indexOf(Math.round(args.data?.item ?? 0))
99
+ if (slot < 0) return this.to({ data: {}, duration: args.duration })
100
+ const facing = sphereFaceForward(count, slot)
101
+ // The yaw the clock has added is part of where the item is now.
102
+ const spun = this.spinSpeed * this.time.total
103
+ return this.to({
104
+ data: {
105
+ yaw: this.yaw + wrapDegrees(facing.yaw - (this.yaw + spun)),
106
+ pitch: this.pitch + wrapDegrees(facing.pitch - this.pitch),
107
+ roll: 0,
108
+ },
109
+ duration: args.duration,
110
+ easing: args.easing,
111
+ })
112
+ }
113
+
114
+ @command({ args: [{ key: "radius", min: 0, default: 300 }] })
115
+ radiusTo(args: CommandArgs<{ radius: number }> & { duration: number }): Command<SphereGridProps> {
116
+ return this.to({ data: { radius: args.data?.radius ?? this.radius }, duration: args.duration, easing: args.easing })
117
+ }
118
+
119
+ /** Dolly the camera: a shorter focal length exaggerates the depth, a longer one flattens it. */
120
+ @command({ args: [{ key: "focalLength", min: 100, default: 600 }] })
121
+ focalLengthTo(args: CommandArgs<{ focalLength: number }> & { duration: number }): Command<SphereGridProps> {
122
+ return this.to({
123
+ data: { focalLength: args.data?.focalLength ?? this.focalLength },
124
+ duration: args.duration,
125
+ easing: args.easing,
126
+ })
127
+ }
128
+
129
+ protected override arrangementFor(): SphereArrangement {
130
+ return {
131
+ kind: "sphere",
132
+ radius: this.radius,
133
+ yaw: this.yaw,
134
+ pitch: this.pitch,
135
+ roll: this.roll,
136
+ facing: this.facing,
137
+ focalLength: this.focalLength,
138
+ depthFade: this.depthFade,
139
+ cullBackfaces: this.cullBackfaces,
140
+ spinSpeed: this.spinSpeed,
141
+ }
142
+ }
143
+ }
package/README.md DELETED
@@ -1,4 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
- If no other versions are published within 30 days, this package and version will be deleted.