Three.js 第一枪
Three.js学习笔记
var和let和const的区别
const 定义常量 let 有区域 var 整个函数内都有效
|
代码
<head> <meta charset="UTF-8"> <title>第一枪</title> <style> body { margin: 0; overflow: hidden; } </style> <script src="http://www.yanhuangxueyuan.com/versions/threejsR92/build/three.js"></script> </head>
<body> <script>
let sdq = new THREE.Scene();
let wuti = new THREE.BoxGeometry(150, 150, 150); let material = new THREE.MeshLambertMaterial({ color: 0xDC143C }); var mesh = new THREE.Mesh(wuti, material); sdq.add(mesh);
var point = new THREE.PointLight(0xffffff);
point.position.set(260, 600, 200); sdq.add(point); var ambient = new THREE.AmbientLight(0x444444); sdq.add(ambient);
let width = window.innerWidth; let height = window.innerHeight; let k = width / height; let s = 250; let camera = new THREE.OrthographicCamera(-s * k, s * k, s, -s, 1, 1000); camera.position.set(200, 300, 200); camera.lookAt(sdq.position);
let renderer = new THREE.WebGLRenderer(); renderer.setSize(width, height); renderer.setClearColor(0xb9d3ff, 1); document.body.appendChild(renderer.domElement); renderer.render(sdq, camera); </script> </body>
|
正方体
球体
作者: 我叫史迪奇
本文来自于:
https://sdq3.link/Three.html博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议