我正在使用以下代码,并且已经浏览了帖子,当然还有所有的 wiki 等等。无论我使用什么 .js JSON 对象,浏览器窗口中都不会出现任何内容。浏览器控制台中没有任何标志,我准备在本地运行。缺少什么/做错了什么?
<body>
<script src="http://threejs.org/build/three.js"></script>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
var geometry;
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var material = new THREE.MeshBasicMaterial({color: 0x00ff00});
loader = new THREE.JSONLoader();
loader.load( "LeePerrySmith.js", function( geometry ) {
mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial() );
mesh.scale.set( 10, 10, 10 );
mesh.position.y = 0;
mesh.position.x = 0;
mesh.scale.set( 100, 100, 100 );
scene.add( mesh );
mesh.side = THREE.DoubleSide;
alert("hit");
} );
camera.position.z = 5;
var render = function () {
renderer.render(scene, camera);
};
render();
</script>
</body>
新代码
<script src="http://threejs.org/build/three.js"></script>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
var geometry;
var material = new THREE.MeshBasicMaterial({color: 0x00ff00});
var mesh = new THREE.Mesh( geometry, material );
loader = new THREE.JSONLoader();
loader.load( "LeePerrySmith.js", function( geometry ) {
mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial() );
mesh.scale.set( 10, 10, 10 );
mesh.position.y = 0;
mesh.position.x = 0;
mesh.scale.set( 100, 100, 100 );
scene.add( mesh );
mesh.side = THREE.DoubleSide;
alert("hit");
render();
} );
camera.position.z = 1000;
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var render = function () {
renderer.render(scene, camera);
};
</script>