Texture scale 1x1 for a mesh




i want to scale my texture 1x1 on a geometry.
The result should look like a normal THREE.BoxGeometry(1,1,1);
If i load a texture to the mesh the texture is mapped right to the BoxGeometry.

In my case i have to load an .geo data and import that to three js (i have no uv-koords).
A minimal example is this:

var texture = new THREE.TextureLoader().load( 'files/texture.png' );
material = new THREE.MeshPhongMaterial({map: texture});

var geometry = new THREE.Geometry();
		new THREE.Vector3(0, 0, 0), //0 
		new THREE.Vector3(1, 0, 0), //1
		new THREE.Vector3(1, 0, 1), //2
		new THREE.Vector3(0, 0, 1), //3 
		new THREE.Vector3(0, 1, 0), //4 
		new THREE.Vector3(1, 1, 0), //5 
		new THREE.Vector3(1, 1, 1), //6 
		new THREE.Vector3(0, 1, 1), //7
		new THREE.Face3(0, 1, 2),
		new THREE.Face3(0, 2, 3),
		new THREE.Face3(7, 4, 0),
		new THREE.Face3(0, 3, 7),
		new THREE.Face3(6, 7, 3),
		new THREE.Face3(3, 2, 6),
		new THREE.Face3(4, 7, 6),
		new THREE.Face3(6, 5, 4),
		new THREE.Face3(1, 0, 4),
		new THREE.Face3(4, 5, 1),
		new THREE.Face3(6, 2, 1),
		new THREE.Face3(1, 5, 6),
	mesh = new THREE.Mesh( geometry, material );

This is the same as a standard BoxGeometry but without uv koords.

My question is: How can i automatically calculate the uv koords for any geometry (could also be freeform) to look like the standard BoxGeometry?
It is not possible to write the uv koords manually because i have to load 10000+ different geometries.


The uv coordinates of BoxGeometry are specific since they are not continuous over the geometry. Instead, each side has a set of uv-data that allows to display the entire texture. It’s not possible to create such uv-data for any type of geometry. A tetrahedron is one simple example. What kind of texture projection would be correct for this geometry from your point of view?


A tetrahedron isn´t needed.
It is mostly for cubes or quadrangles. Sometimes for circles or cylinder.

So i need to map the texture correctly for each side of the cube (automatically).
Or for the top and the buttom Face of a cylinder. Or on an quadrangels or circle.


Thus, you have to analyse an imported object and compute uv coordinates for its sides yourself.


I know i have to do it myself. I am looking for the mathematic way behind the problem to solve it.