@atom.io/spa 0.0.9 → 0.0.11
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/README.md +30 -10
- package/README.mdx +16 -5
- package/dist/BrandMarkScene-BeWazldB.js +140 -0
- package/dist/BrandMarkScene-BeWazldB.js.map +1 -0
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-application.js +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.js +5 -5
- package/dist/{astro-context-OdlexHR4.js → astro-context-B9XKrz8c.js} +1 -1
- package/dist/{astro-context-OdlexHR4.js.map → astro-context-B9XKrz8c.js.map} +1 -1
- package/dist/astro-middleware.js +2 -2
- package/dist/{development/astro-request-DRKvDjsO.js → astro-request-C0eYQlmS.js} +2 -2
- package/dist/{astro-request-DRKvDjsO.js.map → astro-request-C0eYQlmS.js.map} +1 -1
- package/dist/astro-resumability-client.d.ts +1 -1
- package/dist/astro-resumability-client.js +1 -1
- package/dist/astro-resumability-server.js +1 -1
- package/dist/astro-server.js +4 -4
- package/dist/{astro-shared-KxK9OUSj.d.ts → astro-shared-C-iO4PVU.d.ts} +2 -2
- package/dist/{astro-shared-KxK9OUSj.d.ts.map → astro-shared-C-iO4PVU.d.ts.map} +1 -1
- package/dist/{astro-shared-DBwINQav.js → astro-shared-CwBaV3Xu.js} +2 -2
- package/dist/{astro-shared-DBwINQav.js.map → astro-shared-CwBaV3Xu.js.map} +1 -1
- package/dist/astro.d.ts +2 -2
- package/dist/astro.js +1 -1
- package/dist/brand-css.d.ts +2 -0
- package/dist/brand-model.d.ts +32 -0
- package/dist/brand-model.d.ts.map +1 -0
- package/dist/brand-model.js +120 -0
- package/dist/brand-model.js.map +1 -0
- package/dist/brand.css +37 -0
- package/dist/brand.d.ts +13 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +94 -0
- package/dist/brand.js.map +1 -0
- package/dist/{capabilities-ChgSs6bp.d.ts → capabilities-BNnXgvo5.d.ts} +3 -3
- package/dist/{capabilities-ChgSs6bp.d.ts.map → capabilities-BNnXgvo5.d.ts.map} +1 -1
- package/dist/client.min.js +1 -1
- package/dist/{core-DD2giR6E.js → core-N07x1OaR.js} +1 -1
- package/dist/{core-DD2giR6E.js.map → core-N07x1OaR.js.map} +1 -1
- package/dist/development/BrandMarkScene-B282kBA3.js +140 -0
- package/dist/development/BrandMarkScene-B282kBA3.js.map +1 -0
- package/dist/development/astro-application.js +1 -1
- package/dist/development/astro-client.js +5 -5
- package/dist/development/{astro-context-OdlexHR4.js → astro-context-B9XKrz8c.js} +1 -1
- package/dist/development/{astro-context-OdlexHR4.js.map → astro-context-B9XKrz8c.js.map} +1 -1
- package/dist/development/astro-middleware.js +2 -2
- package/dist/{astro-request-DRKvDjsO.js → development/astro-request-C0eYQlmS.js} +2 -2
- package/dist/development/{astro-request-DRKvDjsO.js.map → astro-request-C0eYQlmS.js.map} +1 -1
- package/dist/development/astro-resumability-client.js +1 -1
- package/dist/development/astro-resumability-server.js +1 -1
- package/dist/development/astro-server.js +4 -4
- package/dist/development/{astro-shared-DBwINQav.js → astro-shared-CwBaV3Xu.js} +2 -2
- package/dist/development/{astro-shared-DBwINQav.js.map → astro-shared-CwBaV3Xu.js.map} +1 -1
- package/dist/development/astro.js +1 -1
- package/dist/development/brand-model.js +120 -0
- package/dist/development/brand-model.js.map +1 -0
- package/dist/development/brand.css +37 -0
- package/dist/development/brand.js +94 -0
- package/dist/development/brand.js.map +1 -0
- package/dist/development/{core-DrUd8x25.js → core-D1FWUMMC.js} +1 -1
- package/dist/development/{core-DrUd8x25.js.map → core-D1FWUMMC.js.map} +1 -1
- package/dist/development/{dom-BRFv7FP_.js → dom-C1cVf5Vm.js} +6 -5
- package/dist/development/dom-C1cVf5Vm.js.map +1 -0
- package/dist/development/floating.js +1 -1
- package/dist/development/floating.js.map +1 -1
- package/dist/development/hot.js +3 -3
- package/dist/development/hot.js.map +1 -1
- package/dist/{identity-oFU5p-Qj.js → development/identity-DWHH6jbd.js} +3 -3
- package/dist/development/{identity-DwB8MTM1.js.map → identity-DWHH6jbd.js.map} +1 -1
- package/dist/development/index.js +4 -4
- package/dist/development/{jsx-runtime-BGDPK50B.js → jsx-runtime-B2XxfA3E.js} +1 -1
- package/dist/development/{jsx-runtime-BGDPK50B.js.map → jsx-runtime-B2XxfA3E.js.map} +1 -1
- package/dist/development/jsx-runtime.js +1 -1
- package/dist/development/konva.js +4 -4
- package/dist/development/motion.js +39 -20
- package/dist/development/motion.js.map +1 -1
- package/dist/development/renderer.js +3 -3
- package/dist/{server-renderer-BYFDmqnM.js → development/server-renderer-B-L5tNg7.js} +4 -4
- package/dist/development/{server-renderer-u1-c5PGd.js.map → server-renderer-B-L5tNg7.js.map} +1 -1
- package/dist/development/server.js +1 -1
- package/dist/development/{src-CB7ruwRs.js → src-By4JY4qf.js} +2 -2
- package/dist/development/{src-CB7ruwRs.js.map → src-By4JY4qf.js.map} +1 -1
- package/dist/development/three-F5D1OnE9.js +527 -0
- package/dist/development/three-F5D1OnE9.js.map +1 -0
- package/dist/development/three.js +1 -509
- package/dist/development/{vite-WUiz1ju6.js → vite-BKxEE-ZO.js} +1 -1
- package/dist/development/{vite-WUiz1ju6.js.map → vite-BKxEE-ZO.js.map} +1 -1
- package/dist/development/vite.js +1 -1
- package/dist/{dom--HZvmgqd.js → dom-BbfEAPpR.js} +6 -5
- package/dist/dom-BbfEAPpR.js.map +1 -0
- package/dist/floating.d.ts +1 -1
- package/dist/floating.js +1 -1
- package/dist/floating.js.map +1 -1
- package/dist/hot.d.ts +1 -1
- package/dist/hot.d.ts.map +1 -1
- package/dist/hot.js +1 -1
- package/dist/hot.js.map +1 -1
- package/dist/{development/identity-DwB8MTM1.js → identity-wPtz6EJM.js} +3 -3
- package/dist/{identity-oFU5p-Qj.js.map → identity-wPtz6EJM.js.map} +1 -1
- package/dist/{index-DdA39aMv.d.ts → index-2AKIR8up.d.ts} +4 -4
- package/dist/{index-DdA39aMv.d.ts.map → index-2AKIR8up.d.ts.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/{jsx-runtime-BGDPK50B.js → jsx-runtime-B2XxfA3E.js} +1 -1
- package/dist/{jsx-runtime-BGDPK50B.js.map → jsx-runtime-B2XxfA3E.js.map} +1 -1
- package/dist/{jsx-runtime-CCvcEosg.d.ts → jsx-runtime-CjiJSx5m.d.ts} +2 -2
- package/dist/{jsx-runtime-CCvcEosg.d.ts.map → jsx-runtime-CjiJSx5m.d.ts.map} +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/konva.d.ts +3 -3
- package/dist/konva.js +4 -4
- package/dist/motion.d.ts +3 -1
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +39 -20
- package/dist/motion.js.map +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +3 -3
- package/dist/{development/server-renderer-u1-c5PGd.js → server-renderer-CjTOgG1b.js} +4 -4
- package/dist/{server-renderer-BYFDmqnM.js.map → server-renderer-CjTOgG1b.js.map} +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/size.json +13 -13
- package/dist/{src-B2W_TA_X.js → src-BQlLP70K.js} +2 -2
- package/dist/{src-B2W_TA_X.js.map → src-BQlLP70K.js.map} +1 -1
- package/dist/three-DGOOlFXk.js +527 -0
- package/dist/three-DGOOlFXk.js.map +1 -0
- package/dist/three.d.ts +24 -3
- package/dist/three.d.ts.map +1 -1
- package/dist/three.js +1 -509
- package/dist/{vite-WUiz1ju6.js → vite-BKxEE-ZO.js} +1 -1
- package/dist/{vite-WUiz1ju6.js.map → vite-BKxEE-ZO.js.map} +1 -1
- package/dist/vite.js +1 -1
- package/package.json +43 -23
- package/src/BrandMark.module.css +25 -0
- package/src/BrandMark.tsx +106 -0
- package/src/BrandMarkScene.module.css +10 -0
- package/src/BrandMarkScene.tsx +116 -0
- package/src/brand-css.d.ts +2 -0
- package/src/brand-model.ts +177 -0
- package/src/brand.ts +3 -0
- package/src/dom.ts +8 -1
- package/src/hot.ts +3 -2
- package/src/lasertag.d.ts +1 -0
- package/src/motion-layout.ts +55 -26
- package/src/motion.ts +3 -0
- package/src/three.ts +69 -22
- package/dist/development/dom-BRFv7FP_.js.map +0 -1
- package/dist/development/three.js.map +0 -1
- package/dist/dom--HZvmgqd.js.map +0 -1
- package/dist/three.js.map +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** @jsxImportSource @atom.io/spa */
|
|
2
|
+
import type * as THREE from "three"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
createDz2OrbitalCamera,
|
|
6
|
+
createDz2OrbitalModel,
|
|
7
|
+
disposeDz2OrbitalModel,
|
|
8
|
+
DZ2_ORBITAL_LIGHTS,
|
|
9
|
+
DZ2_ORBITAL_Y_ROTATION_RADIANS_PER_SECOND,
|
|
10
|
+
} from "./brand-model.ts"
|
|
11
|
+
import css from "./BrandMarkScene.module.css"
|
|
12
|
+
import type { SpaElement } from "./core.ts"
|
|
13
|
+
import { onCleanup, onMount } from "./core.ts"
|
|
14
|
+
import { AmbientLight, Canvas, Group, Mesh, PointLight } from "./three.ts"
|
|
15
|
+
|
|
16
|
+
const canvas = { Canvas }
|
|
17
|
+
export function BrandMarkScene(props: {
|
|
18
|
+
variant: `mark` | `splash`
|
|
19
|
+
width: number
|
|
20
|
+
height: number
|
|
21
|
+
view: Window
|
|
22
|
+
onReady(): void
|
|
23
|
+
onError(error: unknown): void
|
|
24
|
+
}): SpaElement {
|
|
25
|
+
const view = props.view
|
|
26
|
+
const camera = createDz2OrbitalCamera()
|
|
27
|
+
const model = createDz2OrbitalModel()
|
|
28
|
+
const mark = () => props.variant === `mark`
|
|
29
|
+
const narrow = () => view.innerWidth < 680
|
|
30
|
+
let orbital: THREE.Object3D | null = null
|
|
31
|
+
let dirty = true
|
|
32
|
+
const preference = view.matchMedia(`(prefers-reduced-motion: reduce)`)
|
|
33
|
+
const invalidate = () => {
|
|
34
|
+
dirty = true
|
|
35
|
+
}
|
|
36
|
+
onMount(() => {
|
|
37
|
+
preference.addEventListener(`change`, invalidate)
|
|
38
|
+
view.document.addEventListener(`visibilitychange`, invalidate)
|
|
39
|
+
onCleanup(() => {
|
|
40
|
+
preference.removeEventListener(`change`, invalidate)
|
|
41
|
+
view.document.removeEventListener(`visibilitychange`, invalidate)
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
onCleanup(() => {
|
|
45
|
+
disposeDz2OrbitalModel(model)
|
|
46
|
+
})
|
|
47
|
+
return (
|
|
48
|
+
<brand-mark-scene class={css[`class`]}>
|
|
49
|
+
<canvas.Canvas
|
|
50
|
+
camera={camera}
|
|
51
|
+
width={props.width}
|
|
52
|
+
height={props.height}
|
|
53
|
+
dpr={Math.min(
|
|
54
|
+
view.devicePixelRatio || 1,
|
|
55
|
+
mark() ? 2 : 1.35,
|
|
56
|
+
mark()
|
|
57
|
+
? Infinity
|
|
58
|
+
: Math.sqrt(16_000_000 / (props.width * props.height)),
|
|
59
|
+
)}
|
|
60
|
+
rendererOptions={{
|
|
61
|
+
alpha: true,
|
|
62
|
+
antialias: true,
|
|
63
|
+
powerPreference: mark() ? `low-power` : `high-performance`,
|
|
64
|
+
}}
|
|
65
|
+
onError={props.onError}
|
|
66
|
+
onCreated={({ scene, renderer }) => {
|
|
67
|
+
renderer.render(scene, camera)
|
|
68
|
+
props.onReady()
|
|
69
|
+
}}
|
|
70
|
+
onResize={({ width, height }) => {
|
|
71
|
+
camera.aspect = width / height
|
|
72
|
+
camera.updateProjectionMatrix()
|
|
73
|
+
invalidate()
|
|
74
|
+
}}
|
|
75
|
+
renderWhen={() =>
|
|
76
|
+
!view.document.hidden && (dirty || !preference.matches)
|
|
77
|
+
}
|
|
78
|
+
onFrame={({ delta }) => {
|
|
79
|
+
if (view.document.hidden) return
|
|
80
|
+
if (!preference.matches)
|
|
81
|
+
orbital!.rotation.y +=
|
|
82
|
+
Math.min(delta, 0.1) * DZ2_ORBITAL_Y_ROTATION_RADIANS_PER_SECOND
|
|
83
|
+
dirty = false
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<AmbientLight
|
|
87
|
+
color={DZ2_ORBITAL_LIGHTS.ambient.color}
|
|
88
|
+
intensity={DZ2_ORBITAL_LIGHTS.ambient.intensity}
|
|
89
|
+
/>
|
|
90
|
+
<PointLight
|
|
91
|
+
color={DZ2_ORBITAL_LIGHTS.core.color}
|
|
92
|
+
intensity={DZ2_ORBITAL_LIGHTS.core.intensity}
|
|
93
|
+
distance={DZ2_ORBITAL_LIGHTS.core.distance}
|
|
94
|
+
position={DZ2_ORBITAL_LIGHTS.core.position}
|
|
95
|
+
/>
|
|
96
|
+
<Group
|
|
97
|
+
scale={mark() ? 1.25 : narrow() ? 0.52 : 0.72}
|
|
98
|
+
position={[0, !mark() && narrow() ? -0.08 : 0, 0]}
|
|
99
|
+
ref={(node) => {
|
|
100
|
+
orbital = node
|
|
101
|
+
if (node) node.rotation.copy(model.orbital.rotation)
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{model.meshes.map((mesh, index) => (
|
|
105
|
+
<Mesh
|
|
106
|
+
key={index}
|
|
107
|
+
args={[mesh.geometry, mesh.material]}
|
|
108
|
+
position={mesh.position.toArray()}
|
|
109
|
+
rotation={[mesh.rotation.x, mesh.rotation.y, mesh.rotation.z]}
|
|
110
|
+
/>
|
|
111
|
+
))}
|
|
112
|
+
</Group>
|
|
113
|
+
</canvas.Canvas>
|
|
114
|
+
</brand-mark-scene>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as THREE from "three"
|
|
2
|
+
|
|
3
|
+
export const DZ2_ORBITAL_FINAL_SPIN_RADIANS = 1.1
|
|
4
|
+
const DZ2_ORBITAL_SETTLED_ROTATION_X = 1.4
|
|
5
|
+
const DZ2_ORBITAL_SETTLED_ROTATION_Z = -1.4
|
|
6
|
+
export const DZ2_ORBITAL_Y_ROTATION_RADIANS_PER_SECOND = Math.PI / 128
|
|
7
|
+
const DZ2_ORBITAL_LOBE_CENTER_OFFSET = 0.05
|
|
8
|
+
|
|
9
|
+
const DZ2_ORBITAL_CAMERA = {
|
|
10
|
+
fov: 34,
|
|
11
|
+
near: 0.1,
|
|
12
|
+
far: 100,
|
|
13
|
+
position: [4.2, 2.4, 6.6],
|
|
14
|
+
lookAt: [0, 0, 0],
|
|
15
|
+
} satisfies {
|
|
16
|
+
fov: number
|
|
17
|
+
near: number
|
|
18
|
+
far: number
|
|
19
|
+
position: [number, number, number]
|
|
20
|
+
lookAt: [number, number, number]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** @internal Used by contributor tools or implementation tests. */
|
|
24
|
+
export const DZ2_ORBITAL_LIGHTS = {
|
|
25
|
+
core: {
|
|
26
|
+
color: 0xffffff,
|
|
27
|
+
intensity: 28,
|
|
28
|
+
distance: 9,
|
|
29
|
+
position: [1.8, 1.7, 3.5],
|
|
30
|
+
},
|
|
31
|
+
ambient: {
|
|
32
|
+
color: 0x9fd6ff,
|
|
33
|
+
intensity: 1.4,
|
|
34
|
+
},
|
|
35
|
+
} satisfies {
|
|
36
|
+
core: {
|
|
37
|
+
color: number
|
|
38
|
+
intensity: number
|
|
39
|
+
distance: number
|
|
40
|
+
position: [number, number, number]
|
|
41
|
+
}
|
|
42
|
+
ambient: {
|
|
43
|
+
color: number
|
|
44
|
+
intensity: number
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type Dz2OrbitalMesh = THREE.Mesh<THREE.BufferGeometry, THREE.MeshToonMaterial>
|
|
49
|
+
|
|
50
|
+
export type Dz2OrbitalModel = {
|
|
51
|
+
orbital: THREE.Group
|
|
52
|
+
meshes: Dz2OrbitalMesh[]
|
|
53
|
+
materials: {
|
|
54
|
+
lobe: THREE.MeshToonMaterial
|
|
55
|
+
torus: THREE.MeshToonMaterial
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function makeLobeGeometry(direction: 1 | -1): THREE.LatheGeometry {
|
|
60
|
+
const points: THREE.Vector2[] = []
|
|
61
|
+
const height = 1.5
|
|
62
|
+
const radius = 0.75
|
|
63
|
+
for (let index = 0; index <= 44; index++) {
|
|
64
|
+
const progress = index / 45
|
|
65
|
+
const easedRadius =
|
|
66
|
+
radius * Math.sin(Math.PI * progress) ** 0.58 * (0.5 + progress * 0.6)
|
|
67
|
+
|
|
68
|
+
points.push(new THREE.Vector2(easedRadius, direction * progress * height))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (let index = 440; index <= 450; index++) {
|
|
72
|
+
const progress = index / 450
|
|
73
|
+
const easedRadius =
|
|
74
|
+
radius * Math.sin(Math.PI * progress) ** 0.58 * (0.5 + progress * 0.6)
|
|
75
|
+
points.push(new THREE.Vector2(easedRadius, direction * progress * height))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const lastPoint = points[points.length - 1]
|
|
79
|
+
const nextToLastPoint = points[points.length - 2]
|
|
80
|
+
lastPoint.setY(nextToLastPoint.y)
|
|
81
|
+
points[0].setY(points[1].y)
|
|
82
|
+
return new THREE.LatheGeometry(points, 96)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function createDz2OrbitalCamera(aspect = 1): THREE.PerspectiveCamera {
|
|
86
|
+
const camera = new THREE.PerspectiveCamera(
|
|
87
|
+
DZ2_ORBITAL_CAMERA.fov,
|
|
88
|
+
aspect,
|
|
89
|
+
DZ2_ORBITAL_CAMERA.near,
|
|
90
|
+
DZ2_ORBITAL_CAMERA.far,
|
|
91
|
+
)
|
|
92
|
+
camera.position.set(...DZ2_ORBITAL_CAMERA.position)
|
|
93
|
+
camera.lookAt(...DZ2_ORBITAL_CAMERA.lookAt)
|
|
94
|
+
return camera
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function addDz2OrbitalLights(scene: THREE.Scene): void {
|
|
98
|
+
const coreLight = new THREE.PointLight(
|
|
99
|
+
DZ2_ORBITAL_LIGHTS.core.color,
|
|
100
|
+
DZ2_ORBITAL_LIGHTS.core.intensity,
|
|
101
|
+
DZ2_ORBITAL_LIGHTS.core.distance,
|
|
102
|
+
)
|
|
103
|
+
coreLight.position.set(...DZ2_ORBITAL_LIGHTS.core.position)
|
|
104
|
+
scene.add(coreLight)
|
|
105
|
+
scene.add(
|
|
106
|
+
new THREE.AmbientLight(
|
|
107
|
+
DZ2_ORBITAL_LIGHTS.ambient.color,
|
|
108
|
+
DZ2_ORBITAL_LIGHTS.ambient.intensity,
|
|
109
|
+
),
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function setDz2OrbitalRotation(
|
|
114
|
+
orbital: THREE.Object3D,
|
|
115
|
+
y = DZ2_ORBITAL_FINAL_SPIN_RADIANS,
|
|
116
|
+
): void {
|
|
117
|
+
orbital.rotation.set(
|
|
118
|
+
DZ2_ORBITAL_SETTLED_ROTATION_X,
|
|
119
|
+
y,
|
|
120
|
+
DZ2_ORBITAL_SETTLED_ROTATION_Z,
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function createDz2OrbitalModel(): Dz2OrbitalModel {
|
|
125
|
+
const orbital = new THREE.Group()
|
|
126
|
+
setDz2OrbitalRotation(orbital)
|
|
127
|
+
|
|
128
|
+
const lobeMaterial = new THREE.MeshToonMaterial({
|
|
129
|
+
color: 0xff3366,
|
|
130
|
+
emissive: 0xff3366,
|
|
131
|
+
emissiveIntensity: 0.22,
|
|
132
|
+
opacity: 0.82,
|
|
133
|
+
side: THREE.DoubleSide,
|
|
134
|
+
})
|
|
135
|
+
const torusMaterial = new THREE.MeshToonMaterial({
|
|
136
|
+
color: 0x0099ff,
|
|
137
|
+
emissive: 0x0099ff,
|
|
138
|
+
emissiveIntensity: 0.17,
|
|
139
|
+
opacity: 0.72,
|
|
140
|
+
side: THREE.DoubleSide,
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const topLobe: Dz2OrbitalMesh = new THREE.Mesh(
|
|
144
|
+
makeLobeGeometry(1),
|
|
145
|
+
lobeMaterial,
|
|
146
|
+
)
|
|
147
|
+
const bottomLobe: Dz2OrbitalMesh = new THREE.Mesh(
|
|
148
|
+
makeLobeGeometry(-1),
|
|
149
|
+
lobeMaterial,
|
|
150
|
+
)
|
|
151
|
+
topLobe.position.y = DZ2_ORBITAL_LOBE_CENTER_OFFSET
|
|
152
|
+
bottomLobe.position.y = -DZ2_ORBITAL_LOBE_CENTER_OFFSET
|
|
153
|
+
const torus: Dz2OrbitalMesh = new THREE.Mesh(
|
|
154
|
+
new THREE.TorusGeometry(1.2, 0.3, 36, 144),
|
|
155
|
+
torusMaterial,
|
|
156
|
+
)
|
|
157
|
+
torus.rotation.x = Math.PI / 2
|
|
158
|
+
const meshes = [topLobe, bottomLobe, torus]
|
|
159
|
+
orbital.add(...meshes)
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
orbital,
|
|
163
|
+
meshes,
|
|
164
|
+
materials: {
|
|
165
|
+
lobe: lobeMaterial,
|
|
166
|
+
torus: torusMaterial,
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function disposeDz2OrbitalModel(model: Dz2OrbitalModel): void {
|
|
172
|
+
for (const mesh of model.meshes) {
|
|
173
|
+
mesh.geometry.dispose()
|
|
174
|
+
}
|
|
175
|
+
model.materials.lobe.dispose()
|
|
176
|
+
model.materials.torus.dispose()
|
|
177
|
+
}
|
package/src/brand.ts
ADDED
package/src/dom.ts
CHANGED
|
@@ -259,9 +259,16 @@ function mount(
|
|
|
259
259
|
)
|
|
260
260
|
record._end = comment(`]`, parent, at, childOwner, initial)
|
|
261
261
|
} else {
|
|
262
|
+
// Frozen descriptors opt into reuse; mutable props and accessors must refresh.
|
|
263
|
+
const reusable =
|
|
264
|
+
record._value === child &&
|
|
265
|
+
typeof child === `object` &&
|
|
266
|
+
child !== null &&
|
|
267
|
+
Object.isFrozen(child) &&
|
|
268
|
+
Object.isFrozen((child as SpaElement).props)
|
|
262
269
|
record._value = child
|
|
263
270
|
owner._root._presence?.resume(record._scope)
|
|
264
|
-
invalidate(record._scope)
|
|
271
|
+
if (!reusable) invalidate(record._scope)
|
|
265
272
|
}
|
|
266
273
|
record._index = index
|
|
267
274
|
previous = record
|
package/src/hot.ts
CHANGED
|
@@ -47,7 +47,7 @@ function createHotRuntime() {
|
|
|
47
47
|
proxy: null! as Component,
|
|
48
48
|
}
|
|
49
49
|
created.proxy = Object.assign(
|
|
50
|
-
(
|
|
50
|
+
(...args: Parameters<Component>) => {
|
|
51
51
|
if (owner) {
|
|
52
52
|
const root = owner._root
|
|
53
53
|
const view = roots.get(root) ?? mounting
|
|
@@ -57,7 +57,8 @@ function createHotRuntime() {
|
|
|
57
57
|
view.modules.add(id)
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
// Compiled JSX mount helpers can take options after their first argument.
|
|
61
|
+
return created.current(...args)
|
|
61
62
|
},
|
|
62
63
|
{ spa: true },
|
|
63
64
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "lasertag/css-modules"
|
package/src/motion-layout.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface Props {
|
|
|
14
14
|
id?: string | number
|
|
15
15
|
group?: string | number
|
|
16
16
|
scroll?: boolean
|
|
17
|
+
root?: boolean
|
|
17
18
|
transition?: MotionLayoutTransition
|
|
18
19
|
}
|
|
19
20
|
interface LayoutController {
|
|
@@ -29,7 +30,9 @@ interface Entry {
|
|
|
29
30
|
dead: boolean
|
|
30
31
|
node?: IProjectionNode | undefined
|
|
31
32
|
release?: Cleanup | undefined
|
|
32
|
-
|
|
33
|
+
beginStyles?: Cleanup | undefined
|
|
34
|
+
measureStyles?: Cleanup | undefined
|
|
35
|
+
endStyles?: Cleanup | undefined
|
|
33
36
|
captureStyles?: Cleanup | undefined
|
|
34
37
|
identity?: string
|
|
35
38
|
size?: string
|
|
@@ -73,7 +76,11 @@ export function createLayoutController(
|
|
|
73
76
|
const detach = entry.release
|
|
74
77
|
entry.release = undefined
|
|
75
78
|
entry.node = undefined
|
|
76
|
-
entry.
|
|
79
|
+
entry.beginStyles =
|
|
80
|
+
entry.measureStyles =
|
|
81
|
+
entry.endStyles =
|
|
82
|
+
entry.captureStyles =
|
|
83
|
+
undefined
|
|
77
84
|
detach?.()
|
|
78
85
|
}
|
|
79
86
|
const configure = (entry: Entry) => {
|
|
@@ -97,6 +104,7 @@ export function createLayoutController(
|
|
|
97
104
|
}
|
|
98
105
|
entry.node!.setOptions({
|
|
99
106
|
layoutScroll: entry.props.scroll ?? false,
|
|
107
|
+
layoutRoot: entry.props.root ?? false,
|
|
100
108
|
animationType:
|
|
101
109
|
typeof entry.props.animate === `string` ? entry.props.animate : `both`,
|
|
102
110
|
animate: entry.props.animate !== false && !reduced(),
|
|
@@ -154,34 +162,36 @@ export function createLayoutController(
|
|
|
154
162
|
let visibility = ``
|
|
155
163
|
let pointerEvents = ``
|
|
156
164
|
let transform = ``
|
|
165
|
+
let rendered = ``
|
|
157
166
|
const transformTemplate = (_: unknown, projected: string) =>
|
|
158
167
|
`${projected === `none` ? `` : projected} ${transform}`.trim()
|
|
159
168
|
entry.captureStyles = () => {
|
|
160
169
|
style.cssText = element.style.cssText
|
|
161
170
|
}
|
|
162
|
-
entry.
|
|
171
|
+
entry.beginStyles = () => {
|
|
163
172
|
// Resolve authored CSS against today's dimensions, without reading back
|
|
164
173
|
// the opacity and percentage origins written by projection itself.
|
|
165
|
-
|
|
174
|
+
rendered = element.style.cssText
|
|
166
175
|
for (const name of styleNames) restore(name)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
176
|
+
}
|
|
177
|
+
entry.measureStyles = () => {
|
|
178
|
+
const authored = getComputedStyle(element)
|
|
179
|
+
opacity = authored.opacity || `1`
|
|
180
|
+
visibility = authored.visibility
|
|
181
|
+
pointerEvents = authored.pointerEvents
|
|
182
|
+
transform = authored.transform
|
|
183
|
+
if (!visual.values.has(`opacity`))
|
|
184
|
+
node.latestValues[`opacity`] = Number(opacity)
|
|
185
|
+
const origin = authored.transformOrigin.split(` `)
|
|
186
|
+
const width = element.offsetWidth,
|
|
187
|
+
height = element.offsetHeight
|
|
188
|
+
entry.size = `${width}:${height}`
|
|
189
|
+
for (const [key, value] of [
|
|
190
|
+
[`originX`, parseFloat(origin[0]) / (width || 1)],
|
|
191
|
+
[`originY`, parseFloat(origin[1]) / (height || 1)],
|
|
192
|
+
] as const)
|
|
193
|
+
if (!visual.values.has(key) && Number.isFinite(value))
|
|
194
|
+
node.latestValues[key] = value
|
|
185
195
|
// Motion-owned transforms compose in projection; return to authored
|
|
186
196
|
// transforms if that Motion binding is subsequently removed.
|
|
187
197
|
const template =
|
|
@@ -199,6 +209,9 @@ export function createLayoutController(
|
|
|
199
209
|
visual.update(next, null)
|
|
200
210
|
}
|
|
201
211
|
}
|
|
212
|
+
entry.endStyles = () => {
|
|
213
|
+
element.style.cssText = rendered
|
|
214
|
+
}
|
|
202
215
|
const applyProjectionStyles = node.applyProjectionStyles
|
|
203
216
|
node.applyProjectionStyles = (targetStyle, styleProp) => {
|
|
204
217
|
applyProjectionStyles.call(node, targetStyle, {
|
|
@@ -238,14 +251,29 @@ export function createLayoutController(
|
|
|
238
251
|
}
|
|
239
252
|
observer?.observe(element)
|
|
240
253
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
}
|
|
255
|
+
const prepareAll = () => {
|
|
256
|
+
const active = ordered()
|
|
257
|
+
for (const entry of active) prepare(entry)
|
|
258
|
+
const begun: Entry[] = []
|
|
259
|
+
try {
|
|
260
|
+
// Strip every projection before reading any authored style or dimension.
|
|
261
|
+
// Interleaving these phases forces a layout for each registered element.
|
|
262
|
+
for (const entry of active) {
|
|
263
|
+
begun.push(entry)
|
|
264
|
+
entry.beginStyles!()
|
|
265
|
+
}
|
|
266
|
+
for (const entry of active) entry.measureStyles!()
|
|
267
|
+
} finally {
|
|
268
|
+
for (const entry of begun) entry.endStyles!()
|
|
269
|
+
}
|
|
270
|
+
for (const entry of active) configure(entry)
|
|
271
|
+
return active
|
|
244
272
|
}
|
|
245
273
|
const commit = () => {
|
|
246
274
|
try {
|
|
247
275
|
if (dead) return
|
|
248
|
-
|
|
276
|
+
prepareAll()
|
|
249
277
|
const roots = new Set(
|
|
250
278
|
[...entries].flatMap((entry) =>
|
|
251
279
|
entry.node ? [entry.node.root ?? entry.node] : [],
|
|
@@ -314,6 +342,7 @@ export function createLayoutController(
|
|
|
314
342
|
commit,
|
|
315
343
|
beforeUpdate(): Cleanup {
|
|
316
344
|
updating = true
|
|
345
|
+
// Snapshot the rendered projection; resolve authored styles once after the DOM changes.
|
|
317
346
|
for (const entry of ordered()) {
|
|
318
347
|
prepare(entry)
|
|
319
348
|
entry.node!.willUpdate()
|
package/src/motion.ts
CHANGED
|
@@ -113,6 +113,8 @@ export interface MotionAttributes<Kind extends string = `dom`> {
|
|
|
113
113
|
[`motion:layoutId`]?: Kind extends `dom` ? string | number : never
|
|
114
114
|
[`motion:layoutGroup`]?: Kind extends `dom` ? string | number : never
|
|
115
115
|
[`motion:layoutScroll`]?: Kind extends `dom` ? boolean : never
|
|
116
|
+
/** Measure descendants relative to this instantly positioned layout ancestor. */
|
|
117
|
+
[`motion:layoutRoot`]?: Kind extends `dom` ? boolean : never
|
|
116
118
|
[`motion:layoutTransition`]?: Kind extends `dom`
|
|
117
119
|
? MotionLayoutTransition
|
|
118
120
|
: never
|
|
@@ -166,6 +168,7 @@ const layoutKeys = {
|
|
|
166
168
|
layoutId: `id`,
|
|
167
169
|
layoutGroup: `group`,
|
|
168
170
|
layoutScroll: `scroll`,
|
|
171
|
+
layoutRoot: `root`,
|
|
169
172
|
layoutTransition: `transition`,
|
|
170
173
|
} as const
|
|
171
174
|
function equal(a: unknown, b: unknown): boolean {
|