[page:Material] → [page:ShaderMaterial] →

线段材质([name])

用于绘制线框样式几何体的材质。 与 [page:LineBasicMaterial] 不同,它支持任意线宽,并允许使用世界单位而不是屏幕空间单位。 此材质与 [page:LineSegments2] 和 [page:Line2] 一起使用。

线段始终以圆形端点和圆形接头渲染。

示例

[example:webgl_lines_fat WebGL / lines / fat ]
[example:webgl_lines_fat_raycasting WebGL / lines / fat / raycasting ]
[example:webgl_lines_fat_wireframe WebGL / lines / fat / wireframe ]
[example:webgpu_lines_fat WebGPU / lines / fat / raycasting ]

构造函数

[name]( [param:Object parameters] )

[page:Object parameters] - (可选)一个包含一个或多个定义材质外观属性的对象。 材质的任何属性(包括从 [page:ShaderMaterial] 继承的任何属性)都可以在此传入。

特例是属性 [page:Hexadecimal color],可以作为数字或十六进制字符串传入,默认值为 `0xffffff`(白色)。 内部会调用 [page:Color.set]( color )。

属性

有关共同属性,请参见基类 [page:ShaderMaterial]。

[property:Color color]

材质的 [page:Color] 颜色,默认设置为白色(0xffffff)。

[property:Boolean dashed]

线段是否为虚线。默认值为 `false`(实线)。

[property:number dashOffset]

虚线循环的起始偏移量。默认值为 `0`。

[property:number dashScale]

虚线和间隔的缩放比例。默认值为 `1`。

[property:number dashSize]

虚线的大小。默认值为 `1`。

[property:number gapSize]

间隔的大小。默认值为 `1`。

[property:Float linewidth]

当 [page:worldUnits] 为 `false`(默认值)时,以 CSS 像素单位控制线宽;当 [page:worldUnits] 为 `true` 时,以世界单位控制线宽。默认值为 `1`。

[property:Vector2 resolution]

视口大小,以屏幕像素为单位。 必须保持更新以确保屏幕空间渲染的准确性。 [page:LineSegments2.onBeforeRender] 回调函数会为可见对象执行更新。 默认值为 `[1, 1]`。

[property:Boolean worldUnits]

材质的尺寸(宽度、虚线间隔)是否使用世界单位。 默认值为 `false`(使用屏幕空间单位)。

方法

有关共同方法,请参见基类 [page:ShaderMaterial]。

源代码

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/lines/LineMaterial.js examples/jsm/lines/LineMaterial.js]