-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplain.ts
47 lines (37 loc) · 1.11 KB
/
plain.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as THREE from 'three';
import MouseTracker from 'MouseTracker';
import animate from 'helpers/animate';
function plainExample(): void {
const width = window.innerWidth;
const height = window.innerHeight;
const ratio = width / height;
const renderer = new THREE.WebGLRenderer();
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(70, ratio, 0.1, 1000);
renderer.setSize(width, height, false);
renderer.setClearColor(0x000000, 1);
document.body.appendChild(renderer.domElement);
camera.position.set(0, 2, 2);
camera.rotateX(-Math.PI / 4);
const wireframe = new THREE.Mesh(
// @ts-expect-error
new THREE.PlaneBufferGeometry(10, 10, 10, 10).rotateX(-Math.PI / 2),
new THREE.MeshBasicMaterial({
color: 0xff0000,
wireframe: true
})
);
scene.add(wireframe);
const mouse = new MouseTracker({
mesh: wireframe,
camera,
// tracker: (xyz) => console.log(xyz),
debug: true
});
if (mouse.object) {
scene.add(mouse.object);
}
renderer.render(scene, camera);
animate(renderer, scene, camera);
}
export default plainExample;