medesign 0.0.0-stage → 1.2.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.
- package/LICENSE +21 -0
- package/README.md +128 -2
- package/bin/medesign.js +200 -0
- package/integrations/claude-code/SKILL.md +20 -0
- package/integrations/cursor/medesign.mdc +26 -0
- package/medesign.config.js +46 -0
- package/package.json +62 -4
- package/presets/apple/design-tokens.css +115 -0
- package/presets/apple/guidelines.md +19 -0
- package/presets/apple/preset.json +53 -0
- package/presets/metha/design-tokens.css +127 -0
- package/presets/metha/guidelines.md +23 -0
- package/presets/metha/preset.json +53 -0
- package/presets/schema.json +102 -0
- package/presets/tesla/design-tokens.css +112 -0
- package/presets/tesla/guidelines.md +17 -0
- package/presets/tesla/preset.json +53 -0
- package/references/ai-tells.md +127 -0
- package/references/appendices.md +220 -0
- package/references/architecture.md +39 -0
- package/references/argon-design-archetypes.md +317 -0
- package/references/banner-sizes-and-styles.md +118 -0
- package/references/block-library.md +61 -0
- package/references/brand-design-tokens.md +42 -0
- package/references/catalog.json +108 -0
- package/references/cip-deliverable-guide.md +95 -0
- package/references/cip-design.md +121 -0
- package/references/cip-prompt-engineering.md +84 -0
- package/references/cip-style-guide.md +68 -0
- package/references/cli-architecture.md +146 -0
- package/references/components.md +240 -0
- package/references/dark-mode.md +23 -0
- package/references/design-core.md +42 -0
- package/references/design-md-protocol.md +75 -0
- package/references/design-routing.md +207 -0
- package/references/eng-imagery-content.md +71 -0
- package/references/eng-layout.md +28 -0
- package/references/eng-other.md +26 -0
- package/references/eng-states-theme.md +22 -0
- package/references/eng-type-color.md +44 -0
- package/references/icon-design.md +122 -0
- package/references/image-mockup-direction.md +53 -0
- package/references/image-to-code.md +46 -0
- package/references/impeccable-polish.md +85 -0
- package/references/intake.md +90 -0
- package/references/logo-color-psychology.md +101 -0
- package/references/logo-design.md +110 -0
- package/references/logo-prompt-engineering.md +158 -0
- package/references/logo-style-guide.md +109 -0
- package/references/mesurv-dna.md +104 -0
- package/references/micro-interactions-and-auto-animate.md +71 -0
- package/references/modern-craft-invariants.md +332 -0
- package/references/motion-tokens.md +99 -0
- package/references/preflight.md +110 -0
- package/references/proactive-motion.md +167 -0
- package/references/quality-gate.md +147 -0
- package/references/redesign-audit.md +38 -0
- package/references/redesign.md +52 -0
- package/references/slides-copywriting-formulas.md +84 -0
- package/references/slides-create.md +4 -0
- package/references/slides-html-template.md +295 -0
- package/references/slides-layout-patterns.md +137 -0
- package/references/slides-strategies.md +94 -0
- package/references/slides.md +42 -0
- package/references/social-photos-design.md +329 -0
- package/references/spatial-canvas-engine.md +160 -0
- package/references/stitch-system.md +184 -0
- package/references/style-extraction.md +17 -0
- package/references/styles/brutalist.md +88 -0
- package/references/styles/minimalist.md +81 -0
- package/references/styles/soft.md +94 -0
- package/references/threeui-spatial-engine.md +224 -0
- package/references/ui-styling-shadcn.md +336 -0
- package/references/ui-ux-vocabulary-vault.json +1223 -0
- package/references/ui-ux-vocabulary-vault.md +438 -0
- package/references/vocab-protocol.md +52 -0
- package/references/vocabulary.md +78 -0
- package/scripts/export-tokens.js +403 -0
- package/tests/browser-audit.js +442 -0
- package/tests/linter.js +412 -0
- package/tests/schemas/sarif-2.1.0.schema.json +2915 -0
- package/tests/visual-testbed.html +681 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## 🔬 Section 5: Style Extraction & Mockup-First Protocol (`/medesign extract`)
|
|
2
|
+
|
|
3
|
+
เมื่อผู้ใช้ส่ง Screenshot, URL, หรือสั่ง `/medesign extract` หรือเปิด Comparison Lab:
|
|
4
|
+
1. **Deconstruct Visual Anatomy:** วิเคราะห์แยกองค์ประกอบ 6 มิติ — Canvas Polarity, Surface Hierarchy, Border/Shadow Mechanism, Typography Pairing & Tracking, Accent Voltage Rule, และ Control Density
|
|
5
|
+
2. **Synthesize Pure Tokens (`DESIGN.md` / `user-profile.json`):** ถอดรหัสเป็น CSS/Tailwind Tokens ล้วนโดยไม่ต้องยึดติดชื่อแบรนด์เดิม
|
|
6
|
+
3. **Mockup-First Confirmation (ห้ามแก้โค้ดโปรดักชันทันที):**
|
|
7
|
+
- สร้างหน้า HTML Live Preview บน Localhost (เช่น Port `3333`) โดยใช้คอนเทนต์จริงจากโปรเจกต์ของผู้ใช้ (เช่น MESURV, Mesnooker)
|
|
8
|
+
- **Dual-Axis Variation (Surface × Spatial Topology):** ห้ามเปลี่ยนแค่สี/ฟอนต์/กรอบบนโครงหน้าเว็บเดิมซ้ำๆ ต้องแยกการเปรียบเทียบเป็น 2 แกนเสมอ:
|
|
9
|
+
- **Axis 1 (Surface Theme DNA):** โทนสี, ฟอนต์, เส้นขอบ, มุมโค้ง, เงา
|
|
10
|
+
- **Axis 2 (Spatial Layout Architecture):** สัดส่วนการจัดวางหน้าต่างที่ต่างกันอย่างสิ้นเชิง (เช่น Top-Nav Fullwidth, Tab-Switched Workspace, 3-Column Editorial, Split-Pane Workbench, Command HUD — ห้ามล็อก Left Sidebar ตายตัวทุกหน้า)
|
|
11
|
+
- **Injected Top-Center Switcher:** ทุกหน้าใน Comparison Lab ต้องมีแถบสลับหน้าลอยตรงกลางด้านบน (`⊞ Home | ← Prev | Dropdown | Next →`) เพื่อให้กดเปลี่ยนหน้าเปรียบเทียบได้ทันที
|
|
12
|
+
- **Live Theme Toggle Safety:** เมื่อทำปุ่มสลับธีมสด (`data-theme`) ต้องประกาศ CSS Selector รองรับทั้ง `:root[data-theme="..."], body[data-theme="..."]` และใช้ JS อัปเดตทั้ง `document.documentElement` และ `document.body` เสมอ
|
|
13
|
+
- รอให้ผู้ใช้กด Confirm หรือระบุจุดที่ต้องการจูนเพิ่ม (Iterative Refinement) ก่อนนำไปเขียนทับ `user-profile.json` และโค้ดจริง
|
|
14
|
+
- เมื่อผู้ใช้ยืนยันและล็อก DNA เสร็จแล้ว ให้สั่งปิดเซิร์ฟเวอร์ทดสอบ (`manage_task(Action='kill')`) ทันทีเพื่อไม่ให้ค้างในระบบ
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
# SKILL: Industrial Brutalism & Tactical Telemetry UI
|
|
3
|
+
|
|
4
|
+
## 1. Skill Meta
|
|
5
|
+
**Name:** Industrial Brutalism & Tactical Telemetry Interface Engineering
|
|
6
|
+
**Description:** Advanced proficiency in architecting web interfaces that synthesize mid-century Swiss Typographic design, industrial manufacturing manuals, and retro-futuristic aerospace/military terminal interfaces. This discipline requires absolute mastery over rigid modular grids, extreme typographic scale contrast, purely utilitarian color palettes, and the programmatic simulation of analog degradation (halftones, CRT scanlines, bitmap dithering). The objective is to construct digital environments that project raw functionality, mechanical precision, and high data density, deliberately discarding conventional consumer UI patterns.
|
|
7
|
+
|
|
8
|
+
## 2. Visual Archetypes
|
|
9
|
+
The design system operates by merging two distinct but highly compatible visual paradigms. **Pick ONE per project and commit to it. Do not alternate or mix both modes within the same interface.**
|
|
10
|
+
|
|
11
|
+
### 2.1 Swiss Industrial Print
|
|
12
|
+
Derived from 1960s corporate identity systems and heavy machinery blueprints.
|
|
13
|
+
* **Characteristics:** High-contrast light modes (newsprint/off-white substrates). Reliance on monolithic, heavy sans-serif typography. Unforgiving structural grids outlined by visible dividing lines. Aggressive, asymmetric use of negative space punctuated by oversized, viewport-bleeding numerals or letterforms. Heavy use of primary red as an alert/accent color.
|
|
14
|
+
|
|
15
|
+
### 2.2 Tactical Telemetry & CRT Terminal
|
|
16
|
+
Derived from classified military databases, legacy mainframes, and aerospace Heads-Up Displays (HUDs).
|
|
17
|
+
* **Characteristics:** Dark mode exclusivity. High-density tabular data presentation. Absolute dominance of monospaced typography. Integration of technical framing devices (ASCII brackets, crosshairs). Application of simulated hardware limitations (phosphor glow, scanlines, low bit-depth rendering).
|
|
18
|
+
|
|
19
|
+
## 3. Typographic Architecture
|
|
20
|
+
Typography is the primary structural and decorative infrastructure. Imagery is secondary. The system demands extreme variance in scale, weight, and spacing.
|
|
21
|
+
|
|
22
|
+
### 3.1 Macro-Typography (Structural Headers)
|
|
23
|
+
* **Classification:** Neo-Grotesque / Heavy Sans-Serif.
|
|
24
|
+
* **Optimal Web Fonts:** Neue Haas Grotesk (Black), Inter (Extra Bold/Black), Archivo Black, Roboto Flex (Heavy), Monument Extended.
|
|
25
|
+
* **Implementation Parameters:**
|
|
26
|
+
* **Scale:** Deployed at massive scales using fluid typography (e.g., `clamp(4rem, 10vw, 15rem)`).
|
|
27
|
+
* **Tracking (Letter-spacing):** Extremely tight, often negative (`-0.03em` to `-0.06em`), forcing glyphs to form solid architectural blocks.
|
|
28
|
+
* **Leading (Line-height):** Highly compressed (`0.85` to `0.95`).
|
|
29
|
+
* **Casing:** Exclusively uppercase for structural impact.
|
|
30
|
+
|
|
31
|
+
### 3.2 Micro-Typography (Data & Telemetry)
|
|
32
|
+
* **Classification:** Monospace / Technical Sans.
|
|
33
|
+
* **Optimal Web Fonts:** JetBrains Mono, IBM Plex Mono, Space Mono, VT323, Courier Prime.
|
|
34
|
+
* **Implementation Parameters:**
|
|
35
|
+
* **Scale:** Fixed and small (`10px` to `14px` / `0.7rem` to `0.875rem`).
|
|
36
|
+
* **Tracking:** Generous (`0.05em` to `0.1em`) to simulate mechanical typewriter spacing or terminal matrices.
|
|
37
|
+
* **Leading:** Standard to tight (`1.2` to `1.4`).
|
|
38
|
+
* **Casing:** Exclusively uppercase. Used for all metadata, navigation, unit IDs, and coordinates.
|
|
39
|
+
|
|
40
|
+
### 3.3 Textural Contrast (Artistic Disruption)
|
|
41
|
+
* **Classification:** High-Contrast Serif.
|
|
42
|
+
* **Optimal Web Fonts:** Playfair Display, EB Garamond, Times New Roman.
|
|
43
|
+
* **Implementation Parameters:** Used exceedingly sparingly. Must be subjected to heavy post-processing (halftone filters, 1-bit dithering) to degrade vector perfection and create textural juxtaposition against the clean sans-serifs.
|
|
44
|
+
|
|
45
|
+
## 4. Color System
|
|
46
|
+
The color architecture is uncompromising. Gradients, soft drop shadows, and modern translucency are strictly prohibited. Colors simulate physical media or primitive emissive displays.
|
|
47
|
+
|
|
48
|
+
**CRITICAL: Choose ONE substrate palette per project and use it consistently. Never mix light and dark substrates within the same interface.**
|
|
49
|
+
|
|
50
|
+
### If Swiss Industrial Print (Light):
|
|
51
|
+
* **Background:** `#F4F4F0` or `#EAE8E3` (Matte, unbleached documentation paper).
|
|
52
|
+
* **Foreground:** `#050505` to `#111111` (Carbon Ink).
|
|
53
|
+
* **Accent:** `#E61919` or `#FF2A2A` (Aviation/Hazard Red). This is the ONLY accent color. Used for strike-throughs, thick structural dividing lines, or vital data highlights.
|
|
54
|
+
|
|
55
|
+
### If Tactical Telemetry (Dark):
|
|
56
|
+
* **Background:** `#0A0A0A` or `#121212` (Deactivated CRT. Avoid pure `#000000`).
|
|
57
|
+
* **Foreground:** `#EAEAEA` (White phosphor). This is the primary text color.
|
|
58
|
+
* **Accent:** `#E61919` or `#FF2A2A` (Aviation/Hazard Red). Same red, same rules.
|
|
59
|
+
* **Terminal Green (`#4AF626`):** Optional. Use ONLY for a single specific UI element (e.g., one status indicator or one data readout) — never as a general text color. If it doesn't serve a clear purpose, omit it entirely.
|
|
60
|
+
|
|
61
|
+
## 5. Layout and Spatial Engineering
|
|
62
|
+
The layout must appear mathematically engineered. It rejects conventional web padding in favor of visible compartmentalization.
|
|
63
|
+
|
|
64
|
+
* **The Blueprint Grid:** Strict adherence to CSS Grid architectures. Elements do not float; they are anchored precisely to grid tracks and intersections.
|
|
65
|
+
* **Visible Compartmentalization:** Extensive utilization of solid borders (`1px` or `2px solid`) to delineate distinct zones of information. Horizontal rules (`<hr>`) frequently span the entire container width to segregate operational units.
|
|
66
|
+
* **Bimodal Density:** Layouts oscillate between extreme data density (tightly packed monospace metadata clustered together) and vast expanses of calculated negative space framing macro-typography.
|
|
67
|
+
* **Geometry:** Absolute rejection of `border-radius`. All corners must be exactly 90 degrees to enforce mechanical rigidity.
|
|
68
|
+
|
|
69
|
+
## 6. UI Components and Symbology
|
|
70
|
+
Standard web UI conventions are replaced with utilitarian, industrial graphic elements.
|
|
71
|
+
|
|
72
|
+
* **Syntax Decoration:** Utilization of ASCII characters to frame data points.
|
|
73
|
+
* *Framing:* `[ DELIVERY SYSTEMS ]`, `< RE-IND >`
|
|
74
|
+
* *Directional:* `>>>`, `///`, `\\\\`
|
|
75
|
+
* **Industrial Markers:** Prominent integration of registration (`®`), copyright (`©`), and trademark (`™`) symbols functioning as structural geometric elements rather than legal text.
|
|
76
|
+
* **Technical Assets:** Integration of crosshairs (`+`) at grid intersections, repeating vertical lines (barcodes), thick horizontal warning stripes, and randomized string data (e.g., `REV 2.6`, `UNIT / D-01`) to simulate active mechanical processes.
|
|
77
|
+
|
|
78
|
+
## 7. Textural and Post-Processing Effects
|
|
79
|
+
To prevent the design from appearing purely digital, simulated analog degradation is engineered into the frontend via CSS and SVG filters.
|
|
80
|
+
|
|
81
|
+
* **Halftone and 1-Bit Dithering:** Transforming continuous-tone images or large serif typography into dot-matrix patterns. Achieved via pre-processing or CSS `mix-blend-mode: multiply` overlays combined with SVG radial dot patterns.
|
|
82
|
+
* **CRT Scanlines:** For terminal interfaces, applying a `repeating-linear-gradient` to the background to simulate horizontal electron beam sweeps (e.g., `repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 4px)`).
|
|
83
|
+
* **Mechanical Noise:** A global, low-opacity SVG static/noise filter applied to the DOM root to introduce a unified physical grain across both dark and light modes.
|
|
84
|
+
|
|
85
|
+
## 8. Web Engineering Directives
|
|
86
|
+
1. **Grid Determinism:** Utilize `display: grid; gap: 1px;` with contrasting parent/child background colors to generate mathematically perfect, razor-thin dividing lines without complex border declarations.
|
|
87
|
+
2. **Semantic Rigidity:** Construct the DOM using precise semantic tags (`<data>`, `<samp>`, `<kbd>`, `<output>`, `<dl>`) to accurately reflect the technical nature of the telemetry.
|
|
88
|
+
3. **Typography Clamping:** Implement CSS `clamp()` functions exclusively for macro-typography to ensure massive text scales aggressively while maintaining structural integrity across viewports.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
# Protocol: Premium Utilitarian Minimalism UI Architect
|
|
3
|
+
|
|
4
|
+
## 1. Protocol Overview
|
|
5
|
+
Name: Premium Utilitarian Minimalism & Editorial UI
|
|
6
|
+
Description: An advanced frontend engineering directive for generating highly refined, ultra-minimalist, "document-style" web interfaces analogous to top-tier workspace platforms. This protocol strictly enforces a high-contrast warm monochrome palette, bespoke typographic hierarchies, meticulous structural macro-whitespace, bento-grid layouts, and an ultra-flat component architecture with deliberate muted pastel accents. It actively rejects standard generic SaaS design trends.
|
|
7
|
+
|
|
8
|
+
## 2. Absolute Negative Constraints (Banned Elements)
|
|
9
|
+
The AI must strictly avoid the following generic web development defaults:
|
|
10
|
+
- DO NOT use the "Inter", "Roboto", or "Open Sans" typefaces.
|
|
11
|
+
- DO NOT use generic, thin-line icon libraries like "Lucide", "Feather", or standard "Heroicons".
|
|
12
|
+
- DO NOT use Tailwind's default heavy drop shadows (e.g., `shadow-md`, `shadow-lg`, `shadow-xl`). Shadows must be practically non-existent or heavily customized to be ultra-diffuse and low opacity (< 0.05).
|
|
13
|
+
- DO NOT use primary colored backgrounds for large elements or sections (e.g., no bright blue, green, or red hero sections).
|
|
14
|
+
- DO NOT use gradients, neon colors, or 3D glassmorphism (beyond subtle navbar blurs).
|
|
15
|
+
- DO NOT use `rounded-full` (pill shapes) for large containers, cards, or primary buttons.
|
|
16
|
+
- DO NOT use emojis anywhere in code, markup, text content, headings, or alt text. Replace with proper icons or clean SVG primitives.
|
|
17
|
+
- DO NOT use generic placeholder names like "John Doe", "Acme Corp", or "Lorem Ipsum". Use realistic, contextual content.
|
|
18
|
+
- DO NOT use AI copywriting clichés: "Elevate", "Seamless", "Unleash", "Next-Gen", "Game-changer", "Delve". Write plain, specific language.
|
|
19
|
+
|
|
20
|
+
## 3. Typographic Architecture
|
|
21
|
+
The interface must rely on extreme typographic contrast and premium font selection to establish an editorial feel.
|
|
22
|
+
- Primary Sans-Serif (Body, UI, Buttons): Use clean, geometric, or system-native fonts with character. Target: `font-family: 'SF Pro Display', 'Geist Sans', 'Helvetica Neue', 'Switzer', sans-serif`.
|
|
23
|
+
- Editorial Serif (Hero Headings & Quotes): Target: `font-family: 'Lyon Text', 'Newsreader', 'Playfair Display', 'Instrument Serif', serif`. Apply tight tracking (`letter-spacing: -0.02em` to `-0.04em`) and tight line-height (`1.1`).
|
|
24
|
+
- Monospace (Code, Keystrokes, Meta-data): Target: `font-family: 'Geist Mono', 'SF Mono', 'JetBrains Mono', monospace`.
|
|
25
|
+
- Text Colors: Body text must never be absolute black (`#000000`). Use off-black/charcoal (`#111111` or `#2F3437`) with a generous `line-height` of `1.6` for legibility. Secondary text should be muted gray (`#787774`).
|
|
26
|
+
|
|
27
|
+
## 4. Color Palette (Warm Monochrome + Spot Pastels)
|
|
28
|
+
Color is a scarce resource, utilized only for semantic meaning or subtle accents.
|
|
29
|
+
- Canvas / Background: Pure White `#FFFFFF` or Warm Bone/Off-White `#F7F6F3` / `#FBFBFA`.
|
|
30
|
+
- Primary Surface (Cards): `#FFFFFF` or `#F9F9F8`.
|
|
31
|
+
- Structural Borders / Dividers: Ultra-light gray `#EAEAEA` or `rgba(0,0,0,0.06)`.
|
|
32
|
+
- Accent Colors: Exclusively use highly desaturated, washed-out pastels for tags, inline code backgrounds, or subtle icon backgrounds.
|
|
33
|
+
- Pale Red: `#FDEBEC` (Text: `#9F2F2D`)
|
|
34
|
+
- Pale Blue: `#E1F3FE` (Text: `#1F6C9F`)
|
|
35
|
+
- Pale Green: `#EDF3EC` (Text: `#346538`)
|
|
36
|
+
- Pale Yellow: `#FBF3DB` (Text: `#956400`)
|
|
37
|
+
|
|
38
|
+
## 5. Component Specifications
|
|
39
|
+
- Bento Box Feature Grids:
|
|
40
|
+
- Utilize asymmetrical CSS Grid layouts.
|
|
41
|
+
- Cards must have exactly `border: 1px solid #EAEAEA`.
|
|
42
|
+
- Border-radius must be crisp: `8px` or `12px` maximum.
|
|
43
|
+
- Internal padding must be generous (e.g., `24px` to `40px`).
|
|
44
|
+
- Primary Call-To-Action (Buttons):
|
|
45
|
+
- Solid background `#111111`, text `#FFFFFF`.
|
|
46
|
+
- Slight border-radius (`4px` to `6px`). No box-shadow.
|
|
47
|
+
- Hover state should be a subtle color shift to `#333333` or a micro-scale `transform: scale(0.98)`.
|
|
48
|
+
- Tags & Status Badges:
|
|
49
|
+
- Pill-shaped (`border-radius: 9999px`), very small typography (`text-xs`), uppercase with wide tracking (`letter-spacing: 0.05em`).
|
|
50
|
+
- Background must use the defined Muted Pastels.
|
|
51
|
+
- Accordions (FAQ):
|
|
52
|
+
- Strip all container boxes. Separate items only with a `border-bottom: 1px solid #EAEAEA`.
|
|
53
|
+
- Use a clean, sharp `+` and `-` icon for the toggle state.
|
|
54
|
+
- Keystroke Micro-UIs:
|
|
55
|
+
- Render shortcuts as physical keys using `<kbd>` tags: `border: 1px solid #EAEAEA`, `border-radius: 4px`, `background: #F7F6F3`, using the Monospace font.
|
|
56
|
+
- Faux-OS Window Chrome:
|
|
57
|
+
- When mocking up software, wrap it in a minimalist container with a white top bar containing three small, light gray circles (replicating macOS window controls).
|
|
58
|
+
|
|
59
|
+
## 6. Iconography & Imagery Directives
|
|
60
|
+
- System Icons: Use "Phosphor Icons (Bold or Fill weights)" or "Radix UI Icons" for a technical, slightly thicker-stroke aesthetic. Standardize stroke width across all icons.
|
|
61
|
+
- Illustrations: Monochromatic, rough continuous-line ink sketches on a white background, featuring a single offset geometric shape filled with a muted pastel color.
|
|
62
|
+
- Photography: Use high-quality, desaturated images with a warm tone. Apply subtle overlays (`opacity: 0.04` warm grain) to blend photos into the monochrome palette. Never use oversaturated stock photos. Use reliable placeholders like `https://picsum.photos/seed/{context}/1200/800` when real assets are unavailable.
|
|
63
|
+
- Hero & Section Backgrounds: Sections should not feel empty and flat. Use subtle full-width background imagery at very low opacity, soft radial light spots (`radial-gradient` with warm tones at `opacity: 0.03`), or minimal geometric line patterns to add depth without breaking the clean aesthetic.
|
|
64
|
+
|
|
65
|
+
## 7. Subtle Motion & Micro-Animations
|
|
66
|
+
Motion should feel invisible — present but never distracting. The goal is quiet sophistication, not spectacle.
|
|
67
|
+
- Scroll Entry: Elements fade in gently as they enter the viewport. Use `translateY(12px)` + `opacity: 0` resolving over `600ms` with `cubic-bezier(0.16, 1, 0.3, 1)`. Use `IntersectionObserver`, never `window.addEventListener('scroll')`.
|
|
68
|
+
- Hover States: Cards lift with an ultra-subtle shadow shift (`box-shadow` transitioning from `0 0 0` to `0 2px 8px rgba(0,0,0,0.04)` over `200ms`). Buttons respond with `scale(0.98)` on `:active`.
|
|
69
|
+
- Staggered Reveals: Lists and grid items enter with a cascade delay (`animation-delay: calc(var(--index) * 80ms)`). Never mount everything at once.
|
|
70
|
+
- Background Ambient Motion: Optional. A single, very slow-moving radial gradient blob (`animation-duration: 20s+`, `opacity: 0.02-0.04`) drifting behind hero sections. Must be applied to a `position: fixed; pointer-events: none` layer. Never on scrolling containers.
|
|
71
|
+
- Performance: Animate exclusively via `transform` and `opacity`. No layout-triggering properties (`top`, `left`, `width`, `height`). Use `will-change: transform` sparingly and only on actively animating elements.
|
|
72
|
+
|
|
73
|
+
## 8. Execution Protocol
|
|
74
|
+
When tasked with writing frontend code (HTML, React, Tailwind, Vue) or designing a layout:
|
|
75
|
+
1. Establish the macro-whitespace first. Use massive vertical padding between sections (e.g., `py-24` or `py-32` in Tailwind).
|
|
76
|
+
2. Constrain the main typography content width to `max-w-4xl` or `max-w-5xl`.
|
|
77
|
+
3. Apply the custom typographic hierarchy and monochromatic color variables immediately.
|
|
78
|
+
4. Ensure every card, divider, and border adheres strictly to the `1px solid #EAEAEA` rule.
|
|
79
|
+
5. Add scroll-entry animations to all major content blocks.
|
|
80
|
+
6. Ensure sections have visual depth through imagery, ambient gradients, or subtle textures — no empty flat backgrounds.
|
|
81
|
+
7. Provide code that reflects this high-end, uncluttered, editorial aesthetic natively without requiring manual adjustments.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
# Agent Skill: Principal UI/UX Architect & Motion Choreographer (Awwwards-Tier)
|
|
3
|
+
|
|
4
|
+
## 1. Meta Information & Core Directive
|
|
5
|
+
- **Persona:** `Vanguard_UI_Architect`
|
|
6
|
+
- **Objective:** You engineer $150k+ agency-level digital experiences, not just websites. Your output must exude haptic depth, cinematic spatial rhythm, obsessive micro-interactions, and flawless fluid motion.
|
|
7
|
+
- **The Variance Mandate:** NEVER generate the exact same layout or aesthetic twice in a row. You must dynamically combine different premium layout archetypes and texture profiles while strictly adhering to the elite "Apple-esque / Linear-tier" design language.
|
|
8
|
+
|
|
9
|
+
## 2. THE "ABSOLUTE ZERO" DIRECTIVE (STRICT ANTI-PATTERNS)
|
|
10
|
+
If your generated code includes ANY of the following, the design instantly fails:
|
|
11
|
+
- **Banned Fonts:** Inter, Roboto, Arial, Open Sans, Helvetica. (Assume premium fonts like `Geist`, `Clash Display`, `PP Editorial New`, or `Plus Jakarta Sans` are available).
|
|
12
|
+
- **Banned Icons:** Standard thick-stroked Lucide, FontAwesome, or Material Icons. Use only ultra-light, precise lines (e.g., Phosphor Light, Remix Line).
|
|
13
|
+
- **Banned Borders & Shadows:** Generic 1px solid gray borders. Harsh, dark drop shadows (`shadow-md`, `rgba(0,0,0,0.3)`).
|
|
14
|
+
- **Banned Layouts:** Edge-to-edge sticky navbars glued to the top. Symmetrical, boring 3-column Bootstrap-style grids without massive whitespace gaps.
|
|
15
|
+
- **Banned Motion:** Standard `linear` or `ease-in-out` transitions. Instant state changes without interpolation.
|
|
16
|
+
|
|
17
|
+
## 3. THE CREATIVE VARIANCE ENGINE
|
|
18
|
+
Before writing code, silently "roll the dice" and select ONE combination from the following archetypes based on the prompt's context to ensure the output is uniquely tailored but always premium:
|
|
19
|
+
|
|
20
|
+
### A. Vibe & Texture Archetypes (Pick 1)
|
|
21
|
+
1. **Ethereal Glass (SaaS / AI / Tech):** Deepest OLED black (`#050505`), radial mesh gradients (e.g., subtle glowing purple/emerald orbs) in the background. Vantablack cards with heavy `backdrop-blur-2xl` and pure white/10 hairlines. Wide geometric Grotesk typography.
|
|
22
|
+
2. **Editorial Luxury (Lifestyle / Real Estate / Agency):** Warm creams (`#FDFBF7`), muted sage, or deep espresso tones. High-contrast Variable Serif fonts for massive headings. Subtle CSS noise/film-grain overlay (`opacity-[0.03]`) for a physical paper feel.
|
|
23
|
+
3. **Soft Structuralism (Consumer / Health / Portfolio):** Silver-grey or completely white backgrounds. Massive bold Grotesk typography. Airy, floating components with unbelievably soft, highly diffused ambient shadows.
|
|
24
|
+
|
|
25
|
+
### B. Layout Archetypes (Pick 1)
|
|
26
|
+
1. **The Asymmetrical Bento:** A masonry-like CSS Grid of varying card sizes (e.g., `col-span-8 row-span-2` next to stacked `col-span-4` cards) to break visual monotony.
|
|
27
|
+
- **Mobile Collapse:** Falls back to a single-column stack (`grid-cols-1`) with generous vertical gaps (`gap-6`). All `col-span` overrides reset to `col-span-1`.
|
|
28
|
+
2. **The Z-Axis Cascade:** Elements are stacked like physical cards, slightly overlapping each other with varying depths of field, some with a subtle `-2deg` or `3deg` rotation to break the digital grid.
|
|
29
|
+
- **Mobile Collapse:** Remove all rotations and negative-margin overlaps below `768px`. Stack vertically with standard spacing. Overlapping elements cause touch-target conflicts on mobile.
|
|
30
|
+
3. **The Editorial Split:** Massive typography on the left half (`w-1/2`), with interactive, scrollable horizontal image pills or staggered interactive cards on the right.
|
|
31
|
+
- **Mobile Collapse:** Converts to a full-width vertical stack (`w-full`). Typography block sits on top, interactive content flows below with horizontal scroll preserved if needed.
|
|
32
|
+
|
|
33
|
+
**Mobile Override (Universal):** Any asymmetric layout above `md:` MUST aggressively fall back to `w-full`, `px-4`, `py-8` on viewports below `768px`. Never use `h-screen` for full-height sections — always use `min-h-[100dvh]` to prevent iOS Safari viewport jumping.
|
|
34
|
+
|
|
35
|
+
## 4. HAPTIC MICRO-AESTHETICS (COMPONENT MASTERY)
|
|
36
|
+
|
|
37
|
+
### A. The "Double-Bezel" (Doppelrand / Nested Architecture)
|
|
38
|
+
Never place a premium card, image, or container flatly on the background. They must look like physical, machined hardware (like a glass plate sitting in an aluminum tray) using nested enclosures.
|
|
39
|
+
- **Outer Shell:** A wrapper `div` with a subtle background (`bg-black/5` or `bg-white/5`), a hairline outer border (`ring-1 ring-black/5` or `border border-white/10`), a specific padding (e.g., `p-1.5` or `p-2`), and a large outer radius (`rounded-[2rem]`).
|
|
40
|
+
- **Inner Core:** The actual content container inside the shell. It has its own distinct background color, its own inner highlight (`shadow-[inset_0_1px_1px_rgba(255,255,255,0.15)]`), and a mathematically calculated smaller radius (e.g., `rounded-[calc(2rem-0.375rem)]`) for concentric curves.
|
|
41
|
+
|
|
42
|
+
### B. Nested CTA & "Island" Button Architecture
|
|
43
|
+
- **Structure:** Primary interactive buttons must be fully rounded pills (`rounded-full`) with generous padding (`px-6 py-3`).
|
|
44
|
+
- **The "Button-in-Button" Trailing Icon:** If a button has an arrow (`↗`), it NEVER sits naked next to the text. It must be nested inside its own distinct circular wrapper (e.g., `w-8 h-8 rounded-full bg-black/5 dark:bg-white/10 flex items-center justify-center`) placed completely flush with the main button's right inner padding.
|
|
45
|
+
|
|
46
|
+
### C. Spatial Rhythm & Tension
|
|
47
|
+
- **Macro-Whitespace:** Double your standard padding. Use `py-24` to `py-40` for sections. Allow the design to breathe heavily.
|
|
48
|
+
- **Eyebrow Tags:** Precede major H1/H2s with a microscopic, pill-shaped badge (`rounded-full px-3 py-1 text-[10px] uppercase tracking-[0.2em] font-medium`).
|
|
49
|
+
|
|
50
|
+
## 5. MOTION CHOREOGRAPHY (FLUID DYNAMICS)
|
|
51
|
+
Never use default transitions. All motion must simulate real-world mass and spring physics. Use custom cubic-beziers (e.g., `transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)]`).
|
|
52
|
+
|
|
53
|
+
### A. The "Fluid Island" Nav & Hamburger Reveal
|
|
54
|
+
- **Closed State:** The Navbar is a floating glass pill detached from the top (`mt-6`, `mx-auto`, `w-max`, `rounded-full`).
|
|
55
|
+
- **The Hamburger Morph:** On click, the 2 or 3 lines of the hamburger icon must fluidly rotate and translate to form a perfect 'X' (`rotate-45` and `-rotate-45` with absolute positioning), not just disappear.
|
|
56
|
+
- **The Modal Expansion:** The menu should open as a massive, screen-filling overlay with a heavy glass effect (`backdrop-blur-3xl bg-black/80` or `bg-white/80`).
|
|
57
|
+
- **Staggered Mask Reveal:** The navigation links inside the expanded state do not just appear. They fade in and slide up from an invisible box (`translate-y-12 opacity-0` to `translate-y-0 opacity-100`) with a staggered delay (`delay-100`, `delay-150`, `delay-200` for each item).
|
|
58
|
+
|
|
59
|
+
### B. Magnetic Button Hover Physics
|
|
60
|
+
- Use the `group` utility. On hover, do not just change the background color.
|
|
61
|
+
- Scale the entire button down slightly (`active:scale-[0.98]`) to simulate physical pressing.
|
|
62
|
+
- The nested inner icon circle should translate diagonally (`group-hover:translate-x-1 group-hover:-translate-y-[1px]`) and scale up slightly (`scale-105`), creating internal kinetic tension.
|
|
63
|
+
|
|
64
|
+
### C. Scroll Interpolation (Entry Animations)
|
|
65
|
+
- Elements never appear statically on load. As they enter the viewport, they must execute a gentle, heavy fade-up (`translate-y-16 blur-md opacity-0` resolving to `translate-y-0 blur-0 opacity-100` over 800ms+).
|
|
66
|
+
- For JavaScript-driven scroll reveals, use `IntersectionObserver` or Framer Motion's `whileInView`. Never use `window.addEventListener('scroll')` — it causes continuous reflows and kills mobile performance.
|
|
67
|
+
|
|
68
|
+
## 6. PERFORMANCE GUARDRAILS
|
|
69
|
+
- **GPU-Safe Animation:** Never animate `top`, `left`, `width`, or `height`. Animate exclusively via `transform` and `opacity`. Use `will-change: transform` sparingly and only on elements that are actively animating.
|
|
70
|
+
- **Blur Constraints:** Apply `backdrop-blur` only to fixed or sticky elements (navbars, overlays). Never apply blur filters to scrolling containers or large content areas — this causes continuous GPU repaints and severe mobile frame drops.
|
|
71
|
+
- **Grain/Noise Overlays:** Apply noise textures exclusively to fixed, `pointer-events-none` pseudo-elements (`position: fixed; inset: 0; z-index: 50`). Never attach them to scrolling containers.
|
|
72
|
+
- **Z-Index Discipline:** Do not use arbitrary `z-50` or `z-[9999]`. Reserve z-indexes strictly for systemic layers: sticky nav, modals, overlays, tooltips.
|
|
73
|
+
|
|
74
|
+
## 7. EXECUTION PROTOCOL
|
|
75
|
+
When generating UI code, follow this exact sequence:
|
|
76
|
+
1. **[SILENT THOUGHT]** Roll the Variance Engine (Section 3). Choose your Vibe and Layout Archetypes based on the prompt's context to ensure a unique output.
|
|
77
|
+
2. **[SCAFFOLD]** Establish the background texture, macro-whitespace scale, and massive typography sizes.
|
|
78
|
+
3. **[ARCHITECT]** Build the DOM strictly using the "Double-Bezel" (Doppelrand) technique for all major cards, inputs, and feature grids. Use exaggerated squircle radii (`rounded-[2rem]`).
|
|
79
|
+
4. **[CHOREOGRAPH]** Inject the custom `cubic-bezier` transitions, the staggered navigation reveals, and the button-in-button hover physics.
|
|
80
|
+
5. **[OUTPUT]** Deliver flawless, pixel-perfect React/Tailwind/HTML code. Do not include basic, generic fallbacks.
|
|
81
|
+
|
|
82
|
+
## 8. PRE-OUTPUT CHECKLIST
|
|
83
|
+
Evaluate your code against this matrix before delivering. This is the last filter.
|
|
84
|
+
- [ ] No banned fonts, icons, borders, shadows, layouts, or motion patterns from Section 2 are present
|
|
85
|
+
- [ ] A Vibe Archetype and Layout Archetype from Section 3 were consciously selected and applied
|
|
86
|
+
- [ ] All major cards and containers use the Double-Bezel nested architecture (outer shell + inner core)
|
|
87
|
+
- [ ] CTA buttons use the Button-in-Button trailing icon pattern where applicable
|
|
88
|
+
- [ ] Section padding is at minimum `py-24` — the layout breathes heavily
|
|
89
|
+
- [ ] All transitions use custom cubic-bezier curves — no `linear` or `ease-in-out`
|
|
90
|
+
- [ ] Scroll entry animations are present — no element appears statically
|
|
91
|
+
- [ ] Layout collapses gracefully below `768px` to single-column with `w-full` and `px-4`
|
|
92
|
+
- [ ] All animations use only `transform` and `opacity` — no layout-triggering properties
|
|
93
|
+
- [ ] `backdrop-blur` is only applied to fixed/sticky elements, never to scrolling content
|
|
94
|
+
- [ ] The overall impression reads as "$150k agency build", not "template with nice fonts"
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# ThreeUI Spatial 3D & Procedural WebGL Engine Guide
|
|
2
|
+
|
|
3
|
+
องค์ความรู้ สถาปัตยกรรมระดับ Production และคู่มือเทคนิคการสร้างหน้าเว็บ 3D / Spatial UI แบบ Zero-Heavy-Asset ที่ถอดรหัสจาก **ThreeUI (Meng To / DesignCode)** ออกแบบมาสำหรับการทำงานร่วมกับ AI Coding Agents โดยเฉพาะ
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. ปรัชญาและโครงสร้าง Dual-Layer Architecture
|
|
8
|
+
|
|
9
|
+
ปัญหาหลักของการนำ Three.js / WebGL มาใส่ในเว็บแอปพลิเคชันยุคใหม่ (React 19 / Next.js) คือ:
|
|
10
|
+
- **Virtual DOM Conflict**: การ re-render ของ React ทำลาย WebGL context หรือเกิด Double-Mounting ใน StrictMode
|
|
11
|
+
- **Heavy Asset Penalty**: โมเดล 3D (.gltf/.glb) มีขนาดใหญ่ (10-50MB) โหลดช้า และกินหน่วยความจำ GPU มหาศาล
|
|
12
|
+
- **AI Coding Fragility**: เมื่อ AI พยายามเขียน Canvas, Shaders, และ React state ปนกัน มักเกิดข้อผิดพลาดด้าน Memory Leak และ Event Listeners
|
|
13
|
+
|
|
14
|
+
### ThreeUI Architectural Solution:
|
|
15
|
+
ThreeUI แก้ปัญหานี้ด้วย **Dual-Layer Sandbox Frame**:
|
|
16
|
+
1. **Outer Layer (React Host Component)**: ตัวครอบเบาๆ เช่น `LandingPageFrame.tsx` ทำหน้าที่รับ Props จากผู้ใช้ (Typography, Colors, Camera tilt, Shader sliders) และเรนเดอร์ `<iframe>` แบบ Sandboxed
|
|
17
|
+
2. **Inner Layer (Standalone Authored Document)**: หน้า HTML อิสระ (เช่น `kage.html`, `sylva.html`) ที่บรรจุ Three.js runtime, Procedural Geometry, และ Event Listeners ของตัวเองแบบ Isolated 100%
|
|
18
|
+
3. **The Communication Bridge**: React Host จะไม่ยุ่งกับโค้ด JavaScript ข้างใน แต่จะฉีด Dynamic CSS Tokens (`:root { --ink: ... }`) หรือส่งข้อความผ่าน postMessage เข้าไปยัง iframe head ทำให้เปลี่ยนสี, ปรับฟอนต์, และจูนสไตล์ได้แบบ Real-time โดยไม่ทำลาย WebGL context
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. Agentic Prompt Contract Standard (มาตรฐานคำสั่ง AI Agent)
|
|
23
|
+
|
|
24
|
+
เมื่อต้องการส่งคำสั่งให้ AI Coding Agent (Cursor, Claude Code, Antigravity) นำ 3D Component หรือ Landing Page ไปติดตั้ง ให้ใช้รูปแบบสัญญาที่มีความแม่นยำสูง (High-Fidelity Prompt Contract):
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
# Integrate <[ComponentName] /> from ThreeUI using its exact source
|
|
28
|
+
|
|
29
|
+
Component: `[ComponentName]`
|
|
30
|
+
Runtime: Full HTML + DOM/CSS + Three.js
|
|
31
|
+
Source revision: `SHA-256 [Commit/Document Hash]`
|
|
32
|
+
|
|
33
|
+
## Current configured usage
|
|
34
|
+
```tsx
|
|
35
|
+
import { [ComponentName] } from "@/components/threeui/[ComponentName]";
|
|
36
|
+
|
|
37
|
+
export function Scene() {
|
|
38
|
+
return (
|
|
39
|
+
<div className="shader-frame">
|
|
40
|
+
<[ComponentName]
|
|
41
|
+
primaryColor="#e0231c"
|
|
42
|
+
headingFont="onest"
|
|
43
|
+
bodyFont="onest"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Exact implementation source
|
|
51
|
+
Canonical HTML: [slug.html](https://threeui.com/landing-pages/[slug].html)
|
|
52
|
+
Bundle URL: https://threeui.com/source-code/[slug].json
|
|
53
|
+
|
|
54
|
+
Required registered files:
|
|
55
|
+
- `LandingPages.tsx` — component · SHA-256 [hash]
|
|
56
|
+
- `LandingPageFrame.tsx` — frame-component · SHA-256 [hash]
|
|
57
|
+
- `pageTypography.ts` — controls-source · SHA-256 [hash]
|
|
58
|
+
- `public/landing-pages/[slug].html` — canonical-source · SHA-256 [hash]
|
|
59
|
+
|
|
60
|
+
## Implementation requirements
|
|
61
|
+
- Preserve the authored structure, styling, shaders, motion, and asset paths described by the source.
|
|
62
|
+
- Do not recreate from preview or screenshot; fetch the registered source bundle.
|
|
63
|
+
- Maintain battery & GPU hygiene (IntersectionObserver throttling).
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 3. สถาปัตยกรรม LandingPageFrame & Dynamic CSS Retoner
|
|
69
|
+
|
|
70
|
+
### 3.1 ตัวอย่างโครงสร้าง Frame Host (`LandingPageFrame.tsx`)
|
|
71
|
+
```tsx
|
|
72
|
+
import { useEffect, useRef, useState, type CSSProperties } from "react";
|
|
73
|
+
|
|
74
|
+
export type LandingPageFrameProps = {
|
|
75
|
+
sourceUrl: string;
|
|
76
|
+
srcDoc?: string;
|
|
77
|
+
title: string;
|
|
78
|
+
className?: string;
|
|
79
|
+
style?: CSSProperties;
|
|
80
|
+
backgroundCanvasSelector?: string; // ถ้ากำหนด จะเปิดโหมด Scene-Only Background
|
|
81
|
+
customization?: {
|
|
82
|
+
css: string;
|
|
83
|
+
fonts: string[];
|
|
84
|
+
filter?: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export function LandingPageFrame({
|
|
89
|
+
sourceUrl,
|
|
90
|
+
srcDoc,
|
|
91
|
+
title,
|
|
92
|
+
backgroundCanvasSelector,
|
|
93
|
+
customization,
|
|
94
|
+
className = "",
|
|
95
|
+
style,
|
|
96
|
+
}: LandingPageFrameProps) {
|
|
97
|
+
const frameRef = useRef<HTMLIFrameElement>(null);
|
|
98
|
+
|
|
99
|
+
// เมื่อ iframe โหลดเสร็จ หรือค่า customization เปลี่ยน ให้ฉีด CSS เข้า head โดยตรง
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const frame = frameRef.current;
|
|
102
|
+
if (!frame || !frame.contentDocument) return;
|
|
103
|
+
|
|
104
|
+
const doc = frame.contentDocument;
|
|
105
|
+
let styleTag = doc.getElementById("threeui-dynamic-overrides");
|
|
106
|
+
if (!styleTag) {
|
|
107
|
+
styleTag = doc.createElement("style");
|
|
108
|
+
styleTag.id = "threeui-dynamic-overrides";
|
|
109
|
+
doc.head.appendChild(styleTag);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let css = customization?.css ?? "";
|
|
113
|
+
// หากเป็นโหมด Background ให้ซ่อน UI elements ทั้งหมดยกเว้น Canvas
|
|
114
|
+
if (backgroundCanvasSelector) {
|
|
115
|
+
css += `
|
|
116
|
+
.page, header, footer, nav, .hero-content { display: none !important; }
|
|
117
|
+
body { background: transparent !important; overflow: hidden !important; }
|
|
118
|
+
${backgroundCanvasSelector} { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; }
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
styleTag.textContent = css;
|
|
122
|
+
}, [customization, backgroundCanvasSelector]);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<iframe
|
|
126
|
+
ref={frameRef}
|
|
127
|
+
title={title}
|
|
128
|
+
src={srcDoc ? undefined : sourceUrl}
|
|
129
|
+
srcDoc={srcDoc}
|
|
130
|
+
className={`threeui-frame ${className}`}
|
|
131
|
+
style={{ width: "100%", height: "100%", border: 0, ...style }}
|
|
132
|
+
loading="lazy"
|
|
133
|
+
sandbox="allow-scripts allow-same-origin"
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 4. Zero-Heavy-Asset Procedural 3D & 2.5D Parallax System
|
|
142
|
+
|
|
143
|
+
ThreeUI หลีกเลี่ยงไฟล์ 3D หนักๆ โดยใช้เทคนิคผสมผสานระหว่างคณิตศาสตร์และรูปภาพแบนด์วิธต่ำ:
|
|
144
|
+
|
|
145
|
+
1. **Procedural Meshes**:
|
|
146
|
+
- ภูมิประเทศ ท้องฟ้า และเมฆ สร้างจาก `THREE.PlaneGeometry` หรือ `THREE.SphereGeometry` แล้วบิดรูปทรงด้วย Simplex / Perlin Noise บน Vertex Shader
|
|
147
|
+
2. **2.5D WebP Layered Depth Sprites**:
|
|
148
|
+
- องค์ประกอบฉากหน้า (ต้นสน, ซุ้มประตู, หิน, กิ่งซากุระ, โคมไฟ) บันทึกเป็นรูป WebP พร้อม Alpha Channel แยกชิ้น
|
|
149
|
+
- นำมาวางบน `THREE.Mesh(new THREE.PlaneGeometry(...), material)` จัดเรียงความลึกบนแกน Z พร้อมเปิด `material.transparent = true; material.depthWrite = false;`
|
|
150
|
+
- ผลลัพธ์: ได้ความสมจริงระดับงานศิลปะ แต่ขนาดรวมทั้งหน้าเว็บไม่เกิน 2-3 MB
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 5. มาตรฐาน GPU & Battery Hygiene (กฎเหล็ก Production)
|
|
155
|
+
|
|
156
|
+
เมื่อนำ Three.js หรือ WebGL มาใช้ ต้องมี 3 กฎเหล็กเสมอ:
|
|
157
|
+
1. **Intersection Throttling**:
|
|
158
|
+
```javascript
|
|
159
|
+
const intersection = new IntersectionObserver(([entry]) => {
|
|
160
|
+
visible = entry?.isIntersecting ?? true;
|
|
161
|
+
if (visible && !frameId) frameId = requestAnimationFrame(render);
|
|
162
|
+
if (!visible && frameId) { cancelAnimationFrame(frameId); frameId = 0; }
|
|
163
|
+
});
|
|
164
|
+
intersection.observe(container);
|
|
165
|
+
```
|
|
166
|
+
2. **DevicePixelRatio Clamping**:
|
|
167
|
+
- ห้ามใช้ `window.devicePixelRatio` ดิบๆ บนจอ 4K/Retina
|
|
168
|
+
- กำหนด: `const pixelRatio = Math.min(window.devicePixelRatio || 1, 2);`
|
|
169
|
+
3. **Linear Color Space & Tone Mapping**:
|
|
170
|
+
- `renderer.toneMapping = THREE.ACESFilmicToneMapping;`
|
|
171
|
+
- `renderer.toneMappingExposure = 1.0;`
|
|
172
|
+
- `renderer.outputColorSpace = THREE.SRGBColorSpace;`
|
|
173
|
+
4. **Uncompressed VRAM Budget Gate (≤ 32MB) & Modern Compression**:
|
|
174
|
+
- ปัญหาของ Draco คือไฟล์ดาวน์โหลดเล็กแต่เมื่อคลายบีบอัดบน GPU จะขยายร่างเป็น 60MB–140MB บน VRAM จนทำให้ Safari บน iOS สั่ง Kill Tab
|
|
175
|
+
- **กฎเหล็กใหม่:** คุมหน่วยความจำ **Uncompressed VRAM Footprint รวมไม่เกิน 32MB**
|
|
176
|
+
- บังคับใช้ **Meshopt Compression** (คลายบีบอัดเร็วกว่า Draco 5 เท่า ขนาด WASM Decoder เพียง 20KB ไม่ทำให้ Main-Thread ค้าง)
|
|
177
|
+
- พื้นผิว Texture บังคับใช้ **KTX2 (Basis Universal UASTC/ETC1S)** เพราะถูกส่งตรงไปยัง VRAM ในสถานะบีบอัดได้ทันทีโดยไม่ต้องแตกไฟล์เป็น Bitmap ขนาดใหญ่
|
|
178
|
+
5. **Clean Lifecycle Disposal & Context Leak Prevention**:
|
|
179
|
+
- เมื่อ Component ถูก Unmount ต้องสั่ง Dispose ทรัพยากร GPU ทั้งหมดเพื่อป้องกัน Memory Leaks:
|
|
180
|
+
```javascript
|
|
181
|
+
geometry?.dispose();
|
|
182
|
+
material?.dispose();
|
|
183
|
+
texture?.dispose();
|
|
184
|
+
renderer?.dispose();
|
|
185
|
+
renderer?.forceContextLoss();
|
|
186
|
+
```
|
|
187
|
+
6. **DOM Overlay & Canvas Pointer-Events Layering**:
|
|
188
|
+
- Canvas ฉากหลัง: `position: fixed; inset: 0; z-index: 0; pointer-events: auto;`
|
|
189
|
+
- UI Container ซ้อนทับ: `position: relative; z-index: 10; pointer-events: none;`
|
|
190
|
+
- ปุ่ม/ลิงก์/ฟอร์มที่กดได้: `pointer-events: auto;` (เพื่อให้ Pointer Event ของการหมุน Orbit ทะลุช่องว่างระหว่างปุ่มลงสู่ Canvas ได้ราบรื่น)
|
|
191
|
+
7. **On-Demand WebGL Render Loop (0W GPU Idle Power)**:
|
|
192
|
+
- สำหรับฉากที่ไม่ต้องการ Render คลื่นน้ำหรือแสงกระพริบตลอดเวลา บังคับใช้ `frameloop="demand"`
|
|
193
|
+
- ตัดลูป `requestAnimationFrame` ทันทีเมื่อความเร็วการหมุนหรือซูม $\lvert v \rvert < 0.0001$ เพื่อให้ GPU ใช้พลังงานเป็น **0 วัตต์** ประหยัดแบตเตอรี่สูงสุด
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 6. Curated Recipe Vault (สูตรแม่แบบยอดนิยม)
|
|
198
|
+
|
|
199
|
+
### 1. Kage (Kyoto Night Temple Walk)
|
|
200
|
+
- **Concept**: วัดบนภูเขาเกียวโตยามค่ำคืน เปลวไฟโคมหิน และดวงจันทร์สีชาด
|
|
201
|
+
- **Colors**: Ink Black `#05070a`, Pale Sage Bone `#dfe7e0`, Vermilion `#e0231c`, Gold `#c9a24a`
|
|
202
|
+
- **Fog**: `scene.fog = new THREE.FogExp2(0x050a0e, 0.0168);`
|
|
203
|
+
- **Lighting**: PCF Soft Shadows + Multi-point Lantern flickering lights
|
|
204
|
+
- **Typography**: Onest font (Weight 300 / 400), tracking `-0.012em`
|
|
205
|
+
|
|
206
|
+
### 2. Kibori (Japanese Wooden Sculpture)
|
|
207
|
+
- **Concept**: งานช่างไม้แกะสลัก ริ้วเนื้อไม้ธรรมชาติ แสงและเงาที่อบอุ่น
|
|
208
|
+
- **Colors**: Deep Cedar `#1a1512`, Hinoki `#d4b28c`, Charcoal `#2c2825`
|
|
209
|
+
- **Material**: Procedural wood grain bump shaders with subtle ambient occlusion
|
|
210
|
+
|
|
211
|
+
### 3. Meng To Sketchbook (Botanical Watercolor Parallax)
|
|
212
|
+
- **Concept**: สมุดบันทึกพฤกษศาสตร์ กระดาษวาชิ และภาพสีน้ำแยกเลเยอร์
|
|
213
|
+
- **Colors**: Paper Ivory `#fcfbf7`, Sumi Ink `#1b1b19`, Botanical Green `#405943`
|
|
214
|
+
- **Technique**: Multi-layer 2D canvas blending with drifting procedural petal particles
|
|
215
|
+
|
|
216
|
+
### 4. Sylva / Inner Green (Living Forest World)
|
|
217
|
+
- **Concept**: โลกธรรมชาติป่าดิบ การฟื้นฟูระบบนิเวศ
|
|
218
|
+
- **Colors**: Forest Moss `#383b34`, Pale Card `#f2f3ef`, Deep Earth `#23261f`
|
|
219
|
+
- **Unit System**: `calc(100vw / 1600)` เพื่อให้สัดส่วนของฉากสมมาตรเป๊ะทุกความกว้างจอ
|
|
220
|
+
|
|
221
|
+
### 5. Sable / Ascii Vortex
|
|
222
|
+
- **Concept**: อุโมงค์ตัวอักษรและพายุดูดข้อมูล (AI Agent Interface)
|
|
223
|
+
- **Colors**: Pitch Black `#000000`, Monospace White `#ffffff`, Terminal Green
|
|
224
|
+
- **Technique**: Raymarched glyph sampling, pointer suction well, dynamic font dissolution
|