// 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 をズームイン/ズームアウトできます。
しかし、球体の「中に入る」と、 を入れても裏側が見えませんsphere.doubleSided = true;
。
私は(そして偽も)入れてみrenderer.setFaceCulling(true);
ましたが、誰もそれを修正しませんでした。
何か案は?