Create three js geometry with values from a database

For the beginning, I’ve built an HTML page that uses “three js” to create some cubes. The number of cubes, the size, the coordinates are fixed.
In the next step, these values, which are the number of cubes, their size and position, are read from a postgrsql database. I do that with node js.
Do I have to create a JSON file or OBJ / MTL files? And import this, as a whole scene, then with a loader?
If so, where can I find an example / description of the JSON format or OBJ / MTL format?

I say thank you for your advice.

You should probably start here.

I would import the whole scene, probably as glTF. You can use GLTFExporter to create the glTF asset and then use GLTFLoader to import the file. The following two examples might help to see both classes in action:

BTW: I don’t think it’s a good idea to store assets in a database. Using a content or just a web server might be the better option.

I want to represent an industrial process and get the current values ​​from a database.
I have unfortunately found no way to pass the values ​​to a html page and assign them to the three js geometries. In the meantime I created a scene with blender and exported it to a gltf file.
Unfortunately I can not read this file with three js.

Here is my code under node js:


var app = require('express')();

app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');

app.listen(3000, function(){
console.log("Listenng to port 3000")

and the index.html:

<title>threejs - models</title>

		margin: 0;
		overflow: hidden;

<canvas id="myCanvas"></canvas>

<script src="//"></script>
<script  type="text/javascript" src="GLTFLoader.js"></script>


var renderer,
 	myCanvas  = document.getElementById('myCanvas');	
	renderer = new THREE.WebGLRenderer({
		canvas: myCanvas,
		antialias: true
	renderer.setSize(window.innerWidth, window.innerHeight);
	camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 1000 );
	camera.position.y = -400;
	camera.position.z = 400;
	camera.rotation.x = .70;
	scene = new THREE.Scene();
	var light = new THREE.AmbientLight(0xffffff, 0.5);
	var light2 = new THREE.PointLight(0xffffff, 0.5);
	var loader = new THREE.GLTFLoader();
	loader.load('Version_2.gltf', handle_load);
	function handle_load(gltf) {
		scene.add (gltf.scene);
	// for test:
	//cube = new THREE.Mesh(new THREE.CubeGeometry(100,100,100), new THREE.MeshNormalMaterial());					
	renderer.render(scene, camera);

It looks like the line:

var loader = new THREE.GLTFLoader();


causes an error.

It works now.
I have probably used an old version of the GLTFLoader. I can now load a gltf file. Parallel I tried the OBJLoader / MTL Loader. I can work with that, too.