BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

ObjectLoader.parseTextures()

概述

ObjectLoader.parseTextures(textures, onLoad)是three.js中ObjectLoader的一个方法,用于解析映射纹理数据。

参数

该方法有两个参数:

  • textures:一个Array类型,包含了需要解析的映射纹理数据

  • onLoad:一个Function类型,当所有纹理加载完成时被调用

返回值

该方法没有返回值。

使用方法

const loader = new THREE.ObjectLoader();
loader.parseTextures(textures, onTexturesLoaded);

其中,textures参数应当由纹理数据构成的数组,如下所示:

const textureData = {
    "name": "textureName",
    "url": "texture/url.png",
    "mapping": "UVMapping",
    "wrapS": "clampToEdgeWrapping",
    "wrapT": "clampToEdgeWrapping",
    "magFilter": "LinearFilter",
    "minFilter": "LinearMipMapLinearFilter",
    "anisotropy": 1,
    "repeat": [1, 1],
    "offset": [0, 0],
    "rotation": 0
};

const textures = [textureData];

当所有纹理加载完成时,onTexturesLoaded函数会被调用。您可以在此函数中执行一些操作,如渲染场景。

function onTexturesLoaded() {
    renderer.render(scene, camera);
}

注意事项

  • textures数组中的每一个纹理数据对象必须包含nameurl两个属性。

  • mappingwrapSwrapTmagFilterminFilteranisotropyrepeatoffsetrotation属性均为可选,使用时应按需填充。