-1
// set the scene size
var WIDTH = 800;
var HEIGHT = 640;

// set some camera attributes
var VIEW_ANGLE = 45,
ASPECT = WIDTH / HEIGHT,
NEAR = 0.1,
FAR = 10000;

var $container = $('#container');

// create a WebGL renderer, camera
var renderer = new THREE.WebGLRenderer();
var camera = new THREE.PerspectiveCamera(VIEW_ANGLE,
                                         ASPECT,
                                         NEAR,
                                         FAR);
var scene = new THREE.Scene();

// the camera starts at 0,0,0 so pull it back
camera.position.z = 1000;

// start the renderer
renderer.setSize(WIDTH, HEIGHT);

// attach the render-supplied DOM element
$container.append(renderer.domElement);

// create the sphere's material
var sphereMaterial = new THREE.MeshLambertMaterial({
  color: 0xCC0000
});

// set up the sphere vars
var radius = 50, segments = 16, rings = 16;

// create a new mesh with sphere geometry -
// we will cover the sphereMaterial next!
var sphere = new THREE.Mesh(
  new THREE.SphereGeometry(radius, segments, rings),
  sphereMaterial);

sphere.position.x = 20;
sphere.doubleSided = true;

// add the sphere to the scene
scene.add(sphere);

// and the camera
scene.add(camera);

/* Light it up */
var pointLight = new THREE.PointLight(0xFFFFFF);
pointLight.position.x = 10;
pointLight.position.y = 50;
pointLight.position.z = 130;
scene.add(pointLight);

window.setInterval(update, 16.66666666);

var keyboard = new THREEx.KeyboardState();

function update() {
  if (keyboard.pressed("W")) {
    camera.position.z -= 5;
  } else if (keyboard.pressed("S")) {
    camera.position.z += 5;
  }

  renderer.render(scene, camera);
}

那是我的代码,这里使用 W 和 S 键的简单演示让我可以放大/缩小 3D 球体。

但是,当我进入球体“内部”时,我看不到它的背面,即使我放了sphere.doubleSided = true;.

我试过把renderer.setFaceCulling(true);(和假的),但他们都没有修复它。

有任何想法吗?

4

1 回答 1

2

用于side: THREE.DoubleSide材料

您使用的是哪个版本的three.js?

jsfiddle

于 2012-12-26T13:27:30.430 回答