Communitygithub.com

Pascal编辑器集成

使用Pascal编辑器架构(React Three Fiber + Zustand场景图)构建和扩展3D建筑编辑器应用。适用于:构建3D建筑工具、创建BIM类编辑器、为Pascal编辑器添加自定义功能、构建楼层平面生成器。

Pascal编辑器集成 是什么?

Pascal编辑器集成技能旨在帮助开发者基于开源项目Pascal Editor(采用React Three Fiber和WebGPU构建)快速搭建功能完备的3D建筑编辑器。该技能详细介绍了其核心API,包括基于类型化节点的场景树(场地、建筑、楼层、墙体、开口等)、基于Zustand的状态管理(useScene、useViewer、useEditor)以及用于几何生成和验证的系统架构。开发者可以通过此技能创建墙体与门窗、生成楼层与房间区域、导出JSON场景数据,并利用React Three Fiber进行渲染。该技能特别适合AI驱动的建筑生成场景,可与`architectural-dimensions`等技能结合实现真实世界尺寸验证,并支持注册自定义验证系统以确保建筑规范。

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

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Pascal编辑器集成 是做什么的?

概述

Pascal编辑器(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状态Store

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.5m,厚200mm,层高2.7m
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.2m,窗台高900mm
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)

// 添加门:宽900mm
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 mm(0.1 m)网格:

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

示例

示例1:构建10m x 8m的底层

创建包含外墙、分隔起居室与卧室的内隔墙以及合适开口的完整底层:

  1. 创建楼层节点,标高0,高度2.7 m
  2. 创建楼板:10 m x 8 m多边形,厚度0.25 m
  3. 创建4面外墙(厚0.20 m,砌体):北墙(10 m)、东墙(8 m)、南墙(10 m)、西墙(8 m)
  4. 在x=5.5处添加内隔墙(厚0.10 m,木结构),贯穿整个进深
  5. 在北墙上添加入户门:1.0 m x 2.1 m,偏移3.5 m
  6. 在东墙上添加窗户:两扇1.2 m x 1.2 m,窗台高0.9 m,偏移分别为1.2 m和4.5 m
  7. 创建区域:起居室(5.3 m x 7.8 m = 41.3 m2),卧室区(4.3 m x 7.8 m = 33.5 m2)
  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(`墙体 ${node.id}:外墙厚度 ${thickness}m 小于最小值 0.14m`)
      if (height < 2.1)
        console.warn(`墙体 ${node.id}:高度 ${height}m 小于最小值 2.1m`)
    }
  }
})

该验证会在墙体节点被标记为脏数据后自动运行,先于几何系统重建网格。

指南

  • 所有尺寸单位均为米——Pascal内部使用公制
  • 使用useScene进行所有节点CRUD操作,useViewer用于选择/相机,useEditor用于工具
  • 将坐标吸附到0.1 m网格以确保几何体整洁
  • 墙厚:外墙0.20 m,内隔墙0.10 m
  • 门底高度始终为0(楼板高度);窗台高度默认0.9 m
  • 注册自定义系统时,优先级>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.

相关技能