我已使用以下源代码(三个 js)将平面图像转换为球形图像。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Spherical image conversion</title>
<style>
body { margin: 0; overflow: hidden; background-color: #000; }
</style>
</head>
<body>
<div id="container">
<div id="openseadragon1" style="width: 100%; height: 100%;"></div>
<div id="sphere"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/Detector.js"></script>
<script src="./openseadragon_2.0/openseadragon.min.js"></script>
<script type="text/javascript">
var viewer = OpenSeadragon({
id: "openseadragon1",
wrapHorizontal: "true",
wrapVertical: "true",
constrainDuringPan:"true",
defaultZoomLevel: 1,
visibilityRatio: 1,
minZoomLevel: 1,
prefixUrl: "openseadragon_2.0/images/",
tileSources: "spherical.dzi"
});
</script>
<script>
var sphereContainer = document.getElementById('sphere');
var width = window.innerWidth,
height = window.innerHeight;
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, width / height, 1, 1000);
camera.position.x = 0.1;
var renderer = Detector.webgl ? new THREE.WebGLRenderer() : new THREE.CanvasRenderer();
renderer.setSize(width, height);
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(100, 20, 20),
new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture('spherical-image.jpg')
})
);
sphere.scale.x = -1;
scene.add(sphere);
var controls = new THREE.OrbitControls(camera);
controls.noPan = true;
controls.noZoom = true;
sphereContainer.appendChild(renderer.domElement);
render();
function render() {
controls.update();
requestAnimationFrame(render);
renderer.render(scene, camera);
}
function onMouseWheel(event) {
event.preventDefault();
if (event.wheelDeltaY) { // WebKit
camera.fov -= event.wheelDeltaY * 0.05;
} else if (event.wheelDelta) { // Opera / IE9
camera.fov -= event.wheelDelta * 0.05;
} else if (event.detail) { // Firefox
camera.fov += event.detail * 1.0;
}
camera.fov = Math.max(40, Math.min(100, camera.fov));
camera.updateProjectionMatrix();
}
document.addEventListener('mousewheel', onMouseWheel, false);
document.addEventListener('DOMMouseScroll', onMouseWheel, false);
</script>
</body>
</html>
此外,我已将高分辨率图像转换为深度缩放图像格式。所以目前我有一个包含处理(分割)图像和 dzi 格式文件(图像文件夹和 image.dzi 文件)的文件夹。
现在我需要集成 openseadragon 库以在缩放图像后获得更好的性能。这将在特定坐标中渲染文件夹中的平铺图像。
请给我一个建议,我们该如何做到这一点。
提前致谢。