-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathteapot.js
61 lines (51 loc) · 1.73 KB
/
teapot.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var teapotSize = 400;
var tess = -1; // force initialization
effectController = {
shininess: 40.0,
ka: 0.17,
kd: 0.51,
ks: 0.2,
metallic: true,
hue: 0.121,
saturation: 0.73,
lightness: 0.66,
lhue: 0.04,
lsaturation: 0.01, // non-zero so that fractions will be shown
llightness: 1.0,
// bizarrely, if you initialize these with negative numbers, the sliders
// will not show any decimal places.
lx: 0.32,
ly: 0.39,
lz: 0.7,
newTess: 15,
bottom: true,
lid: true,
body: true,
fitLid: false,
nonblinn: false,
newShading: "glossy"
};
var shading = 'smooth';
// MATERIALS
var materialColor = new THREE.Color();
materialColor.setRGB( 1.0, 1.0, 1.0 );
wireMaterial = new THREE.MeshBasicMaterial( { color: 0xFFFFFF, wireframe: true } ) ;
flatMaterial = new THREE.MeshPhongMaterial( { color: materialColor, specular: 0x0, shading: THREE.FlatShading, side: THREE.DoubleSide } );
gouraudMaterial = new THREE.MeshLambertMaterial( { color: materialColor, side: THREE.DoubleSide } );
phongMaterial = new THREE.MeshPhongMaterial( { color: materialColor, shading: THREE.SmoothShading, side: THREE.DoubleSide } );
var teapotGeometry = new THREE.TeapotBufferGeometry( teapotSize,
tess,
effectController.bottom,
effectController.lid,
effectController.body,
effectController.fitLid,
! effectController.nonblinn );
teapot = new THREE.Mesh(
teapotGeometry,
shading === "wireframe" ? wireMaterial : (
shading === "flat" ? flatMaterial : (
shading === "smooth" ? gouraudMaterial : (
shading === "glossy" ? phongMaterial : (
reflectiveMaterial ) ) ) ) ); // if no match, pick Phong
teapot.scale.multiplyScalar(0.4);
module.exports = teapot;