|
@@ -1,12 +1,13 @@
|
|
|
-//import * as three from "three";
|
|
|
|
|
-//import {OribitControls} from "orbitControls";
|
|
|
|
|
|
|
+import * as three from "three";
|
|
|
|
|
+import {OrbitControls} from "orbitControls";
|
|
|
|
|
|
|
|
|
|
+import {CheapBoard, TwoByFour} from "boards";
|
|
|
|
|
|
|
|
const canvas = document.getElementById("canvas");
|
|
const canvas = document.getElementById("canvas");
|
|
|
const renderer = new three.WebGLRenderer({antialias: true, canvas});
|
|
const renderer = new three.WebGLRenderer({antialias: true, canvas});
|
|
|
|
|
|
|
|
-const camera = new three.PerpectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
|
|
|
|
|
-camera.position.z = 5;
|
|
|
|
|
|
|
+const camera = new three.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
|
|
|
|
|
+camera.position.z = 200;
|
|
|
camera.position.y = 1.8;
|
|
camera.position.y = 1.8;
|
|
|
|
|
|
|
|
const controls = new OrbitControls(camera, renderer.domElement);
|
|
const controls = new OrbitControls(camera, renderer.domElement);
|
|
@@ -16,15 +17,27 @@ const scene = new three.Scene();
|
|
|
const light = new three.DirectionalLight(0xffffff, 3);
|
|
const light = new three.DirectionalLight(0xffffff, 3);
|
|
|
scene.add(light);
|
|
scene.add(light);
|
|
|
|
|
|
|
|
-const floorGom = new three.PlaneGeometry(100, 100);
|
|
|
|
|
-const loader = new three.TextureLoader();
|
|
|
|
|
-const floorTex = loader.load("./americanChestnut.jpg", (t)=>{
|
|
|
|
|
- t.wrapS = t.wrapT = three.RepeatWrapping;
|
|
|
|
|
- t.offset.set(0, 0);
|
|
|
|
|
- t.repeat.set(10, 10);
|
|
|
|
|
-});
|
|
|
|
|
-floorTex.colorSpace = three.SRGBColorSpace;
|
|
|
|
|
-const floorMat = new three.MeshBasicMaterial({map: floorTex});
|
|
|
|
|
-const floor = new three.Mesh(floorGom, floorMat);
|
|
|
|
|
-floor.rotation.x = -(Math.PI / 2);
|
|
|
|
|
-scene.add(floor);
|
|
|
|
|
|
|
+const board = new TwoByFour(scene, 96);
|
|
|
|
|
+
|
|
|
|
|
+function resizeRendererToDisplaySize(renderer){
|
|
|
|
|
+ const canvas = renderer.domElement;
|
|
|
|
|
+ const width = canvas.clientWidth;
|
|
|
|
|
+ const height = canvas.clientHeight;
|
|
|
|
|
+ const needResize = canvas.width !== width || canvas.height !== height;
|
|
|
|
|
+ if(needResize) renderer.setSize(width, height, false);
|
|
|
|
|
+ return needResize;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function render(time){
|
|
|
|
|
+ if(resizeRendererToDisplaySize(renderer)){
|
|
|
|
|
+ const canvas = renderer.domElement;
|
|
|
|
|
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
|
|
|
|
|
+ camera.updateProjectionMatrix();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ renderer.render(scene, camera);
|
|
|
|
|
+ requestAnimationFrame(render);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+renderer.render(scene, camera);
|
|
|
|
|
+requestAnimationFrame(render);
|