Commit e253797
authored
fix(parity): builder, ground shadow, gizmo wrapper, wordart, doc demos (#61)
* fix(parity): builder placement, ground shadow Z, and gizmo wrapper position
Three follow-up bugs from the three.js parity sweep:
1. Builder zoom + placement. The builder still spoke pre-parity
semantics: passed the unitless slider zoom directly to the camera
(rendered the scene at 0.006× CSS scale), `placeMeshOnFloor`
returned CSS-pixel positions in CSS-axis order, and
`projectScreenToWorldGround` inverted with `1/zoom` instead of
`BASE_TILE/zoom`. Mirrored gallery's `LEGACY_ZOOM_COMPAT` pattern,
flipped placement to world units in world-axis order, and fixed the
inverse scale.
2. React + Vue ground shadow lifted by the mesh. The per-mesh ground
shadow SVG is rendered inside the `.polycss-mesh` wrapper, which
translates by `position * BASE_TILE`. Pre-parity that was a no-op
(position was near zero); post-parity the wrapper now lifts the
shadow by the mesh's world Z, so it landed at the cube's vertical
midpoint instead of the floor. Subtract `meshPosZ * BASE_TILE`
from the projection target's Z so the wrapper translate cancels.
3. TransformControls wrapper placement + drag math. The gizmo wrapper
was emitting `translate3d(position[0]px, position[1]px,
position[2]px)` for a position that's now world units in world-axis
order — so the gizmo sat near scene origin instead of on the mesh.
Apply the world→CSS axis swap + ×BASE_TILE in all three renderers.
Vanilla's axis-drag math also added a CSS-px `t` directly to a
world-unit position with the wrong axis index; divide by
`SCENE_TILE_SIZE` and write to `WORLD_AXIS_FOR_CSS[cssAxis]`.
Vanilla rotation gizmo now uses the world axis the ring visually
wraps, snapshots the start position, and re-translates each tick so
the visible bbox center stays put (matches three.js's pivot-around-
center feel without requiring callers to pre-center via
`loadMesh({ center: true })`). `gizmoPosition` now applies the
current rotation to `centerOffset` so the gizmo follows the
spinning mesh.
* fix(website): wordart zoom scale + doc PolyDemo lighting
WordArt passed the legacy unitless zoom slider value (range ~0.001–1.2)
directly to the camera, which post-parity is px-per-world-unit — scenes
rendered tiny. Multiply by BASE_TILE at the camera boundary so the
existing slider range produces the same on-screen scale as before.
PolyDemo was writing `light-direction` / `light-ambient` / `light-color`
attributes on `<poly-scene>`, but the element reads `directional-direction`
/ `ambient-intensity` / `directional-color` (etc.) — the demo's lighting
config was silently ignored on every docs page, falling back to the
renderer default intensity 1, which is very dim under the post-parity
physical-Lambert (/π) shading. Rename the attributes and bump the default
when callers don't override (4.5 directional, 0.55 ambient — same shape
as Gallery DEFAULT_SCENE). Generator-mode path also splits `state.light`
into `directionalLight` + `ambientLight` for the imperative API.
* test(gizmo): update assertions to post-parity world-unit semantics
Six test cases were pinned to the pre-parity drag math and bbox-center
formula:
- Vanilla `applyAxisDelta` now divides the CSS-px `t` by SCENE_TILE_SIZE
and writes to WORLD_AXIS_FOR_CSS[cssAxis] (world axis), so dragging
the X arrow moves `position[1]` (world Y) by t/50 — not `position[0]`
by t CSS px. Three position-assertion tests updated.
- Vanilla rotation: the X ring is built around WORLD_AXIS_FOR_CSS[0] =
world Y, so the test now expects `rotation[1]` (not [0]) to be the
changed component, with X and Z magnitudes near zero. Renamed from
'(X-axis inverted)' to '(around world Y)' to reflect the new behavior.
- React TransformControls wrapper now applies worldPositionToCss before
adding the CSS-pixel bbox center. Two wrapper-transform assertions
updated for the new pixel-space output.1 parent 8fc77fd commit e253797
13 files changed
Lines changed: 288 additions & 146 deletions
File tree
- packages
- polycss/src/api
- react/src
- controls
- scene
- vue/src
- controls
- scene
- website/src/components
- BuilderWorkbench
- components
- geometry
- WordArtWorkbench
Lines changed: 35 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
252 | 251 | | |
253 | 252 | | |
254 | 253 | | |
255 | 254 | | |
256 | 255 | | |
257 | 256 | | |
258 | | - | |
| 257 | + | |
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
| |||
272 | 271 | | |
273 | 272 | | |
274 | 273 | | |
275 | | - | |
276 | | - | |
277 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
282 | 282 | | |
283 | | - | |
284 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 289 | + | |
291 | 290 | | |
292 | 291 | | |
293 | 292 | | |
| |||
304 | 303 | | |
305 | 304 | | |
306 | 305 | | |
307 | | - | |
308 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
309 | 311 | | |
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
313 | 315 | | |
314 | | - | |
| 316 | + | |
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
| |||
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
345 | | - | |
| 347 | + | |
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
352 | 354 | | |
353 | | - | |
354 | | - | |
355 | | - | |
| 355 | + | |
| 356 | + | |
356 | 357 | | |
357 | 358 | | |
358 | | - | |
359 | | - | |
360 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
361 | 365 | | |
362 | 366 | | |
363 | 367 | | |
364 | 368 | | |
365 | 369 | | |
366 | 370 | | |
367 | 371 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
375 | 377 | | |
376 | 378 | | |
377 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | | - | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
527 | 528 | | |
528 | 529 | | |
529 | 530 | | |
530 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
531 | 544 | | |
532 | 545 | | |
533 | 546 | | |
| |||
729 | 742 | | |
730 | 743 | | |
731 | 744 | | |
732 | | - | |
| 745 | + | |
733 | 746 | | |
734 | 747 | | |
735 | 748 | | |
| |||
756 | 769 | | |
757 | 770 | | |
758 | 771 | | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
764 | 783 | | |
765 | 784 | | |
766 | 785 | | |
767 | 786 | | |
768 | | - | |
769 | 787 | | |
770 | 788 | | |
771 | 789 | | |
| |||
810 | 828 | | |
811 | 829 | | |
812 | 830 | | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
818 | 841 | | |
819 | 842 | | |
820 | 843 | | |
| |||
888 | 911 | | |
889 | 912 | | |
890 | 913 | | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
891 | 918 | | |
892 | 919 | | |
893 | 920 | | |
| |||
896 | 923 | | |
897 | 924 | | |
898 | 925 | | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
907 | 933 | | |
908 | | - | |
909 | | - | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
910 | 941 | | |
911 | 942 | | |
912 | | - | |
913 | | - | |
914 | | - | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
915 | 969 | | |
916 | 970 | | |
917 | 971 | | |
| |||
920 | 974 | | |
921 | 975 | | |
922 | 976 | | |
| 977 | + | |
923 | 978 | | |
924 | 979 | | |
925 | 980 | | |
| |||
0 commit comments