CGA.js 函数库

严格按 CityEngine CGA 官方函数库文档分类,覆盖几何创建、细分、操作、纹理、变换、Scope、流程控制、属性与内置函数

241
总函数
172
已完成
19
部分完成
9
未完成
71.4%
完成率
🧊 几何创建 Geometry Creation
创建基本几何体替代当前形状,常用于规则的起始或分支。
函数/操作签名状态
primitiveCubeprimitiveCube(w, h, d)完成
primitiveSphereprimitiveSphere(radius, subdivisions)完成
primitiveCylinderprimitiveCylinder(sides, radius, height)完成
primitiveConeprimitiveCone(sides, radius, height)完成
primitiveDiskprimitiveDisk(sides, radius)完成
primitiveQuadprimitiveQuad(w, h)完成
primitivePyramidprimitivePyramid(w, d, h)完成
shapeLshapeL(frontWidth, leftWidth) { ... }完成
shapeUshapeU(frontWidth, rightWidth, leftWidth) { ... }完成
shapeOshapeO(frontW, rightW, backW, leftW) { ... }完成
✂️ 几何细分 Geometry Subdivision
将当前形状沿某一轴或周长细分为多个子形状。
函数/操作签名状态
splitsplit(axis) { size1:... | size2:... } [*]完成
splitAreasplitArea(axis) { area1:... } [*]完成
setbacksetback(distance) { front:... | side:... | remainder:... }部分完成
splitAndSetbackPerimetersplitAndSetbackPerimeter(splitOffset [, firstEdgeIndex, selectedEdgesMask]) { length:depth:ops | ... } [*] { remainder:ops }完成
innerRectangleinnerRectangle() { ... }完成
🔧 几何操作 Geometry Operations
修改、查询或重塑当前形状的几何结构。
函数/操作签名状态
extrudeextrude(distance)完成
compcomp(f) { front:... | side:... | top:... | bottom:... | all:... }完成
roofHiproofHip(height)完成
roofGableroofGable(height)完成
roofPyramidroofPyramid(height)完成
roofRidgeroofRidge(height, angle)完成
roofShedroofShed(height, index)完成
offsetoffset(distance)完成
tapertaper(height)完成
envelopeenvelope(height, frontAngle, sideAngle)完成
centercenter(axes)完成
mirrormirror(xFlip, yFlip, zFlip)完成
mirrorScopemirrorScope(xFlip, yFlip, zFlip)完成
reverseNormalsreverseNormals()完成
setNormalssetNormals(mode)完成
softenNormalssoftenNormals(angle)完成
cleanupGeometrycleanupGeometry(tolerance)完成
deleteHolesdeleteHoles()完成
convexifyconvexify()完成
resetGeometryresetGeometry()完成
reduceGeometryreduceGeometry(tolerance)部分完成
rectifyrectify(angle)完成
footprintfootprint()完成
trimtrim()完成
modifymodify(component) { ... }未完成
🧩 规则内联和3D布尔 Rule Inlining & 3D Boolean
内联其他规则文件或执行布尔操作。
函数/操作签名状态
insert / iinsert(filePath) / i(filePath)未完成
insertAlongUVinsertAlongUV(uvSet, filePath, height)未完成
unionunion { A | B }部分完成
subtractsubtract { A | B }部分完成
intersectintersect { A | B }部分完成
scatterscatter(domain, count)部分完成
inlineinline(mode) { ... }部分完成
🎨 纹理 Textures
设置颜色、材质和纹理映射。
函数/操作签名状态
colorcolor("#RRGGBB") / color(r, g, b)完成
texturetexture(url)完成
setMaterialsetMaterial("key", "val", ...)完成
resetMaterialresetMaterial()完成
setupProjectionsetupProjection(uvSet, axes, texW, texH)完成
projectUVprojectUV(uvSet)完成
translateUVtranslateUV(uvSet, uOffset, vOffset)完成
scaleUVscaleUV(uvSet, uFactor, vFactor)完成
rotateUVrotateUV(uvSet, angle)完成
tileUVtileUV(uvSet, texW, texH)完成
normalizeUVnormalizeUV(uvSet)完成
deleteUVdeleteUV(uvSet)完成
copyUVcopyUV(src, dst)完成
🔄 变换 Transformations
平移、旋转、缩放当前形状或 Scope。
函数/操作签名状态
tt(tx, ty, tz)完成
translatetranslate(tx, ty, tz)完成
ss(sx, sy, sz)完成
scalescale(sx, sy, sz)完成
rr(rx, ry, rz)完成
rotateScoperotateScope(rx, ry, rz)完成
📐 范围 Scope
对齐、修改或设置当前形状的 Scope 坐标系。
函数/操作签名状态
alignScopeToAxesalignScopeToAxes()完成
alignScopeToGeometryalignScopeToGeometry(faceIndex)完成
alignScopeToGeometryBBoxalignScopeToGeometryBBox(axes)完成
setPivotsetPivot(ix, iy, iz)完成
🔀 流程控制 Flow Control
控制规则执行的流程与分支。
函数/操作签名状态
NILNIL完成
pp(probability)完成
case / Conditionalcase condition : operation完成
elseelse : operation完成
stopstop完成
push / poppush { ... } pop完成
🏷️ 属性 Attributes
声明可配置的全局或局部属性。
语法说明状态
attrattr name = defaultValue完成
constconst name = value完成
@Group属性分组显示完成
@Hidden隐藏属性不显示完成
@Order属性排序完成
@Description属性描述文本完成
@StartRule标记起始规则完成
@Range属性范围限制部分完成
📏 形状属性 Shape Attributes
在规则执行过程中访问当前形状的几何与范围信息。

