如何在Three.js中更改平面中的倍数纹理的大小

时间:2015-05-25 03:10:51

标签: javascript three.js

我想知道如何在geometry.faces中更改大小图像。在我的示例中,我有四张谷歌地图的静态图像。但我的图像将具有640x640像素,但所有图像都有1280x1280。我知道如何更改大小纹理以仅放入de geometry.faces。我的代码如下。 enter image description here

var geometry = new THREE.PlaneGeometry( 1280, 1280, 2, 2 );
var texturaPlano0 = THREE.ImageUtils.loadTexture('http://maps.google.com/maps/api/staticmap?center=-16.679361,-49.252408&zoom=14&size=600x600&sensor=TRUE_OR_FALSE');
var texturaPlano1 = THREE.ImageUtils.loadTexture('http://maps.google.com/maps/api/staticmap?center=-16.679361,-49.20100802620749&zoom=14&size=600x600&sensor=TRUE_OR_FALSE');
var texturaPlano2 = THREE.ImageUtils.loadTexture('http://maps.google.com/maps/api/staticmap?center=-16.727278, -49.222213&zoom=14&size=600x600&sensor=TRUE_OR_FALSE');
var texturaPlano3 = THREE.ImageUtils.loadTexture('http://maps.google.com/maps/api/staticmap?center=-16.736064, -49.252853&zoom=14&size=600x600&sensor=TRUE_OR_FALSE');
// materials
var materials = []; 
materials.push( new THREE.MeshBasicMaterial( {  map: texturaPlano0 }) );
materials.push( new THREE.MeshBasicMaterial( { map: texturaPlano1 }) );
materials.push( new THREE.MeshBasicMaterial( { map: texturaPlano2 }) );
materials.push( new THREE.MeshBasicMaterial( { map: texturaPlano3 }) );
// Set images 
geometry.faces[ 0 ].materialIndex = 0 ;
geometry.faces[ 1 ].materialIndex = 0 ;
geometry.faces[ 2 ].materialIndex = 2 ;
geometry.faces[ 3 ].materialIndex = 2 ;
geometry.faces[ 4 ].materialIndex = 1 ;
geometry.faces[ 5 ].materialIndex = 1 ;
geometry.faces[ 6 ].materialIndex = 3 ;
geometry.faces[ 7 ].materialIndex = 3 ;

// mesh
mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
scene.add( mesh );

0 个答案:

没有答案