gpt4 book ai didi

three.js - THREE.PlaneGeometry 没有被渲染

转载 作者:行者123 更新时间:2023-12-02 00:21:39 26 4
gpt4 key购买 nike

我试过使用 aerotwist 的教程。一切顺利,直到我搞砸了 THREE.PlaneGeometry,如下面的代码:

var $container = $('#container');
var WIDTH = $container.width(), HEIGHT = $container.height();
var VIEW_ANGLE = 45, ASPECT = WIDTH / HEIGHT, NEAR = 0.1, FAR = 10000;

var renderer = new THREE.WebGLRenderer();
var camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
var scene = new THREE.Scene();
camera.position.z = 300;
renderer.setSize(WIDTH, HEIGHT);
$container.append(renderer.domElement);

// create the mesh's material
var meshMaterial = new THREE.MeshBasicMaterial({color:0xCC0000});
var mesh = new THREE.Mesh(new THREE.CubeGeometry(100,100,1,1),meshMaterial);

// add the mesh to the scene
scene.add(mesh);
scene.add(camera);
renderer.render(scene, camera);

当我改变线路时

var mesh = new THREE.Mesh(new THREE.CubeGeometry(100,100,1,1),meshMaterial);

var mesh = new THREE.Mesh(new THREE.PlaneGeometry(100,100,1,1),meshMaterial);

var mesh = new THREE.Mesh(new THREE.PlaneGeometry(100,100),meshMaterial);

然后什么都不渲染。怎么了?

最佳答案

它可能不是双面的,或者您无法在当前角度看到它,请查看 js fiddle of plane rotating和那个一起玩练习。

编辑:

看起来飞机面朝下所以相机看不到它,我更改了 mesh.rotation.x 以证明它确实渲染了。

参见 - updated example

关于three.js - THREE.PlaneGeometry 没有被渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10713021/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com