geometry.*

属性说明状态
geometry.area当前面面积完成
geometry.volume当前体体积完成
geometry.height当前形状高度 (y 范围)完成
geometry.boundaryLength边界总长度完成
geometry.nFaces面数完成
geometry.nEdges边数完成
geometry.nVertices顶点数完成
geometry.nHoles孔洞数完成
geometry.isPlanar是否为平面完成
geometry.isRectangular是否为矩形完成
geometry.isConcave是否为凹形完成
geometry.isClosedSurface是否为闭合表面部分完成
geometry.isOriented是否已定向部分完成
geometry.hasTags是否有标签完成
geometry.hasUVs是否有 UV完成
geometry.uMin / uMax / vMin / vMaxUV 边界完成

scope.*

属性说明状态
scope.sx / sy / szScope 尺寸完成
scope.tx / ty / tzScope 平移完成
scope.rx / ry / rzScope 旋转 (欧拉角)完成
scope.eulerRotation.x / y / zScope 欧拉旋转完成
scope.eulerRotation.pivot旋转轴心完成

initialShape.*

属性说明状态
initialShape.origin初始形状原点完成
initialShape.geometry初始几何信息部分完成
🧮 内置函数 Built-in Functions
数学、字符串、数组、颜色、概率、文件、资产与上下文函数。

数学函数 Math

函数签名状态
absabs(x)完成
acosacos(x)完成
asinasin(x)完成
atanatan(x)完成
atan2atan2(y, x)完成
ceilceil(x)完成
clampclamp(v, min, max)完成
coscos(deg)完成
expexp(x)完成
floorfloor(x)完成
isinfisinf(x)完成
isnanisnan(x)完成
lnln(x)完成
log10log10(x)完成
maxmax(a, b, ...)完成
minmin(a, b, ...)完成
powpow(x, y)完成
rintrint(x)完成
sinsin(deg)完成
sqrtsqrt(x)完成
sumsum(array)完成
tantan(deg)完成
signsign(x)完成
fracfrac(x)完成
trunctrunc(x)完成
hypothypot(a, b)完成
normalizenormalize(x, y, z)完成
dotdot(x1,y1,z1, x2,y2,z2)完成
crosscross(x1,y1,z1, x2,y2,z2)完成

字符串函数 String

函数签名状态
lenlen(str)完成
countcount(str, match)完成
findfind(str, match, n)完成
splitStringsplitString(str, delim)完成
substringsubstring(str, start, end)完成
strreplacestrreplace(str, old, new)完成
replacereplace(str, pattern, replacement)完成
touppertoupper(str)完成
tolowertolower(str)完成
findLastfindLast(str, pattern)完成
getPrefixgetPrefix(str, sep)完成
getSuffixgetSuffix(str, sep)完成
getRangegetRange(str, start, end)完成
trimtrim(str)完成
startsWithstartsWith(str, prefix)完成
endsWithendsWith(str, suffix)完成
includesincludes(str, substr)完成
formatformat(fmt, ...args)完成

