← 返回函数库

translate

Transformations Scope 已实现

CityEngine 官方语法

translate(tx, ty, tz)\ntranslate(axis, distance)

参数说明

参数类型默认值说明
tx, ty, tzfloat沿 scope X/Y/Z 轴的平移量。
axisselector平移轴,如 world.x、world.y、scope.z 等。
distancefloat沿指定轴的平移距离。

描述

平移当前形状的 scope。支持两种形式:三轴分量形式或单轴距离形式。平移不改变几何体,只改变 scope 位置。

translate(tx, ty, tz) 等价于 t(tx, ty, tz)。

官方示例

三轴平移:

Mass --> translate(0, 5, 0) Raised

沿世界 Y 轴平移:

Mass --> translate(world.y, 10) Raised

实现说明

CGA.js 中的 translate 实现基于 CityEngine 2025.1 官方文档。

🎨 3D 预览 — 平移

@StartRule\nLot --> primitiveCube(4, 4, 4)\n        translate(2, 0, 0)\n        color(0.5, 0.5, 1)