Three.js 入门指南(核心对象)

时间:2023-12-04 14:08:08

  推荐大家可以看看这个:http://wenku.baidu.com/link?url=RQU2exzV_EF3GATc3bzQU2o9LGMuCmiN5nUJth5SLG3E2TrxtBLQodJU_kZgfJjd9ljtR5XhZlHdzoHJ6kLeAF4uC9dttM1sNer60lg09gS对于初步了解是极好的了。

官网:https://threejs.org/

中文文档:http://techbrood.com/threejs/docs/

three.js核心对象: scene(场景)

         camera(相机)

         light(光源)

         mesh(模型)

         renderer(渲染器)

         render(渲染)

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="js/three.js"></script>
</head>
<body>
<script type="text/javascript">
var scene = new THREE.Scene(); var geometry = new THREE.BoxGeometry(100,100,100);
var material = new THREE.MeshLambertMaterial({color:0xff0000});
var mesh = new THREE.Mesh(geometry,material);
scene.add(mesh); var light = new THREE.PointLight({color:0xffffff});
light.position.set(300,400,200);
scene.add(light); var camera = new THREE.PerspectiveCamera(40,800/600,1,1000);
camera.position.set(200,200,200);
camera.lookAt(scene.position); var renderer = new THREE.WebGLRenderer();
renderer.setSize(800,600);
document.body.appendChild(renderer.domElement); renderer.render(scene,camera);
</script>
</body>
</html>

Three.js 入门指南(核心对象)

最后的效果如图所示