数组函数 Array

函数签名状态
sizesize(array)完成
nRowsnRows(array)完成
nColumnsnColumns(array)完成
transposetranspose(array)完成
findFirstfindFirst(array, value, eps)完成
findAllfindAll(array, value, eps)完成
setElemssetElems(array, indices, values)完成
sortIndicessortIndices(array)完成
sortRowIndicessortRowIndices(array, col)完成
reversereverse(array)完成
appendappend(array, item)完成
poppop(array)完成
sliceslice(array, start, end)完成
meanmean(array)完成
medianmedian(array)完成
stdstd(array)完成

颜色函数 Color

函数签名状态
colorHSVToHexcolorHSVToHex(h, s, v)完成
colorRGBToHexcolorRGBToHex(r, g, b)完成
colorHexToRcolorHexToR(hex)完成
colorHexToGcolorHexToG(hex)完成
colorHexToBcolorHexToB(hex)完成
colorRampcolorRamp(t, c1, c2, ...)完成
colorHSVOToHexcolorHSVOToHex(h, s, v, o)完成
colorRGBOToHexcolorRGBOToHex(r, g, b, o)完成
colorHexToHcolorHexToH(hex)完成
colorHexToScolorHexToS(hex)完成
colorHexToVcolorHexToV(hex)完成

概率与随机 Probability

函数签名状态
pp(probability)完成
randrand() / rand(max) / rand(min, max)完成
rand.intrand.int(min, max)完成
rand.gaussianrand.gaussian(mean, stddev)完成

文件函数 File

函数签名状态
fileBasenamefileBasename(path)完成
fileDirectoryfileDirectory(path)完成
fileExtensionfileExtension(path)完成
fileNamefileName(path)完成
fileRandomfileRandom(path)完成
fileExistsfileExists(path)完成
fileSearchfileSearch(pattern)完成
filesSearchfilesSearch(pattern)完成
readFloatTablereadFloatTable(content)完成
readStringTablereadStringTable(content)完成
readTextFilereadTextFile(content)完成

资产函数 Asset

函数签名状态
assetInfoassetInfo(path, attr)部分完成
assetMetadataassetMetadata(path, key)未完成
assetNamingInfoassetNamingInfo(path, key)未完成
assetNamingInfosassetNamingInfos(paths, key)未完成
assetsSortRatioassetsSortRatio(paths, ...)完成
assetsSortSizeassetsSortSize(paths, ...)完成
imageInfoimageInfo(path, attr)部分完成
imagesSortRatioimagesSortRatio(paths, ...)完成
assetApproxRatioassetApproxRatio(paths, ...)完成
assetApproxSizeassetApproxSize(paths, ...)完成
assetBestRatioassetBestRatio(paths, ...)完成
assetBestSizeassetBestSize(paths, ...)完成
assetFitSizeassetFitSize(paths, ...)完成
imageApproxRatioimageApproxRatio(paths, ...)完成
imageBestRatioimageBestRatio(paths, ...)完成

上下文函数 Context

函数签名状态
insideinside() / inside(target, label)部分完成
overlapsoverlaps() / overlaps(target, label)部分完成
touchestouches() / touches(target, label)部分完成
minimumDistanceminimumDistance(target, label)部分完成
contextComparecontextCompare(target, label, type)部分完成
contextCountcontextCount(target, label)部分完成

边属性函数 Edge Attributes

函数签名状态
edgeAttr.getBooledgeAttr.getBool(name)未完成
edgeAttr.getFloatedgeAttr.getFloat(name)未完成
edgeAttr.getStringedgeAttr.getString(name)未完成
🛠️ CGA 实用工具函数 CGA Utility Functions
调试、转换和其他辅助功能。
函数/操作签名状态
printprint(value)完成
convertconvert(...)完成
getTreeKeygetTreeKey()完成