-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (31 loc) · 1.23 KB
/
main.js
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
import * as THREE from 'https://cdn.skypack.dev/[email protected]';
import { OrbitControls } from 'https://cdn.skypack.dev/[email protected]/examples/jsm/controls/OrbitControls.js';
// setup scene and camera
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf0f0ff);
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
// create renderer
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
// controls
const controls = new OrbitControls( camera, renderer.domElement );
// geometry
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
const sp_geo = new THREE.SphereGeometry(0.1, 6, 6);
//const material = new THREE.MeshBasicMaterial({color: 0xff0b34});
const sp = new THREE.Mesh(sp_geo, material);
sp.translateZ(3);
scene.add(sp);
camera.position.y = 5;
camera.position.z = -5;
camera.lookAt(0,0,0);
const animate = function () {
requestAnimationFrame( animate );
// do stuff for changing suff here
renderer.render( scene, camera );
};
animate();