我正在使用 THREE.js 迈出第一步。
现在,我只是尝试修改此处找到的示例文件:http: //aerotwist.com/tutorials/getting-started-with-three-js/
该文件创建一个三个场景,添加一个球体和一个点光源。
我的问题是:我找不到如何用我使用搅拌机 2.63 创建并使用搅拌机 2.63 导出器导出的模型替换球体。
我想我的语法有点错误。
下面是我的代码。有人能告诉我要改变什么才能让我的搅拌机模型在舞台上展示吗?
谢谢。
<head>
<meta charset="utf-8" />
<title>Sample Three.js</title>
<link rel="stylesheet" href="js/Styles.css" />
</head>
<body>
<div id="container">
</div>
</body>
<script src="js/Stats.js"></script>
<script src="js/Three.js"></script>
<script>
var WIDTH = 700,
HEIGHT = 600;
var VIEW_ANGLE = 45,
ASPECT = WIDTH / HEIGHT,
NEAR = 0.1,
FAR = 10000;
var container = window.document.getElementById('container');
var renderer = new THREE.WebGLRenderer();
var camera = new THREE.PerspectiveCamera( VIEW_ANGLE,
ASPECT,
NEAR,
FAR );
var scene = new THREE.Scene();
camera.position.z = 300;
renderer.setSize(WIDTH, HEIGHT);
container.appendChild(renderer.domElement);
var sphereMaterial = new THREE.MeshLambertMaterial(
{
color: 0xCC0000
});
//var radius = 50, segments = 16, rings = 16;
var loader = new THREE.JSONLoader();
loader.load( 'js/ModelTest.js', function ( geometry ) {
mesh = new THREE.Mesh( geometry, sphereMaterial );
scene.add( mesh );
mesh.position.x = 0;
mesh.position.y = 0;
mesh.position.z = 0;
alert(mesh.geometry.vertices.length)
} );
//var sphere = new THREE.Mesh(
//new THREE.SphereGeometry(radius, segments, rings),sphereMaterial);
//scene.add(sphere);
scene.add(camera);
var pointLight = new THREE.PointLight( 0xFFFFFF );
pointLight.position.x = 10;
pointLight.position.y = 50;
pointLight.position.z = 130;
scene.add(pointLight);
renderer.render(scene, camera);
</script>