CGA Lite 函数库参考

完整列出 createurban.com 支持的所有 CGA 操作与内置函数。
完成 已实现并测试   部分完成 基础可用,有简化或限制   未完成 仅 stub,待实现

241
总函数
210
已完成
19
部分完成
12
未完成
87.1%
完成率 87.1%

几何创建 Geometry Creation

创建基本几何体替代当前形状,常用于规则的起始或分支。

函数/操作签名状态
primitiveCube [示例]primitiveCube(w, h, d)完成
primitiveSphere [示例]primitiveSphere(radius, subdivisions)完成
primitiveCylinder [示例]primitiveCylinder(sides, radius, height)完成
primitiveCone [示例]primitiveCone(sides, radius, height)完成
primitiveDisk [示例]primitiveDisk(sides, radius)完成
primitiveQuad [示例]primitiveQuad(w, h)完成
primitivePyramid [示例]primitivePyramid()完成
shapeL [示例]shapeL(frontWidth, leftWidth)完成
shapeU [示例]shapeU(frontWidth, rightWidth, leftWidth)完成
shapeO [示例]shapeO(frontW, rightW, backW, leftW)完成

几何细分 Geometry Subdivision

将当前形状沿某一轴或周长细分为多个子形状。

函数/操作签名状态
split [示例]split(axis) { size1:... | size2:... } [*]完成
splitAreasplitArea(axis) { area1:... } [*]完成
setback [示例]setback(distance) { front:... | side:... | remainder:... }部分完成
splitAndSetbackPerimeter [示例]splitAndSetbackPerimeter(splitOffset [, firstEdgeIndex, selectedEdgesMask]) { length:depth:ops | ... } [*] { remainder:ops }完成
innerRectangle [示例]innerRectangle()完成

几何操作 Geometry Operations

修改、查询或重塑当前形状的几何结构。

函数/操作签名状态
extrude [示例]extrude(distance)完成
comp [示例]comp(f) { front:... | side:... | top:... | bottom:... | all:... }完成
roofHip [示例]roofHip(height)完成
roofGable [示例]roofGable(height)完成
roofPyramid [示例]roofPyramid(height)完成
roofRidge [示例]roofRidge(height)完成
roofShed [示例]roofShed(height, index)完成
offset [示例]offset(distance)完成
taper [示例]taper(height)完成
envelope [示例]envelope(height, frontAngle, sideAngle)部分完成
centercenter(axes)完成
mirror [示例]mirror(xFlip, yFlip, zFlip)完成
mirrorScopemirrorScope(xFlip, yFlip, zFlip)完成
reverseNormalsreverseNormals()完成
setNormals [示例]setNormals(mode)完成
softenNormals [示例]softenNormals(angle)完成
cleanupGeometry [示例]cleanupGeometry(tolerance)完成
deleteHoles [示例]deleteHoles()完成
convexify [示例]convexify()完成
resetGeometry [示例]resetGeometry()完成
reduceGeometry [示例]reduceGeometry(tolerance)完成
rectify [示例]rectify(angle)完成
footprint [示例]footprint()完成
trimtrim()完成
modifymodify(component) { ... }未完成

几何标签 Geometry Tags

为当前形状添加或删除标签,用于后续选择器过滤。

函数/操作签名状态
tagtag("name")完成
deleteTagsdeleteTags("name")完成

规则内联和3D布尔 Rule Inlining & 3D Boolean

内联其他规则文件或执行布尔操作。

函数/操作签名状态
insert / iinsert(filePath) / i(filePath)未完成
insertAlongUVinsertAlongUV(uvSet, filePath, height)未完成
union [示例]union { A | B }完成
subtract [示例]subtract { A | B }完成
intersect [示例]intersect { A | B }完成
scatter [示例]scatter(domain, count)完成

纹理 Textures

设置颜色、材质和纹理映射。

