How to use the JSONLoader function from three

Find comprehensive JavaScript three.JSONLoader code examples handpicked from public code repositorys.

three.JSONLoader is a class in the Three.js library used to load 3D models in JSON format.

50
51
52
53
54
55
56
57
58
};

this.loadJSON = function (url, onLoad) {
  var scope = this;

  var loader = new THREE.JSONLoader();
  loader.load(url, function (geometry, materials) {
    var originalMaterial = materials[ 0 ];
    originalMaterial.skinning = true;
fork icon10
star icon33
watch icon0

9
10
11
12
13
14
15
16
17

var reflectionCube
// opt.envMap
//require('./get-cube')()

var loader = new THREE.JSONLoader(false)
loader.load("models/ball.js", function(geometry, materials) {
    // geometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI/2))
    geometry.computeVertexNormals()
fork icon2
star icon16
watch icon2

+ 3 other calls in file

How does three.JSONLoader work?

three.JSONLoader is a class in the Three.js library that allows you to load 3D models in JSON format, parse the data and create an instance of the three.BufferGeometry class to be used by the three.Mesh class for rendering.

6
7
8
9
10
11
12
13
14
15
var camera, projector, scene, renderer, mouse;
var cameraCube, sceneCube;

var mesh, lightMesh, geometry, centralBeacon;
var spheres = [];
var loader = new THREE.JSONLoader(); // init the loader util
var uniforms1;
var sphere, lightMesh, pointLight;

var onMaterial, offMaterial;
fork icon0
star icon0
watch icon2

+ 3 other calls in file

99
100
101
102
103
104
105
106
107
108
  return objects;
}

const GenerateSvgGroup = async (url='/default.svg') => {
  const objects = await ConstructObjectsFromSVG(url);
  const loader = new THREE.JSONLoader();

  const svgGroup = new THREE.Group();
  for (const [i, obj] of objects.entries()) {
    var shape = ShapeFromJSONObject(obj.shape)
fork icon0
star icon0
watch icon2

+ 5 other calls in file

Ai Example

1
2
3
4
5
6
7
8
import * as THREE from "three";
import { JSONLoader } from "three";

const loader = new JSONLoader();
loader.load("model.json", (geometry, materials) => {
  const mesh = new THREE.Mesh(geometry, new THREE.MultiMaterial(materials));
  scene.add(mesh);
});

In this example, a JSONLoader instance is created, and the load method is called with the path to the JSON file as its first argument. When the file is loaded, the onLoad callback function is called with the loaded geometry and materials as arguments. A new Mesh object is created using the geometry and materials, and added to the scene.

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)