three.js:全景查看器中的图像呈波纹状
three.js: Image in panorama viewer is rippled
目前我正在熟悉 three.js 并创建了一个简单的全景查看器:
http://webentwicklung.ulrichbangert.de/threejs-image-on-sphere-inside.html
不幸的是,柱子的垂直边缘呈波纹状。
使用 Panorama Studio 的全景查看器时一切正常:
http://ulrichbangert.de/heimat/Halberstadt/2018-06-10_Halberstadt_Dom_Panorama.html
var width = window.innerWidth,
height = window.innerHeight;
var scene = new THREE.Scene();
scene.add(new THREE.AmbientLight(0x333333));
var light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(5, 3, 5);
scene.add(light);
var camera = new THREE.PerspectiveCamera(45, width / height, 0.01, 1000);
camera.position.z = 1;
camera.fov = Math.max(100, Math.min(200, camera.fov));
camera.updateProjectionMatrix();
var renderer = new THREE.WebGLRenderer();
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);
var loader = new THREE.TextureLoader();
loader.load('images/panorama.jpg', function (texture) {
texture.anisotropy = renderer.getMaxAnisotropy();
var material = new THREE.MeshBasicMaterial({
map: texture
});
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(20, 32, 32),
material
);
sphere.scale.x = -1;
sphere.rotation.x = -0.5;
scene.add(sphere);
var animate = function () {
requestAnimationFrame(animate);
sphere.rotation.y += 0.002;
renderer.render(scene, camera);
};
animate();
});
这里出了什么问题?
尝试为您的 SphereGeometry
添加更多细分。现在您有 32 个纬度和经度细分,这会为您的纹理创建一些难看的直线变形。如果你做类似 new THREE.SphereGeometry(20, 100, 100)
的事情,你会在纹理映射时获得更好的保真度。
目前我正在熟悉 three.js 并创建了一个简单的全景查看器: http://webentwicklung.ulrichbangert.de/threejs-image-on-sphere-inside.html 不幸的是,柱子的垂直边缘呈波纹状。 使用 Panorama Studio 的全景查看器时一切正常: http://ulrichbangert.de/heimat/Halberstadt/2018-06-10_Halberstadt_Dom_Panorama.html
var width = window.innerWidth,
height = window.innerHeight;
var scene = new THREE.Scene();
scene.add(new THREE.AmbientLight(0x333333));
var light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(5, 3, 5);
scene.add(light);
var camera = new THREE.PerspectiveCamera(45, width / height, 0.01, 1000);
camera.position.z = 1;
camera.fov = Math.max(100, Math.min(200, camera.fov));
camera.updateProjectionMatrix();
var renderer = new THREE.WebGLRenderer();
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);
var loader = new THREE.TextureLoader();
loader.load('images/panorama.jpg', function (texture) {
texture.anisotropy = renderer.getMaxAnisotropy();
var material = new THREE.MeshBasicMaterial({
map: texture
});
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(20, 32, 32),
material
);
sphere.scale.x = -1;
sphere.rotation.x = -0.5;
scene.add(sphere);
var animate = function () {
requestAnimationFrame(animate);
sphere.rotation.y += 0.002;
renderer.render(scene, camera);
};
animate();
});
这里出了什么问题?
尝试为您的 SphereGeometry
添加更多细分。现在您有 32 个纬度和经度细分,这会为您的纹理创建一些难看的直线变形。如果你做类似 new THREE.SphereGeometry(20, 100, 100)
的事情,你会在纹理映射时获得更好的保真度。