函数/操作签名状态
color [示例]color("#RRGGBB") / color(r, g, b)完成
texture [示例]texture(url)完成
setMaterial [示例]setMaterial("key", "val", ...)完成
resetMaterial [示例]resetMaterial()完成
setupProjection [示例]setupProjection(uvSet, axes, texW, texH)完成
projectUV [示例]projectUV(uvSet)完成
translateUV [示例]translateUV(uvSet, uOffset, vOffset)完成
scaleUV [示例]scaleUV(uvSet, uFactor, vFactor)完成
rotateUV [示例]rotateUV(uvSet, angle)完成
tileUV [示例]tileUV(uvSet, texW, texH)完成
normalizeUV [示例]normalizeUV(uvSet)完成
deleteUV [示例]deleteUV(uvSet)完成
copyUV [示例]copyUV(src, dst)完成

变换 Transformations

平移、旋转、缩放当前形状或 Scope。

函数/操作签名状态
t [示例]t(tx, ty, tz)完成
translate [示例]translate(tx, ty, tz)完成
s [示例]s(sx, sy, sz)完成
scale [示例]scale(sx, sy, sz)完成
r [示例]r(rx, ry, rz)完成
rotateScope [示例]rotateScope(rx, ry, rz)完成

范围 Scope

对齐、修改或设置当前形状的 Scope 坐标系。

函数/操作签名状态
alignScopeToAxes [示例]alignScopeToAxes()完成
alignScopeToGeometry [示例]alignScopeToGeometry(faceIndex)完成
alignScopeToGeometryBBox [示例]alignScopeToGeometryBBox(axes)完成
setPivotsetPivot(ix, iy, iz)完成

流程控制 Flow Control

控制规则执行的流程与分支。

函数/操作签名状态
NILNIL完成
p [示例]p(probability)完成
Conditionalcase condition : operation完成
elseelse : operation完成
Stopstop完成

属性 Attributes

声明可配置的全局或局部属性。

语法说明状态
attrattr name = defaultValue完成
constconst name = value完成
@Group属性分组显示完成
@Hidden隐藏属性不显示完成
@Order属性排序完成
@Description属性描述文本完成

形状属性 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.isInstanced是否为实例未完成
geometry.hasTags是否有标签完成
geometry.hasUVs是否有 UV完成
geometry.angle面法线与世界坐标夹角完成
geometry.du / geometry.dvUV 方向上的导数完成
geometry.groups几何分组信息未完成
geometry.materials材质列表未完成
geometry.tags标签列表未完成
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

函数签名状态
abs [示例]abs(x)完成
acosacos(x)完成
asinasin(x)完成
atanatan(x)完成
atan2atan2(y, x)完成
ceilceil(x)完成
clamp [示例]clamp(v, min, max)完成
coscos(deg)完成
expexp(x)完成
floorfloor(x)完成
isinfisinf(x)完成
isnanisnan(x)完成
lnln(x)完成
log10log10(x)完成
max [示例]max(a, b, ...)完成
minmin(a, b, ...)完成
powpow(x, y)完成
rintrint(x)完成
sin [示例]sin(deg)完成
sqrt [示例]sqrt(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

函数签名状态
len [示例]len(str)完成
countcount(str, match)完成
findfind(str, match, n)完成
splitStringsplitString(str, delim)完成
substringsubstring(str, start, end)完成
strreplacestrreplace(str, old, new)完成
replacereplace(str, pattern, replacement)完成
toupper [示例]toupper(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)完成
sortIndices [示例]sortIndices(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)完成
colorRGBToHex [示例]colorRGBToHex(r, g, b)完成
colorHexToRcolorHexToR(hex)完成
colorHexToGcolorHexToG(hex)完成
colorHexToBcolorHexToB(hex)完成
colorRamp [示例]colorRamp(t, c1, c2, ...)完成
colorHSVOToHexcolorHSVOToHex(h, s, v, o)完成
colorRGBOToHexcolorRGBOToHex(r, g, b, o)完成
colorHexToHcolorHexToH(hex)完成
colorHexToScolorHexToS(hex)完成
colorHexToVcolorHexToV(hex)完成

概率与随机 Probability

函数签名状态
p [示例]p(probability)完成
rand [示例]rand() / rand(max) / rand(min, max)完成
rand.intrand.int(min, max)完成
rand.gaussianrand.gaussian(mean, stddev)完成

文件函数 File

函数签名状态
fileBasename [示例]fileBasename(path)完成
fileDirectoryfileDirectory(path)完成
fileExtension [示例]fileExtension(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()完成