Communitygithub.com

Pascal Editor 整合

使用 Pascal Editor 的架構(React Three Fiber + Zustand 場景圖)來建構和擴展 3D 建築編輯器應用程式。適用於:建構 3D 建築工具、建立類似 BIM 的編輯器、擴展 Pascal Editor 的自訂功能、建立樓層平面圖產生器。

Pascal Editor 整合 是什麼?

此技能詳細說明如何整合並擴充 Pascal Editor(一個基於 React Three Fiber 和 WebGPU 的開源 3D 建築編輯器)。它提供了一個以節點為基礎的場景圖、Zustand 狀態管理以及一個適合 AI 驅動建築生成的系統架構。技能涵蓋核心 API,用於建立、操作和匯出建築幾何形狀,包括牆壁、樓板、樓層、房間區域以及門窗開口。它更進一步說明如何註冊自訂驗證系統(例如牆壁厚度檢查)以及如何將場景匯出為 JSON。支援的平台包括 React、Next.js 和任何使用 npm 的 JavaScript 環境。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/pascal-editor

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Pascal Editor 整合 是做什麼的?

概述

Pascal Editor (pascalorg/editor) 是一個基於 React Three Fiber 和 WebGPU 建構的開源 3D 建築編輯器。它提供了基於節點的場景圖、Zustand 狀態管理,以及適合 AI 驅動建築生成的系統架構。此技能涵蓋了用於建立、操作和匯出建築幾何形狀的核心 API。

指示

快速開始

npx create-next-app@latest my-building-app
cd my-building-app
npm install @pascal-app/core @pascal-app/ui @react-three/fiber @react-three/drei three zustand

節點階層

Pascal 使用型別化節點的樹狀結構:

Site -> Building -> Level -> Wall -> Opening (door/window)
                          -> Slab (floor/ceiling)
                          -> Zone (room boundary)
                          -> Item (furniture, fixture)

每個節點都包含:id(UUID)、type、parentId、children(子節點 ID)、props(型別特定屬性)以及 dirty(標記需要重建)。

Zustand 狀態儲存庫

import { useScene, useViewer, useEditor } from '@pascal-app/core'

// useScene -- 場景圖(節點、關係)
const { nodes, createNode, updateNode, deleteNode } = useScene()

// useViewer -- 視窗狀態(相機、選取)
const { selectedIds, camera, setSelection } = useViewer()

// useEditor -- 工具模式和 UI 狀態
const { activeTool, setTool, history } = useEditor()

建立帶有開口的牆壁

const scene = useScene.getState()

// 外牆:長 4.5 公尺,厚 200 公釐,天花板高 2.7 公尺
const wall = await scene.createNode({
  type: 'wall',
  props: {
    start: { x: 0, y: 0 }, end: { x: 4.5, y: 0 },
    thickness: 0.20, height: 2.7,
    isExterior: true, material: 'masonry',
  }
}, levelId)

// 新增窗戶:寬 1.2 公尺,窗臺高度 900 公釐
await scene.createNode({
  type: 'item',
  props: {
    itemType: 'window', wallId: wall.id,
    offsetFromStart: 1.5, width: 1.2, height: 1.2, sillHeight: 0.9,
  }
}, wall.id)

// 新增門:寬 900 公釐
await scene.createNode({
  type: 'item',
  props: {
    itemType: 'door', wallId: wall.id,
    offsetFromStart: 3.0, width: 0.9, height: 2.1, sillHeight: 0,
  }
}, wall.id)

建立樓層與房間

const level = await scene.createNode({
  type: 'level',
  props: { name: 'Ground Floor', elevation: 0, height: 2.7, index: 0 }
}, buildingId)

// 樓板
await scene.createNode({
  type: 'slab',
  props: {
    polygon: [{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 10, y: 8 }, { x: 0, y: 8 }],
    thickness: 0.25, isRoof: false,
  }
}, level.id)

// 用於標籤和面積計算的房間區域
await scene.createNode({
  type: 'zone',
  props: {
    name: 'Living Room', roomType: 'living',
    polygon: [{ x: 0.1, y: 0.1 }, { x: 5.4, y: 0.1 }, { x: 5.4, y: 7.9 }, { x: 0.1, y: 7.9 }],
  }
}, level.id)

將場景匯出為 JSON

