我正在尝试从他们的入门指南中学习Three.js:http://threejs.org/docs/index.html#Manual/Introduction/Creating_a_scene我的代码完全来自网站。我正在使用他们网站上的最新代码,就像图书馆一样。控制台中的错误如下:
Uncaught TypeError: Object #<Object> has no method 'mergeVertices'
我不太确定问题是什么
以下是我正在使用的网站的代码:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>First Three JS App</title>
<style>
body {
margin: 0;
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<script src="js/three.js"></script>
<script>
// To be able to view anything with Three.js we need a scene, a camera, and a renderer
// -> To render the scene with the camera
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth / window.innerHeight );
document.body.appendChild( renderer.domElement );
var geometry = THREE.BoxGeometry(10, 10, 10 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 });
var cube = new THREE.Mesh( geometry, material);
scene.add( cube );
camera.position.z = 5;
var render = function render() {
requestAnimationFrame( render )
cube.rotation.x += 0.1;
cube.rotation.y += 0.1;
renderer.render( scene, camera );
};
render();
</script>
</body>
</html>
答案 0 :(得分:0)
从@WestLangley建议,我需要检查我的代码。我错过了几何声明中的new
,我的renderer.setSize
调用需要2个参数而不是1个(我使用的是比率)而最终var render = function....
我需要取出第二个render
{1}}
有时候第二双眼睛是好的..再次感谢@WestLangley