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

FileLoader.setMimeType()

The FileLoader.setMimeType() method is used to set the MIME type of the file that is being loaded using the FileLoader in three.js. The MIME type is a string that specifies the format of the data that is being transferred between the server and the client.

Syntax

loader.setMimeType( mimeType )

Parameters

  • mimeType : A string value that represents the MIME type of the file that you are loading.

Example

var loader = new THREE.FileLoader();

// Set the MIME type of the file that we are loading
loader.setMimeType( "application/json" );

// Load the file using the loader
loader.load(
    // resource URL
    'myfile.json',

    // onLoad callback
    function ( data ) {
        // Do something with the loaded data
        console.log( data );
    }
);

In this example, we first create a new FileLoader object. We then use the setMimeType() method to set the MIME type of the file that we want to load to "application/json". Finally, we use the load() method of the FileLoader to load the file.

Notes

  • It is important to set the MIME type of the file that you are loading correctly. If the MIME type is incorrect, the file may not load or may not be interpreted correctly by the browser.
  • Some MIME types that you might use when loading files in three.js are "image/jpeg", "image/png", "image/gif", "audio/mp3", "audio/wav", "video/mp4", "application/json", "text/plain", etc.