|
@@ -97,11 +97,11 @@
|
|
|
const normalMap = loader.load( 'textures/floors/FloorsCheckerboard_S_Normal.jpg' );
|
|
|
|
|
|
// REFLECTION MAP
|
|
|
- const path = "textures/cube/pisa/";
|
|
|
+ const path = 'textures/cube/pisa/';
|
|
|
const urls = [
|
|
|
- path + "px.png", path + "nx.png",
|
|
|
- path + "py.png", path + "ny.png",
|
|
|
- path + "pz.png", path + "nz.png"
|
|
|
+ path + 'px.png', path + 'nx.png',
|
|
|
+ path + 'py.png', path + 'ny.png',
|
|
|
+ path + 'pz.png', path + 'nz.png'
|
|
|
];
|
|
|
|
|
|
textureCube = new THREE.CubeTextureLoader().load( urls );
|
|
@@ -182,7 +182,7 @@
|
|
|
body: true,
|
|
|
fitLid: false,
|
|
|
nonblinn: false,
|
|
|
- newShading: "glossy"
|
|
|
+ newShading: 'glossy'
|
|
|
};
|
|
|
|
|
|
let h;
|
|
@@ -191,49 +191,49 @@
|
|
|
|
|
|
// material (attributes)
|
|
|
|
|
|
- h = gui.addFolder( "Material control" );
|
|
|
+ h = gui.addFolder( 'Material control' );
|
|
|
|
|
|
- h.add( effectController, "shininess", 1.0, 400.0, 1.0 ).name( "shininess" ).onChange( render );
|
|
|
- h.add( effectController, "kd", 0.0, 1.0, 0.025 ).name( "diffuse strength" ).onChange( render );
|
|
|
- h.add( effectController, "ks", 0.0, 1.0, 0.025 ).name( "specular strength" ).onChange( render );
|
|
|
- h.add( effectController, "metallic" ).onChange( render );
|
|
|
+ h.add( effectController, 'shininess', 1.0, 400.0, 1.0 ).name( 'shininess' ).onChange( render );
|
|
|
+ h.add( effectController, 'kd', 0.0, 1.0, 0.025 ).name( 'diffuse strength' ).onChange( render );
|
|
|
+ h.add( effectController, 'ks', 0.0, 1.0, 0.025 ).name( 'specular strength' ).onChange( render );
|
|
|
+ h.add( effectController, 'metallic' ).onChange( render );
|
|
|
|
|
|
// material (color)
|
|
|
|
|
|
- h = gui.addFolder( "Material color" );
|
|
|
+ h = gui.addFolder( 'Material color' );
|
|
|
|
|
|
- h.add( effectController, "hue", 0.0, 1.0, 0.025 ).name( "hue" ).onChange( render );
|
|
|
- h.add( effectController, "saturation", 0.0, 1.0, 0.025 ).name( "saturation" ).onChange( render );
|
|
|
- h.add( effectController, "lightness", 0.0, 1.0, 0.025 ).name( "lightness" ).onChange( render );
|
|
|
+ h.add( effectController, 'hue', 0.0, 1.0, 0.025 ).name( 'hue' ).onChange( render );
|
|
|
+ h.add( effectController, 'saturation', 0.0, 1.0, 0.025 ).name( 'saturation' ).onChange( render );
|
|
|
+ h.add( effectController, 'lightness', 0.0, 1.0, 0.025 ).name( 'lightness' ).onChange( render );
|
|
|
|
|
|
// light (point)
|
|
|
|
|
|
- h = gui.addFolder( "Lighting" );
|
|
|
+ h = gui.addFolder( 'Lighting' );
|
|
|
|
|
|
- h.add( effectController, "lhue", 0.0, 1.0, 0.025 ).name( "hue" ).onChange( render );
|
|
|
- h.add( effectController, "lsaturation", 0.0, 1.0, 0.025 ).name( "saturation" ).onChange( render );
|
|
|
- h.add( effectController, "llightness", 0.0, 1.0, 0.025 ).name( "lightness" ).onChange( render );
|
|
|
- h.add( effectController, "ka", 0.0, 1.0, 0.025 ).name( "ambient" ).onChange( render );
|
|
|
+ h.add( effectController, 'lhue', 0.0, 1.0, 0.025 ).name( 'hue' ).onChange( render );
|
|
|
+ h.add( effectController, 'lsaturation', 0.0, 1.0, 0.025 ).name( 'saturation' ).onChange( render );
|
|
|
+ h.add( effectController, 'llightness', 0.0, 1.0, 0.025 ).name( 'lightness' ).onChange( render );
|
|
|
+ h.add( effectController, 'ka', 0.0, 1.0, 0.025 ).name( 'ambient' ).onChange( render );
|
|
|
|
|
|
// light (directional)
|
|
|
|
|
|
- h = gui.addFolder( "Light direction" );
|
|
|
+ h = gui.addFolder( 'Light direction' );
|
|
|
|
|
|
- h.add( effectController, "lx", - 1.0, 1.0, 0.025 ).name( "x" ).onChange( render );
|
|
|
- h.add( effectController, "ly", - 1.0, 1.0, 0.025 ).name( "y" ).onChange( render );
|
|
|
- h.add( effectController, "lz", - 1.0, 1.0, 0.025 ).name( "z" ).onChange( render );
|
|
|
+ h.add( effectController, 'lx', - 1.0, 1.0, 0.025 ).name( 'x' ).onChange( render );
|
|
|
+ h.add( effectController, 'ly', - 1.0, 1.0, 0.025 ).name( 'y' ).onChange( render );
|
|
|
+ h.add( effectController, 'lz', - 1.0, 1.0, 0.025 ).name( 'z' ).onChange( render );
|
|
|
|
|
|
- h = gui.addFolder( "Tessellation control" );
|
|
|
- h.add( effectController, "newTess", [ 2, 3, 4, 5, 6, 8, 10, 15, 20, 30, 40, 50 ] ).name( "Tessellation Level" ).onChange( render );
|
|
|
- h.add( effectController, "lid" ).name( "display lid" ).onChange( render );
|
|
|
- h.add( effectController, "body" ).name( "display body" ).onChange( render );
|
|
|
- h.add( effectController, "bottom" ).name( "display bottom" ).onChange( render );
|
|
|
- h.add( effectController, "fitLid" ).name( "snug lid" ).onChange( render );
|
|
|
- h.add( effectController, "nonblinn" ).name( "original scale" ).onChange( render );
|
|
|
+ h = gui.addFolder( 'Tessellation control' );
|
|
|
+ h.add( effectController, 'newTess', [ 2, 3, 4, 5, 6, 8, 10, 15, 20, 30, 40, 50 ] ).name( 'Tessellation Level' ).onChange( render );
|
|
|
+ h.add( effectController, 'lid' ).name( 'display lid' ).onChange( render );
|
|
|
+ h.add( effectController, 'body' ).name( 'display body' ).onChange( render );
|
|
|
+ h.add( effectController, 'bottom' ).name( 'display bottom' ).onChange( render );
|
|
|
+ h.add( effectController, 'fitLid' ).name( 'snug lid' ).onChange( render );
|
|
|
+ h.add( effectController, 'nonblinn' ).name( 'original scale' ).onChange( render );
|
|
|
|
|
|
// shading
|
|
|
|
|
|
- gui.add( effectController, "newShading", [ "wireframe", "flat", "smooth", "glossy", "textured", "normal", "reflective" ] ).name( "Shading" ).onChange( render );
|
|
|
+ gui.add( effectController, 'newShading', [ 'wireframe', 'flat', 'smooth', 'glossy', 'textured', 'normal', 'reflective' ] ).name( 'Shading' ).onChange( render );
|
|
|
|
|
|
const exportButton = document.getElementById( 'export' );
|
|
|
exportButton.addEventListener( 'click', exportCollada );
|
|
@@ -303,7 +303,7 @@
|
|
|
light.color.setHSL( effectController.lhue, effectController.lsaturation, effectController.llightness );
|
|
|
|
|
|
// skybox is rendered separately, so that it is always behind the teapot.
|
|
|
- if ( shading === "reflective" ) {
|
|
|
+ if ( shading === 'reflective' ) {
|
|
|
|
|
|
scene.background = textureCube;
|
|
|
|
|
@@ -337,12 +337,12 @@
|
|
|
|
|
|
teapot = new THREE.Mesh(
|
|
|
teapotGeometry,
|
|
|
- shading === "wireframe" ? wireMaterial : (
|
|
|
- shading === "flat" ? flatMaterial : (
|
|
|
- shading === "smooth" ? gouraudMaterial : (
|
|
|
- shading === "glossy" ? phongMaterial : (
|
|
|
- shading === "textured" ? texturedMaterial : (
|
|
|
- shading === "normal" ? normalMaterial : reflectiveMaterial ) ) ) ) ) ); // if no match, pick Phong
|
|
|
+ shading === 'wireframe' ? wireMaterial : (
|
|
|
+ shading === 'flat' ? flatMaterial : (
|
|
|
+ shading === 'smooth' ? gouraudMaterial : (
|
|
|
+ shading === 'glossy' ? phongMaterial : (
|
|
|
+ shading === 'textured' ? texturedMaterial : (
|
|
|
+ shading === 'normal' ? normalMaterial : reflectiveMaterial ) ) ) ) ) ); // if no match, pick Phong
|
|
|
|
|
|
scene.add( teapot );
|
|
|
|
|
@@ -353,21 +353,21 @@
|
|
|
function exportCollada() {
|
|
|
|
|
|
const result = exporter.parse( teapot, undefined, { upAxis: 'Y_UP', unitName: 'millimeter', unitMeter: 0.001 } );
|
|
|
- let materialType = "Phong";
|
|
|
+ let materialType = 'Phong';
|
|
|
|
|
|
- if ( shading === "wireframe" ) {
|
|
|
+ if ( shading === 'wireframe' ) {
|
|
|
|
|
|
- materialType = "Constant";
|
|
|
+ materialType = 'Constant';
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( shading === "smooth" ) {
|
|
|
+ if ( shading === 'smooth' ) {
|
|
|
|
|
|
- materialType = "Lambert";
|
|
|
+ materialType = 'Lambert';
|
|
|
|
|
|
}
|
|
|
|
|
|
- saveString( result.data, 'teapot_' + shading + "_" + materialType + '.dae' );
|
|
|
+ saveString( result.data, 'teapot_' + shading + '_' + materialType + '.dae' );
|
|
|
|
|
|
result.textures.forEach( tex => {
|
|
|
|