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.parseGeometries()

The ObjectLoader.parseGeometries() method is part of the ObjectLoader class in Three.js. It is used to parse geometries JSON data and create Geometry instances.

Syntax

ObjectLoader.parseGeometries(geometries, onLoad);

Parameters

  • geometries - A JSON object containing geometry data.
  • onLoad - An optional function to execute once the geometries are loaded.

Usage

To use the ObjectLoader.parseGeometries() method, you first need to create an instance of the ObjectLoader class:

const loader = new THREE.ObjectLoader();

Then, you can call the parseGeometries() method:

loader.parseGeometries(geometries, onLoad);

In this example, geometries is a JSON object containing the geometry data that you want to parse. onLoad is an optional function that will be executed once the geometries are loaded.

Example

const loader = new THREE.ObjectLoader();

const geometries = {
  "BoxGeometry": {
    "metadata": {
      ...
    },
    "type": "BoxGeometry",
    "width": 1,
    "height": 1,
    "depth": 1,
    "widthSegments": 1,
    "heightSegments": 1,
    "depthSegments": 1
  }
};

loader.parseGeometries(geometries, function () {
  console.log("Geometries loaded!");
});

In this example, geometries is a JSON object that contains a single BoxGeometry. The parseGeometries() method is called with the geometries JSON object and a callback function that logs a message when the geometries are loaded.

Conclusion

The ObjectLoader.parseGeometries() method is a useful tool for loading geometries from JSON data in Three.js. It simplifies the process of creating Geometry instances from JSON data, allowing you to focus on creating your 3D scenes.