Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 三点半不显示_Javascript_Three.js - Fatal编程技术网

Javascript 三点半不显示

Javascript 三点半不显示,javascript,three.js,Javascript,Three.js,我试图显示我的ply modifying three.js webgl_loader_ply示例,但它没有显示任何内容。当我用MeshLab打开帘布层时,我可以看到对象。我尝试过缩小、更改相机角度、禁用阴影灯,但都没有效果。还有什么建议吗 下面是已编辑的webgl_loader_ply.html <!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - P

我试图显示我的ply modifying three.js webgl_loader_ply示例,但它没有显示任何内容。当我用MeshLab打开帘布层时,我可以看到对象。我尝试过缩小、更改相机角度、禁用阴影灯,但都没有效果。还有什么建议吗

下面是已编辑的webgl_loader_ply.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>three.js webgl - PLY</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <style>
            body {
                font-family: Monospace;
                background-color: #000000;
                margin: 0px;
                overflow: hidden;
            }

            #info {
                color: #fff;
                position: absolute;
                top: 10px;
                width: 100%;
                text-align: center;
                z-index: 100;
                display:block;

            }

            a { color: skyblue }
            .button { background:#999; color:#eee; padding:0.2em 0.5em; cursor:pointer }
            .highlight { background:orange; color:#fff; }

            span {
                display: inline-block;
                width: 60px;
                float: left;
                text-align: center;
            }

        </style>
    </head>
    <body>
        <div id="info">
            <a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> -
            PLY loader test by <a href="https://github.com/menway">Wei Meng</a>. Image from <a href="http://people.sc.fsu.edu/~jburkardt/data/ply/ply.html">John Burkardt</a>
        </div>

        <script src="../build/three.js"></script>

        <script src="js/loaders/PLYLoader.js"></script>

        <script src="js/Detector.js"></script>
        <script src="js/libs/stats.min.js"></script>

        <script>

            if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

            var container, stats;

            var camera, cameraTarget, scene, renderer;

            init();
            animate();

            function init() {

                container = document.createElement( 'div' );
                document.body.appendChild( container );

                camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 1, 15 );
                camera.position.set( 3, 0.15, 3  );

                cameraTarget = new THREE.Vector3( 0, -0.1, 0 );

                scene = new THREE.Scene();
                scene.background = new THREE.Color( 0x72645b );
                scene.fog = new THREE.Fog( 0x72645b, 2, 15 );


                // Ground

                var plane = new THREE.Mesh(
                    new THREE.PlaneBufferGeometry( 40, 40 ),
                    new THREE.MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } )
                );
                plane.rotation.x = -Math.PI/2;
                plane.position.y = -0.5;
                scene.add( plane );

                plane.receiveShadow = true;


                // PLY file

                var loader = new THREE.PLYLoader();
                loader.load( './models/ply/binary/foot.ply', function ( geometry ) {

                    geometry.computeVertexNormals();

                    var material = new THREE.MeshStandardMaterial( { color: 0x0055ff, flatShading: true } );
                    var mesh = new THREE.Mesh( geometry, material );

                    mesh.position.y = - 0.2;
                    mesh.position.z =   0.3;
                    mesh.rotation.x = - Math.PI / 2;
                    mesh.scale.multiplyScalar( 0.001 );

                    mesh.castShadow = true;
                    mesh.receiveShadow = true;

                    scene.add( mesh );

                } );


                // Lights

                scene.add( new THREE.HemisphereLight( 0x443333, 0x111122 ) );

                addShadowedLight( 1, 1, 1, 0xffffff, 1.35 );
                addShadowedLight( 0.5, 1, -1, 0xffaa00, 1 );

                // renderer

                renderer = new THREE.WebGLRenderer( { antialias: true } );
                renderer.setPixelRatio( window.devicePixelRatio );
                renderer.setSize( window.innerWidth, window.innerHeight );

                renderer.gammaInput = true;
                renderer.gammaOutput = true;

                renderer.shadowMap.enabled = true;
                renderer.shadowMap.renderReverseSided = false;

                container.appendChild( renderer.domElement );

                // stats

                stats = new Stats();
                container.appendChild( stats.dom );

                // resize

                window.addEventListener( 'resize', onWindowResize, false );

            }

            function addShadowedLight( x, y, z, color, intensity ) {

                var directionalLight = new THREE.DirectionalLight( color, intensity );
                directionalLight.position.set( x, y, z );
                scene.add( directionalLight );

                directionalLight.castShadow = true;

                var d = 1;
                directionalLight.shadow.camera.left = -d;
                directionalLight.shadow.camera.right = d;
                directionalLight.shadow.camera.top = d;
                directionalLight.shadow.camera.bottom = -d;

                directionalLight.shadow.camera.near = 1;
                directionalLight.shadow.camera.far = 4;

                directionalLight.shadow.mapSize.width = 1024;
                directionalLight.shadow.mapSize.height = 1024;

                directionalLight.shadow.bias = -0.005;

            }

            function onWindowResize() {

                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();

                renderer.setSize( window.innerWidth, window.innerHeight );

            }

            function animate() {

                requestAnimationFrame( animate );
                render();
                stats.update();

            }

            function render() {

                var timer = Date.now() * 0.0005;

                camera.position.x = Math.sin( timer ) * 2.5;
                camera.position.z = Math.cos( timer ) * 2.5;

                camera.lookAt( cameraTarget );

                renderer.render( scene, camera );

            }

        </script>
    </body>
