如何使用threejs使平面几何外观相机

时间:2016-12-27 12:44:45

标签: javascript 3d camera three.js

当旋转相机时,我已将球体和平面几何体添加到场景中,平面几何应该看到 相机,我用过camera.lookAt(plane.position);这没用,然后我试着用 plane.quaternion.copy(camera.quaternion);只有1个平面几何看着相机可以请有人帮忙 我该如何解决这个问题。我还在下面添加了图片和代码。

            var canvas = document.createElement('canvas');
            var context = canvas.getContext('2d');
            var metrics = context.measureText( cardinal.name );
            var textWidth = metrics.width;
            context.fontSize = '100pt Calibri';
            context.fillStyle = 'red';

            context.fillText(cardinal.name, 0, 50);
            var texture = new THREE.Texture(canvas) ;
            texture.needsUpdate = true;
            //var spriteAlignment = new THREE.Vector2(0,0) ;
            var material = new THREE.MeshBasicMaterial( {color: 0xffffff, side: THREE.DoubleSide ,map : texture} );
            var geometry = new THREE.PlaneGeometry( 0.5, 0.3);
            plane = new THREE.Mesh( geometry, material );
            plane.position.set(X_value,0,Z_value);


            //camera.lookAt(X_value,0,Z_value);
            //plane.lookAt(camera.position);
            scene.add(plane);


            }
function animate(spritearray) {

                //sprite.update();
                //spritearray.update();

                for(var j=0; j<spritearray.length; j++){

                    var labelupdate = spritearray[j];
                    labelupdate.update();
                }
                requestAnimationFrame(animate); 
                controls.update();
                renderer.render(scene, camera);


                camera.lookAt( plane.position );

            }

0 个答案:

没有答案