将宽高比与可上载的图像匹配

时间:2015-03-31 09:05:47

标签: javascript three.js

我的网页中有一个div元素,其中包含id" glCanvas"。我希望能够将其宽高比与用户上传的照片进行匹配:

 $("#imageInput").change(function() {
            readBackgroundFile(this);
            readExif(this, function(data) {
                aspectRatio = data.width/data.height;
                height = $("#glCanvas").height();
                width = $("#glCanvas").width();
                newWidth = height*aspectRatio;
                console.log(data.focalLength);
                halfWidth = newWidth/2;
                FOV = 2 * Math.atan(halfWidth*0.5, data.focalLength);
                camera.aspect(aspectRatio);
                $("#glCanvas").width(newWidth);
                renderer.setSize(newWidth, height);

                viewerPosition = new THREE.Vector3().fromArray(llhxyz(data.latitude, data.longitude, data.altitude));
                updateScenePlacement();
            });

我想也许风格.CSS可能是问题:

#glCanvas{
background-color: black;
width: 650px;
margin: 0 auto 0 auto;
height: 500px;

所以我尝试删除它,但遗憾的是将它全部删除了。我该怎么办?

0 个答案:

没有答案
相关问题