</html>

three.js webgl-PLY
身体{
字体系列:Monospace;
背景色:#000000;
边际:0px;
溢出:隐藏;
}
#信息{
颜色:#fff;
位置:绝对位置;
顶部:10px;
宽度:100%;
文本对齐:居中;
z指数:100;
显示:块;
}
a{color:skyblue}
.按钮{背景:#999;颜色:#eee;填充:0.2em 0.5em;光标:指针}
.突出显示{背景:橙色;颜色:#fff;}
跨度{
显示:内联块;
宽度:60px;
浮动:左;
文本对齐:居中;
}
-
层板装载机试验。来自
如果(!Detector.webgl)Detector.addGetWebGLMessage();
var容器,stats;
var摄影机、摄影机目标、场景、渲染器;
init();
制作动画();
函数init(){
container=document.createElement('div');
文件.正文.附件(容器);
摄像头=新的三个透视摄像头(35,window.innerWidth/window.innerHeight,1,15);
摄像机位置设置(3,0.15,3);
cameraTarget=新的三个矢量3(0,-0.1,0);
场景=新的三个。场景();
scene.background=新的三种颜色(0x72645b);
scene.fog=新的3.fog(0x72645b,2,15);
//地面
var平面=新的三点网格(
新的3.平面缓冲几何体(40,40),
新的三点网格材质({颜色:0x999999,镜面反射:0x101010})
);
plane.rotation.x=-Math.PI/2;
平面位置y=-0.5;
场景。添加(平面);
plane.receiveShadow=true;
//层锉
var loader=new THREE.PLYLoader();
loader.load('./型号/ply/binary/foot.ply',函数(几何){
geometry.computeVertexNormals();
var material=new THREE.MeshStandardMaterial({color:0x0055ff,flatShading:true});
var mesh=新的三个网格(几何体、材质);
网格位置y=-0.2;
网格位置z=0.3;
mesh.rotation.x=-Math.PI/2;
目数、刻度、多重刻度(0.001);
mesh.castShadow=true;
mesh.receiveShadow=true;
场景。添加(网格);
} );
//灯光
添加(新的三个半球灯光(0x4433330x111122));
添加阴影灯(1,1,1,0xffffff,1.35);
添加阴影灯(0.5,1,-1,0xffaa00,1);
//渲染器
renderer=new THREE.WebGLRenderer({antialas:true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth、window.innerHeight);
renderer.gammaInput=true;
renderer.gammaOutput=true;
renderer.shadowMap.enabled=true;
renderer.shadowMap.renderReverseSided=false;
container.appendChild(renderer.doElement);
//统计数据
统计数据=新统计数据();
container.appendChild(stats.dom);
//调整大小
addEventListener('resize',onWindowResize,false);
}
函数addShadowedLight(x、y、z、颜色、强度){
var directionalLight=新的三个方向光(颜色、强度);
方向光位置设置(x,y,z);
场景。添加(方向光);
directionalLight.castShadow=真;
var d=1;
directionalLight.shadow.camera.left=-d;
directionalLight.shadow.camera.right=d;
directionalLight.shadow.camera.top=d;
directionalLight.shadow.camera.bottom=-d;
directionalLight.shadow.camera.near=1;
directionalLight.shadow.camera.far=4;
directionalLight.shadow.mapSize.width=1024;
directionalLight.shadow.mapSize.height=1024;
方向光.shadow.bias=-0.005;
}
函数onWindowResize(){
camera.aspect=window.innerWidth/window.innerHeight;
camera.updateProjectMatrix();
renderer.setSize(window.innerWidth、window.innerHeight);
}
函数animate(){
请求动画帧(动画);
render();
stats.update();
}
函数render(){
var timer=Date.now()*0.0005;
camera.position.x=数学sin(计时器)*2.5;
camera.position.z=数学cos(计时器)*2.5;
摄像机。注视(摄像机目标);
渲染器。渲染(场景、摄影机);
}

如果您注释掉这些行,您将看到它

mesh.rotation.x = - Math.PI / 2;
mesh.scale.multiplyScalar( 0.001 );

如果您注释掉这些行,您将看到它

mesh.rotation.x = - Math.PI / 2;
mesh.scale.multiplyScalar( 0.001 );

了解.ply模型不显示的原因是什么是很有趣的