-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriangle_colored.html
More file actions
50 lines (48 loc) · 1.87 KB
/
triangle_colored.html
File metadata and controls
50 lines (48 loc) · 1.87 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
<!DOCTYPE html>
<html>
<head>
<title>Triangle Coloured</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style>
body{
background-color:#000000;
overflow:hidden;
</style>
<script src="js/three.min.js"></script>
</head>
<body id="canvas">
<script>
init();
render();
var scene;
var camera;
var renderer;
function init(){
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.getElementById("canvas").appendChild(renderer.domElement);
scene=new THREE.Scene();
camera=new THREE.PerspectiveCamera(30,window.innerWidth/window.innerHeight,1,100);
camera.position.set(0,0,10);
var triangleGeometry=new THREE.Geometry();
triangleGeometry.vertices.push(new THREE.Vector3( 0.0, 1.0, 0.0));
triangleGeometry.vertices.push(new THREE.Vector3(-1.0, -1.0, 0.0));
triangleGeometry.vertices.push(new THREE.Vector3( 1.0, -1.0, 0.0));
triangleGeometry.faces.push(new THREE.Face3(0, 1, 2));
triangleGeometry.faces[0].vertexColors[0]=new THREE.Color(0xFF0000);
triangleGeometry.faces[0].vertexColors[1]=new THREE.Color(0x00FF00);
triangleGeometry.faces[0].vertexColors[2]=new THREE.Color(0x0000FF);
var material=new THREE.MeshBasicMaterial({
vertexColors:THREE.VertexColors,
side:THREE.DoubleSide
});
var triangleMesh=new THREE.Mesh(triangleGeometry,material);
triangleMesh.position.set(-0.0, 0.0, 3.0);
scene.add(triangleMesh);
}
function render(){
renderer.render(scene,camera);
}
</script>
</body>
</html>