forked from ramity/rift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.js
More file actions
53 lines (41 loc) · 1.41 KB
/
Copy pathcore.js
File metadata and controls
53 lines (41 loc) · 1.41 KB
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
48
49
50
51
52
53
import * as THREE from './node_modules/three/build/three.module.min.js'
var canvas = document.getElementById('display')
var scene = new THREE.Scene()
var camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 0.1, 1000)
var renderer = new THREE.WebGLRenderer({
canvas: canvas,
antialias: true
})
renderer.setClearColor(0x2c3e50);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
var geometry = new THREE.BoxGeometry(1, 1, 1);
var material = new THREE.MeshLambertMaterial({ color: 0x00ff00 });
var cube = new THREE.Mesh(geometry, material);
cube.castShadow = true;
cube.receiveShadow = true;
scene.add(cube);
camera.position.z = 2;
var floor = new THREE.BoxGeometry(9, 9, 1);
var floorMaterial = new THREE.MeshLambertMaterial({ color: 0xe67e22 });
var floorMesh = new THREE.Mesh(floor, floorMaterial);
floorMesh.receiveShadow = true;
floorMesh.position.z = -1;
scene.add(floorMesh);
var light = new THREE.PointLight(0xffee88, 1.5, 10);
light.position.set(1, 1, 1);
light.castShadow = true;
scene.add(light);
// var helper = new THREE.PointLightHelper(light);
// scene.add(helper);
var light = new THREE.AmbientLight(0xbbbbbb);
scene.add(light);
function animate()
{
requestAnimationFrame(animate);
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
// cube.rotation.z += 0.01;
renderer.render(scene, camera);
}
animate();