Three.js API手册

动画
AnimationAction AnimationClip AnimationMixer AnimationObjectGroup AnimationUtils KeyframeTrack PropertyBinding PropertyMixer
动画 / 轨道
BooleanKeyframeTrack ColorKeyframeTrack NumberKeyframeTrack QuaternionKeyframeTrack StringKeyframeTrack VectorKeyframeTrack
音频
Audio AudioAnalyser AudioContext AudioListener PositionalAudio
摄像机
ArrayCamera Camera CubeCamera OrthographicCamera PerspectiveCamera StereoCamera
常量
Animation Core CustomBlendingEquation DrawModes Materials Renderer Textures
核心
BufferAttribute BufferGeometry Clock DirectGeometry EventDispatcher Face3 Geometry InstancedBufferAttribute InstancedBufferGeometry InstancedInterleavedBuffer InterleavedBuffer InterleavedBufferAttribute Layers Object3D Raycaster Uniform
核心 / BufferAttributes
BufferAttribute_Types
弃用列表
DeprecatedList
附件
Earcut ShapeUtils
附件 / 核心
Curve CurvePath Font Interpolations Path Shape ShapePath
附件 / 曲线
ArcCurve CatmullRomCurve3 CubicBezierCurve CubicBezierCurve3 EllipseCurve LineCurve LineCurve3 QuadraticBezierCurve QuadraticBezierCurve3 SplineCurve
附件 / 物体
ImmediateRenderObject
几何体
BoxBufferGeometry BoxGeometry CircleBufferGeometry CircleGeometry ConeBufferGeometry ConeGeometry CylinderBufferGeometry CylinderGeometry DodecahedronBufferGeometry DodecahedronGeometry EdgesGeometry ExtrudeBufferGeometry ExtrudeGeometry IcosahedronBufferGeometry IcosahedronGeometry LatheBufferGeometry LatheGeometry OctahedronBufferGeometry OctahedronGeometry ParametricBufferGeometry ParametricGeometry PlaneBufferGeometry PlaneGeometry PolyhedronBufferGeometry PolyhedronGeometry RingBufferGeometry RingGeometry ShapeBufferGeometry ShapeGeometry SphereBufferGeometry SphereGeometry TetrahedronBufferGeometry TetrahedronGeometry TextBufferGeometry TextGeometry TorusBufferGeometry TorusGeometry TorusKnotBufferGeometry TorusKnotGeometry TubeBufferGeometry TubeGeometry WireframeGeometry
辅助对象
ArrowHelper AxesHelper BoxHelper Box3Helper CameraHelper DirectionalLightHelper FaceNormalsHelper GridHelper PolarGridHelper PositionalAudioHelper HemisphereLightHelper PlaneHelper PointLightHelper RectAreaLightHelper SkeletonHelper SpotLightHelper VertexNormalsHelper
灯光
AmbientLight DirectionalLight HemisphereLight Light PointLight RectAreaLight SpotLight
灯光 / 阴影
DirectionalLightShadow LightShadow SpotLightShadow
加载器
AnimationLoader AudioLoader BufferGeometryLoader Cache CompressedTextureLoader CubeTextureLoader DataTextureLoader FileLoader FontLoader ImageBitmapLoader ImageLoader Loader LoaderUtils MaterialLoader ObjectLoader TextureLoader
加载器 / 管理器
DefaultLoadingManager LoadingManager
材质
LineBasicMaterial LineDashedMaterial Material MeshBasicMaterial MeshDepthMaterial MeshDistanceMaterial MeshLambertMaterial MeshMatcapMaterial MeshNormalMaterial MeshPhongMaterial MeshPhysicalMaterial MeshStandardMaterial MeshToonMaterial PointsMaterial RawShaderMaterial ShaderMaterial ShadowMaterial SpriteMaterial
数学库
Box2 Box3 Color Cylindrical Euler Frustum Interpolant Line3 Math Matrix3 Matrix4 Plane Quaternion Ray Sphere Spherical Triangle Vector2 Vector3 Vector4
数学库 / 插值
CubicInterpolant DiscreteInterpolant LinearInterpolant QuaternionLinearInterpolant
物体
Bone Group Line LineLoop LineSegments LOD Mesh Points Skeleton SkinnedMesh Sprite
渲染器
WebGLMultisampleRenderTarget WebGLRenderer WebGLRenderTarget WebGLRenderTargetCube
渲染器 / 着色器
ShaderChunk ShaderLib UniformsLib UniformsUtils
场景
Fog FogExp2 Scene
纹理贴图
CanvasTexture CompressedTexture CubeTexture DataTexture DataTexture3D DepthTexture Texture VideoTexture
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

材质常量(Texture Constants)

映射模式

