(我删除了之前的问题,因为现在我知道了问题,可以给出更好的标题。我想我会自己回答这个问题。)
此示例来自https://github.com/mrdoob/three.js/wiki/Getting-Started
问题是该示例在FF45或GC50上对我不起作用。它只显示灰色背景。它适用于IE11。
解决方法是使用MeshPhongMaterial而不是MeshLambertMaterial。然后它适用于所有3个浏览器。
我正在使用three.js R75和Windows 10.我不确定这是否是其他情况下的问题。
<!DOCTYPE html>
<html>
<head>
<title>Getting Started with Three.js</title>
<script src="three.min.js"></script>
<script>
window.onload = function() {
var renderer = new THREE.WebGLRenderer();
renderer.setSize( 800, 600 );
document.body.appendChild( renderer.domElement );
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
35, // Field of view
800 / 600, // Aspect ratio
0.1, // Near plane
10000 // Far plane
);
camera.position.set( -15, 10, 10 );
camera.lookAt( scene.position );
var geometry = new THREE.BoxGeometry( 5, 5, 5 );
var material = new THREE.MeshLambertMaterial( { color: 0xFF0000 } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
var light = new THREE.PointLight( 0xFFFF00 );
light.position.set( 10, 0, 10 );
scene.add( light );
renderer.setClearColor( 0xdddddd, 1);
renderer.render( scene, camera );
};
</script>
</head>
<body></body>
</html>