index.js 989 B

123456789101112131415161718192021222324252627282930
  1. //import * as three from "three";
  2. //import {OribitControls} from "orbitControls";
  3. const canvas = document.getElementById("canvas");
  4. const renderer = new three.WebGLRenderer({antialias: true, canvas});
  5. const camera = new three.PerpectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
  6. camera.position.z = 5;
  7. camera.position.y = 1.8;
  8. const controls = new OrbitControls(camera, renderer.domElement);
  9. const scene = new three.Scene();
  10. const light = new three.DirectionalLight(0xffffff, 3);
  11. scene.add(light);
  12. const floorGom = new three.PlaneGeometry(100, 100);
  13. const loader = new three.TextureLoader();
  14. const floorTex = loader.load("./americanChestnut.jpg", (t)=>{
  15. t.wrapS = t.wrapT = three.RepeatWrapping;
  16. t.offset.set(0, 0);
  17. t.repeat.set(10, 10);
  18. });
  19. floorTex.colorSpace = three.SRGBColorSpace;
  20. const floorMat = new three.MeshBasicMaterial({map: floorTex});
  21. const floor = new three.Mesh(floorGom, floorMat);
  22. floor.rotation.x = -(Math.PI / 2);
  23. scene.add(floor);