THREE.UVMapping THREE.CubeReflectionMapping THREE.CubeRefractionMapping THREE.EquirectangularReflectionMapping THREE.EquirectangularRefractionMapping THREE.SphericalReflectionMapping THREE.CubeUVReflectionMapping THREE.CubeUVRefractionMapping

这些常量定义了纹理贴图的映射模式。
UVMapping是默认值,纹理使用网格的坐标来进行映射。

其它的值定义了环境映射的类型。

CubeReflectionMapping 和 CubeRefractionMapping 用于 CubeTexture —— 由6个纹理组合而成,每个纹理都是立方体的一个面。 对于CubeTexture来说,CubeReflectionMapping是其默认值。

EquirectangularReflectionMapping 和 EquirectangularRefractionMapping 用于等距圆柱投影的环境贴图,也被叫做经纬线映射贴图。等距圆柱投影贴图表示沿着其水平中线360°的视角,以及沿着其垂直轴向180°的视角。贴图顶部和底部的边缘分别对应于它所映射的球体的北极和南极。

SphericalReflectionMapping 用球形反射贴图,例如它可以通过剪裁镜面球的照片来获得。 无论摄像机相对于立方贴图对象或者表面的位置时怎样的,球形贴图被渲染时将会“面朝”摄像机。

请查看示例:materials / envmaps

包裹模式

THREE.RepeatWrapping THREE.ClampToEdgeWrapping THREE.MirroredRepeatWrapping

这些常量定义了纹理贴图的 wrapS 和 wrapT 属性,定义了水平和垂直方向上纹理的包裹方式。

使用RepeatWrapping,纹理将简单地重复到无穷大。 With RepeatWrapping the texture will simply repeat to infinity.

ClampToEdgeWrapping是默认值,纹理中的最后一个像素将延伸到网格的边缘。

使用MirroredRepeatWrapping, 纹理将重复到无穷大,在每次重复时将进行镜像。

Magnification Filters 放大滤镜

THREE.NearestFilter THREE.LinearFilter

这些常量用于纹理的magFilter属性,它们定义了当被纹理化的像素映射到小于或者等于1纹理元素(texel)的区域时,将要使用的纹理放大函数。

NearestFilter返回与指定纹理坐标(在曼哈顿距离之内)最接近的纹理元素的值。

LinearFilter是默认值,返回距离指定的纹理坐标最近的四个纹理元素的加权平均值, 并且可以包含纹理的其他部分中,被包裹或者被重复的项目,具体取决于 wrapS 和 wrapT 的值,and on the exact mapping。

缩小滤镜 Minification Filters

THREE.NearestFilter THREE.NearestMipMapNearestFilter THREE.NearestMipMapLinearFilter THREE.LinearFilter THREE.LinearMipMapNearestFilter THREE.LinearMipMapLinearFilter

这些常量用于纹理的minFilter属性,它们定义了当被纹理化的像素映射到大于1纹理元素(texel)的区域时,将要使用的纹理缩小函数。

除了NearestFilter 和 LinearFilter, 下面的四个函数也可以用于缩小:

NearestMipMapNearestFilter选择与被纹理化像素的尺寸最匹配的mipmap,并以[page:constant NearestFilter](最靠近像素中心的纹理元素)为标准来生成纹理值。

NearestMipMapLinearFilter选择与被纹理化像素的尺寸最接近的两个mipmap,并以[page:constant NearestFilter]为标准来从每个mipmap中生成纹理值。最终的纹理值是这两个值的加权平均值。

LinearMipMapNearestFilter选择与被纹理化像素的尺寸最匹配的mipmap,并以[page:constant LinearFilter](最靠近像素中心的四个纹理元素的加权平均值)为标准来生成纹理值。

LinearMipMapLinearFilter是默认值,它选择与被纹理化像素的尺寸最接近的两个mipmap,并以[page:constant LinearFilter]为标准来从每个mipmap中生成纹理值。最终的纹理值是这两个值的加权平均值。

请查看示例:materials / texture / filters

类型

THREE.UnsignedByteType THREE.ByteType THREE.ShortType THREE.UnsignedShortType THREE.IntType THREE.UnsignedIntType THREE.FloatType THREE.HalfFloatType THREE.UnsignedShort4444Type THREE.UnsignedShort5551Type THREE.UnsignedShort565Type THREE.UnsignedInt248Type

这些常量用于纹理的type属性,这些属性必须与正确的格式相对应。详情请查看下方。

UnsignedByteType 是默认值。

格式

THREE.AlphaFormat THREE.RGBFormat THREE.RGBAFormat THREE.LuminanceFormat THREE.LuminanceAlphaFormat THREE.RGBEFormat THREE.DepthFormat THREE.DepthStencilFormat

