← 返回函数库

texture

3D Texturing Material 部分实现

CityEngine 官方语法

texture("filePath")\ntexture("filePath", textureType)

参数说明

参数类型默认值说明
filePathstring纹理文件路径或 URL。支持相对路径。
textureTypeselectordiffuse纹理类型:diffuse、bump、specular、opacity、normal。

描述

为当前形状设置纹理贴图。纹理会应用到材质对应的通道上。若已设置 color,纹理的 diffuse 通道会与颜色混合。

当前实现中,纹理路径被记录但在纯 JS 环境中可能无法直接加载外部图片。Web IDE 环境下可通过 URL 加载。

官方示例

设置 diffuse 纹理:

Wall --> texture("brick.jpg")

设置 bump 纹理:

Wall --> texture("brick_bump.jpg", bump)

实现说明

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

🎨 3D 预览 — 纹理贴图

@StartRule\nLot --> primitiveCube(4, 4, 4)\n        color(0.7, 0.7, 0.7)\n        // texture("example.jpg")

代码编辑器自动补全

枚举值自动补全:输入 texture( 时,补全列表显示带 textureType 的条目:
diffusebumpspecularopacity
可直接选择对应的纹理类型。