瀏覽代碼

switch to phong material

Gregg Tavares 7 年之前
父節點
當前提交
d546089788
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      threejs/threejs-fundamentals-3-cubes.html

+ 5 - 1
threejs/threejs-fundamentals-3-cubes.html

@@ -27,13 +27,17 @@ function main() {
 
 
   const scene = new THREE.Scene();
   const scene = new THREE.Scene();
 
 
+  const light = new THREE.DirectionalLight(0xffffff, 1);
+  light.position.set(-1, 2, 4);
+  scene.add(light);
+
   const boxWidth = 1;
   const boxWidth = 1;
   const boxHeight = 1;
   const boxHeight = 1;
   const boxDepth = 1;
   const boxDepth = 1;
   const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
   const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
 
 
   function makeInstance(geometry, color, x) {
   function makeInstance(geometry, color, x) {
-    const material = new THREE.MeshBasicMaterial({color});
+    const material = new THREE.MeshPhongMaterial({color});
 
 
     const cube = new THREE.Mesh(geometry, material);
     const cube = new THREE.Mesh(geometry, material);
     scene.add(cube);
     scene.add(cube);