这些常量用于纹理的format属性,它们定义了shader(着色器)将如何读取的2D纹理或者texels(纹理元素)的元素。.

AlphaFormat 丢弃红、绿、蓝分量,仅读取Alpha分量。

RGBFormat 丢弃Alpha分量,仅读取红、绿、蓝分量。

RGBAFormat 是默认值,它将读取红、绿、蓝和Alpha分量。

LuminanceFormat 将每个元素作为单独的亮度分量来读取。 将其转换为范围限制在[0,1]区间的浮点数,然后通过将亮度值放入红、绿、蓝通道,并将1.0赋给Alpha通道,来组装成一个RGBA元素。

LuminanceAlphaFormat 将每个元素同时作为亮度分量和Alpha分量来读取。 和上面LuminanceFormat的处理过程是一致的,除了Alpha分量具有除了1.0以外的值。

RGBEFormat 与 RGBAFormat 是相同的。

DepthFormat将每个元素作为单独的深度值来读取,将其转换为范围限制在[0,1]区间的浮点数。 它是DepthTexture的默认值。

DepthStencilFormat将每个元素同时作为一对深度值和模板值来读取。 其中的深度分量解释为DepthFormat。 模板分量基于深度+模板的内部格式来进行解释。

请注意,纹理必须具有正确的type设置,正如上一节所描述的那样。 请参阅[link:https://developer.mozilla.org/en/docs/Web/API/WebGLRenderingContext/texImage2D WebGLRenderingContext.texImage2D]来获得有关详细信息。

DDS / ST3C 压缩纹理格式

THREE.RGB_S3TC_DXT1_Format THREE.RGBA_S3TC_DXT1_Format THREE.RGBA_S3TC_DXT3_Format THREE.RGBA_S3TC_DXT5_Format

要使用CompressedTexture中的[page:Texture.format format]属性,需要获得[link:https://www.khronos.org/registry/webgl/extensions/WEBGL\_compressed\_texture\_s3tc/ WEBGL_compressed_texture_s3tc]扩展的支持。

通过这个扩展,这里的四种S3TC格式将可以使用:
RGB_S3TC_DXT1_Format:RGB图像格式的DXT1压缩图像。 RGBA_S3TC_DXT1_Format:RGB图像格式的DXT1压缩图像,Alpha仅具有是/否透明两个值。
RGBA_S3TC_DXT3_Format:RGBA图像格式的DXT3压缩图像,和32位RGBA纹理贴图相比,它提供了4:1的压缩比。
RGBA_S3TC_DXT5_Format:RGBA图像格式的DXT5压缩图像,它也提供了4:1的压缩比,但与DX3格式的不同之处在于其Alpha是如何被压缩的。

PVRTC 压缩纹理格式 PVRTC Compressed Texture Formats

THREE.RGB_PVRTC_4BPPV1_Format THREE.RGB_PVRTC_2BPPV1_Format THREE.RGBA_PVRTC_4BPPV1_Format THREE.RGBA_PVRTC_2BPPV1_Format

要使用CompressedTexture中的format属性,需要获得 [link:https://www.khronos.org/registry/webgl/extensions/WEBGL\_compressed\_texture\_pvrtc/ WEBGL_compressed_texture_pvrtc]扩展的支持。
PVRTC通常只在具有PowerVR芯片的移动设备上可用,这些设备主要是苹果设备。

通过这个扩展,这里的四种PVRTC格式将可以使用:
RGB_PVRTC_4BPPV1_Format:4位模式下的RGB压缩,每4x4像素一个块。
RGB_PVRTC_2BPPV1_Format:2位模式下的RGB压缩,每8x4像素一个块。
RGBA_PVRTC_4BPPV1_Format: 4位模式下的RGBA压缩,每4x4像素一个块。
RGBA_PVRTC_2BPPV1_Format: 2位模式下的RGB压缩,每8x4像素一个块。

ETC 压缩纹理格式

THREE.RGB_ETC1_Format

要使用CompressedTexture中的format属性,需要获得 [link:https://www.khronos.org/registry/webgl/extensions/WEBGL\_compressed\_texture\_etc1/ WEBGL_compressed_texture_etc1]扩展的支持。

编码

THREE.LinearEncoding THREE.sRGBEncoding THREE.GammaEncoding THREE.RGBEEncoding THREE.LogLuvEncoding THREE.RGBM7Encoding THREE.RGBM16Encoding THREE.RGBDEncoding THREE.BasicDepthPacking THREE.RGBADepthPacking

这些常量用于纹理的encoding属性。

如果编码类型在纹理已被一个材质使用之后发生了改变, 你需要来设置Material.needsUpdate为true来使得材质重新编译。

LinearEncoding是默认值。 除此之外的其他值仅在材质的贴图、envMap和emissiveMap中有效。

源代码

src/constants.js