@motionscript/layout-grid 0.0.0-stage → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +201 -0
- package/dist/browser/chunks/chunk-LEUMKC3A.js +2 -0
- package/dist/browser/chunks/chunk-LEUMKC3A.js.map +7 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/kit.js +2 -0
- package/dist/browser/kit.js.map +7 -0
- package/dist/browser/manifest.json +12 -0
- package/dist/engine.d.ts +13 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +13 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/kit/index.d.ts +7 -0
- package/dist/kit/index.d.ts.map +1 -0
- package/dist/kit/index.js +7 -0
- package/dist/kit/index.js.map +1 -0
- package/dist/kit/item-effects.d.ts +37 -0
- package/dist/kit/item-effects.d.ts.map +1 -0
- package/dist/kit/item-effects.js +76 -0
- package/dist/kit/item-effects.js.map +1 -0
- package/dist/kit/layout-grid.d.ts +243 -0
- package/dist/kit/layout-grid.d.ts.map +1 -0
- package/dist/kit/layout-grid.js +542 -0
- package/dist/kit/layout-grid.js.map +1 -0
- package/dist/kit/order.d.ts +13 -0
- package/dist/kit/order.d.ts.map +1 -0
- package/dist/kit/order.js +43 -0
- package/dist/kit/order.js.map +1 -0
- package/dist/kit/random.d.ts +7 -0
- package/dist/kit/random.d.ts.map +1 -0
- package/dist/kit/random.js +29 -0
- package/dist/kit/random.js.map +1 -0
- package/dist/kit/slots/index.d.ts +22 -0
- package/dist/kit/slots/index.d.ts.map +1 -0
- package/dist/kit/slots/index.js +28 -0
- package/dist/kit/slots/index.js.map +1 -0
- package/dist/kit/slots/path-templates.d.ts +15 -0
- package/dist/kit/slots/path-templates.d.ts.map +1 -0
- package/dist/kit/slots/path-templates.js +113 -0
- package/dist/kit/slots/path-templates.js.map +1 -0
- package/dist/kit/slots/path.d.ts +45 -0
- package/dist/kit/slots/path.d.ts.map +1 -0
- package/dist/kit/slots/path.js +87 -0
- package/dist/kit/slots/path.js.map +1 -0
- package/dist/kit/slots/radial.d.ts +30 -0
- package/dist/kit/slots/radial.d.ts.map +1 -0
- package/dist/kit/slots/radial.js +45 -0
- package/dist/kit/slots/radial.js.map +1 -0
- package/dist/kit/slots/rectangular.d.ts +42 -0
- package/dist/kit/slots/rectangular.d.ts.map +1 -0
- package/dist/kit/slots/rectangular.js +79 -0
- package/dist/kit/slots/rectangular.js.map +1 -0
- package/dist/kit/slots/slot.d.ts +62 -0
- package/dist/kit/slots/slot.d.ts.map +1 -0
- package/dist/kit/slots/slot.js +41 -0
- package/dist/kit/slots/slot.js.map +1 -0
- package/dist/kit/slots/sphere.d.ts +36 -0
- package/dist/kit/slots/sphere.d.ts.map +1 -0
- package/dist/kit/slots/sphere.js +68 -0
- package/dist/kit/slots/sphere.js.map +1 -0
- package/dist/kit/stagger.d.ts +24 -0
- package/dist/kit/stagger.d.ts.map +1 -0
- package/dist/kit/stagger.js +90 -0
- package/dist/kit/stagger.js.map +1 -0
- package/dist/nodes.d.ts +15 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +15 -0
- package/dist/nodes.js.map +1 -0
- package/dist/path-grid/index.d.ts +2 -0
- package/dist/path-grid/index.d.ts.map +1 -0
- package/dist/path-grid/index.js +2 -0
- package/dist/path-grid/index.js.map +1 -0
- package/dist/path-grid/path-grid.d.ts +82 -0
- package/dist/path-grid/path-grid.d.ts.map +1 -0
- package/dist/path-grid/path-grid.js +192 -0
- package/dist/path-grid/path-grid.js.map +1 -0
- package/dist/radial-grid/index.d.ts +2 -0
- package/dist/radial-grid/index.d.ts.map +1 -0
- package/dist/radial-grid/index.js +2 -0
- package/dist/radial-grid/index.js.map +1 -0
- package/dist/radial-grid/radial-grid.d.ts +51 -0
- package/dist/radial-grid/radial-grid.d.ts.map +1 -0
- package/dist/radial-grid/radial-grid.js +95 -0
- package/dist/radial-grid/radial-grid.js.map +1 -0
- package/dist/rectangular-grid/index.d.ts +2 -0
- package/dist/rectangular-grid/index.d.ts.map +1 -0
- package/dist/rectangular-grid/index.js +2 -0
- package/dist/rectangular-grid/index.js.map +1 -0
- package/dist/rectangular-grid/rectangular-grid.d.ts +79 -0
- package/dist/rectangular-grid/rectangular-grid.d.ts.map +1 -0
- package/dist/rectangular-grid/rectangular-grid.js +156 -0
- package/dist/rectangular-grid/rectangular-grid.js.map +1 -0
- package/dist/sphere-grid/index.d.ts +2 -0
- package/dist/sphere-grid/index.d.ts.map +1 -0
- package/dist/sphere-grid/index.js +2 -0
- package/dist/sphere-grid/index.js.map +1 -0
- package/dist/sphere-grid/sphere-grid.d.ts +68 -0
- package/dist/sphere-grid/sphere-grid.d.ts.map +1 -0
- package/dist/sphere-grid/sphere-grid.js +149 -0
- package/dist/sphere-grid/sphere-grid.js.map +1 -0
- package/package.json +70 -3
- package/registry.json +32 -0
- package/src/engine.ts +12 -0
- package/src/index.ts +6 -0
- package/src/kit/index.ts +6 -0
- package/src/kit/item-effects.ts +114 -0
- package/src/kit/layout-grid.ts +605 -0
- package/src/kit/order.ts +41 -0
- package/src/kit/random.ts +29 -0
- package/src/kit/slots/index.ts +39 -0
- package/src/kit/slots/path-templates.ts +120 -0
- package/src/kit/slots/path.ts +120 -0
- package/src/kit/slots/radial.ts +62 -0
- package/src/kit/slots/rectangular.ts +108 -0
- package/src/kit/slots/slot.ts +82 -0
- package/src/kit/slots/sphere.ts +94 -0
- package/src/kit/stagger.ts +96 -0
- package/src/nodes.ts +15 -0
- package/src/path-grid/index.ts +1 -0
- package/src/path-grid/path-grid.ts +213 -0
- package/src/radial-grid/index.ts +1 -0
- package/src/radial-grid/radial-grid.ts +90 -0
- package/src/rectangular-grid/index.ts +1 -0
- package/src/rectangular-grid/rectangular-grid.ts +160 -0
- package/src/sphere-grid/index.ts +1 -0
- package/src/sphere-grid/sphere-grid.ts +143 -0
- package/README.md +0 -4
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { command, node, property, type Command, type CommandArgs, type NodeConfig } from "@motionscript/sdk"
|
|
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.
|