codecamp

three.js PointsMaterial

Points使用的默认材质。

代码示例

const vertices = [];

for ( let i = 0; i < 10000; i ++ ) {

	const x = THREE.MathUtils.randFloatSpread( 2000 );
	const y = THREE.MathUtils.randFloatSpread( 2000 );
	const z = THREE.MathUtils.randFloatSpread( 2000 );

	vertices.push( x, y, z );

}

const geometry = new THREE.BufferGeometry();
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );

const material = new THREE.PointsMaterial( { color: 0x888888 } );

const points = new THREE.Points( geometry, material );

scene.add( points );

例子

misc / controls / fly
WebGL / BufferGeometry / drawrange
WebGL / BufferGeometry / points
WebGL / BufferGeometry / points / interleaved
WebGL / camera
WebGL / geometry / convex
WebGL / geometry / shapes
WebGL / interactive / raycasting / points
WebGL / multiple / elements / text
WebGL / points / billboards
WebGL / points / dynamic
WebGL / points / sprites
WebGL / trails

PointsMaterial( parameters : Object )

parameters - (可选)用于定义材质外观的对象,具有一个或多个属性。 材质的任何属性都可以从此处传入(包括从Material继承的任何属性)。

属性color例外,其可以作为十六进制字符串传递,默认情况下为 0xffffff(白色),内部调用Color.set(color)。

属性(Properties)

共有属性请参见其基类Material。

.alphaMap : Texture

alpha贴图是一张灰度纹理,用于控制整个表面的不透明度。(黑色:完全透明;白色:完全不透明)。 默认值为null。

仅使用纹理的颜色,忽略alpha通道(如果存在)。 对于RGB和RGBA纹理,WebGL渲染器在采样此纹理时将使用绿色通道, 因为在DXT压缩和未压缩RGB 565格式中为绿色提供了额外的精度。 Luminance-only以及luminance/alpha纹理也仍然有效。

.color : Color

材质的颜色(Color),默认值为白色 (0xffffff)。

.fog : Boolean

材质是否受雾影响。默认为true。

.map : Texture

使用来自Texture的数据设置点的颜色。可以选择包括一个alpha通道,通常与 .transparent或.alphaTest。

.size : Number

设置点的大小。默认值为1.0。

如果超过硬件相关参数 gl.ALIASED_POINT_SIZE_RANGE,将被限制。

.sizeAttenuation : Boolean

指定点的大小是否因相机深度而衰减。(仅限透视摄像头。)默认为true。

源码(Source)

src/materials/PointsMaterial.js


three.js MeshToonMaterial
three.js RawShaderMaterial
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

参考

核心 / BufferAttributes

渲染器 / WebXR

开发者参考

WebGL渲染器

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }