我正在尝试使用three.js导出器插件加载我在blender中创建的模型。然而,即使我改变了加载属性,我也是一个重复出现的错误,我想知道格式化它的正确方法。
<html>
<head>
<title>three.js</title>
<meta charset="utf-8">
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script src="js/three.min.js"></script>
<script src="js/renderers/Projector.js"></script>
<script src="js/renderers/CanvasRenderer.js"></script>
<script>
// Setup a new scene
var scene = new THREE.Scene();
// Setup the camera
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
camera.position.z = 5;
camera.position.y = 1;
// Setup the renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Add the lights
var ambientLight = new THREE.AmbientLight(0x111111);
scene.add(ambientLight);
var light = new THREE.PointLight( 0xFFFFDD );
light.position.set( -15, 10, 15 );
scene.add( light );
// Models
var model;
var theaterModel;
// instantiate a loader
var loader = new THREE.JSONLoader();
// load a resource
loader.load(
// resource URL
'models/Theater-of-PalmyraNEW.json',
// Function when resource is loaded
function ( geometry, materials ) {
var material = new THREE.MultiMaterial( materials );
var object = new THREE.Mesh( geometry, material );
scene.add( object );
}
);
function render() {
camera.position.x += ( mouseX - camera.position.x ) * .05;
camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05;
camera.lookAt( scene.position );
renderer.render( scene, camera );
}
</script>
</body>
</html>
错误是在three.js文件和three.min.js文件中未被捕获的类型错误。
Uncaught TypeError: Cannot read property 'length' of undefined
at three.min.js:658
at Jd.parse (three.min.js:661)
at three.min.js:657
at XMLHttpRequest.<anonymous> (three.min.js:605)
这可能只是一个我没有看到的简单错误 - 而且我已经看到其他人遇到了这个问题。