function exportScene(): BuildingExport {
  const { nodes } = useScene.getState()
  const allNodes = Object.values(nodes)
  const site = allNodes.find(n => n.type === 'site')
  const building = allNodes.find(n => n.type === 'building')
  const levels = allNodes
    .filter(n => n.type === 'level' && n.parentId === building.id)
    .sort((a, b) => a.props.elevation - b.props.elevation)

  return {
    units: 'meters',
    site: { width: site.props.width, depth: site.props.depth },
    building: {
      levels: levels.map(level => ({
        name: level.props.name,
        elevation: level.props.elevation,
        height: level.props.height,
        walls: getChildrenByType(level.id, 'wall', allNodes),
        rooms: getChildrenByType(level.id, 'zone', allNodes),
      }))
    }
  }
}

使用 React Three Fiber 進行渲染

import { Canvas } from '@react-three/fiber'
import { PascalScene, PascalCamera, PascalControls } from '@pascal-app/ui'

export function BuildingViewer() {
  return (
    <Canvas camera={{ position: [0, 20, 20], fov: 45 }}>
      <PascalScene />
      <PascalCamera />
      <PascalControls />
      <ambientLight intensity={0.5} />
      <directionalLight position={[10, 20, 10]} castShadow />
    </Canvas>
  )
}

網格對齊

Pascal 預設使用 100 公釐(0.1 公尺)網格:

const snapToGrid = (value: number, gridSize = 0.1) =>
  Math.round(value / gridSize) * gridSize

範例

範例 1:建立 10 公尺 x 8 公尺的地面樓層

建立一個完整的地面樓層,包含外牆、將客廳與臥室分開的內部分隔牆,以及適當的開口:

  1. 建立 elevation 為 0、高度 2.7 公尺的樓層節點
  2. 建立樓板:10 公尺 x 8 公尺多邊形,厚度 0.25 公尺
  3. 建立 4 面外牆(厚 0.20 公尺,磚石):北(10 公尺)、東(8 公尺)、南(10 公尺)、西(8 公尺)
  4. 在 x=5.5 處新增內部分隔牆(厚 0.10 公尺,木材),貫穿整個深度
  5. 在北牆新增入口門:1.0 公尺 x 2.1 公尺,偏移 3.5 公尺
  6. 在東牆新增窗戶:兩個 1.2 公尺 x 1.2 公尺,窗臺高度 0.9 公尺,偏移 1.2 公尺和 4.5 公尺
  7. 建立區域:客廳(5.3 公尺 x 7.8 公尺 = 41.3 平方公尺)、臥室區域(4.3 公尺 x 7.8 公尺 = 33.5 平方公尺)
  8. 匯出為 JSON,根據 architectural-dimensions 規則進行驗證

範例 2:註冊自訂驗證系統

建立一個每當牆壁節點變更時檢查牆壁厚度的系統:

import { registerSystem, useScene } from '@pascal-app/core'

registerSystem({
  name: 'wall-validator',
  nodeTypes: ['wall'],
  priority: 100,
  process(dirtyNodes) {
    for (const node of dirtyNodes) {
      const { thickness, isExterior, height } = node.props
      if (isExterior && thickness < 0.14)
        console.warn(`Wall ${node.id}: exterior ${thickness}m < 0.14m minimum`)
      if (height < 2.1)
        console.warn(`Wall ${node.id}: height ${height}m < 2.1m minimum`)
    }
  }
})

這會在牆壁節點被標記為髒(dirty)時自動執行,並在幾何系統重建網格之前執行。

指南

  • 所有尺寸單位均為公尺——Pascal 內部使用公制
  • 所有節點的 CRUD 操作使用 useScene,選取/相機使用 useViewer,工具使用 useEditor
  • 將座標對齊到 0.1 公尺網格,以獲得乾淨的幾何形狀
  • 牆壁厚度:外牆 0.20 公尺,內部分隔牆 0.10 公尺
  • 門的窗臺高度始終為 0(地面樓層);窗戶窗臺高度預設為 0.9 公尺
  • 註冊 priority > 50 的自訂系統,以便在幾何重建(0-50)之前執行
  • 結合 architectural-dimensions 技能以進行真實世界的尺寸驗證
  • 關鍵套件:@pascal-app/core、@pascal-app/ui、@react-three/fiber、three、zustand
  • GitHub: github.com/pascalorg/editor

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

相關技能