|
@@ -87,6 +87,9 @@ function getObjectsKeys( obj ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+var textureLoader = new THREE.TextureLoader();
|
|
|
+var cubeTextureLoader = new THREE.CubeTextureLoader();
|
|
|
+
|
|
|
var envMaps = ( function () {
|
|
|
|
|
|
var path = '../../examples/textures/cube/SwedishRoyalCastle/';
|
|
@@ -97,10 +100,10 @@ var envMaps = ( function () {
|
|
|
path + 'pz' + format, path + 'nz' + format
|
|
|
];
|
|
|
|
|
|
- var reflectionCube = new THREE.CubeTextureLoader().load( urls );
|
|
|
+ var reflectionCube = cubeTextureLoader.load( urls );
|
|
|
reflectionCube.format = THREE.RGBFormat;
|
|
|
|
|
|
- var refractionCube = new THREE.CubeTextureLoader().load( urls );
|
|
|
+ var refractionCube = cubeTextureLoader.load( urls );
|
|
|
refractionCube.mapping = THREE.CubeRefractionMapping;
|
|
|
refractionCube.format = THREE.RGBFormat;
|
|
|
|
|
@@ -112,18 +115,62 @@ var envMaps = ( function () {
|
|
|
|
|
|
} )();
|
|
|
|
|
|
-var envMapKeys = getObjectsKeys( envMaps );
|
|
|
+var diffuseMaps = ( function () {
|
|
|
+
|
|
|
+ var bricks = textureLoader.load( '../../examples/textures/brick_diffuse.jpg' );
|
|
|
+ bricks.wrapS = THREE.RepeatWrapping;
|
|
|
+ bricks.wrapT = THREE.RepeatWrapping;
|
|
|
+ bricks.repeat.set( 9, 1 );
|
|
|
+
|
|
|
+ return {
|
|
|
+ none: null,
|
|
|
+ bricks: bricks
|
|
|
+ };
|
|
|
+
|
|
|
+} )();
|
|
|
+
|
|
|
+var roughnessMaps = ( function () {
|
|
|
+
|
|
|
+ var bricks = textureLoader.load( '../../examples/textures/brick_roughness.jpg' );
|
|
|
+ bricks.wrapT = THREE.RepeatWrapping;
|
|
|
+ bricks.wrapS = THREE.RepeatWrapping;
|
|
|
+ bricks.repeat.set( 9, 1 );
|
|
|
+
|
|
|
+ return {
|
|
|
+ none: null,
|
|
|
+ bricks: bricks
|
|
|
+ };
|
|
|
|
|
|
-var textureMaps = ( function () {
|
|
|
+} )();
|
|
|
+
|
|
|
+var matcaps = ( function () {
|
|
|
|
|
|
return {
|
|
|
none: null,
|
|
|
- grass: new THREE.TextureLoader().load( '../../examples/textures/terrain/grasslight-thin.jpg' )
|
|
|
+ porcelainWhite: textureLoader.load( '../../examples/textures/matcaps/matcap-porcelain-white.jpg' )
|
|
|
};
|
|
|
|
|
|
} )();
|
|
|
|
|
|
-var textureMapKeys = getObjectsKeys( textureMaps );
|
|
|
+var alphaMaps = ( function () {
|
|
|
+
|
|
|
+ var fibers = textureLoader.load( '../../examples/textures/alphaMap.jpg' );
|
|
|
+ fibers.wrapT = THREE.RepeatWrapping;
|
|
|
+ fibers.wrapS = THREE.RepeatWrapping;
|
|
|
+ fibers.repeat.set( 9, 1 );
|
|
|
+
|
|
|
+ return {
|
|
|
+ none: null,
|
|
|
+ fibers: fibers
|
|
|
+ };
|
|
|
+
|
|
|
+} )();
|
|
|
+
|
|
|
+var envMapKeys = getObjectsKeys( envMaps );
|
|
|
+var diffuseMapKeys = getObjectsKeys( diffuseMaps );
|
|
|
+var roughnessMapKeys = getObjectsKeys( roughnessMaps );
|
|
|
+var matcapKeys = getObjectsKeys( matcaps );
|
|
|
+var alphaMapKeys = getObjectsKeys( alphaMaps );
|
|
|
|
|
|
function generateVertexColors( geometry ) {
|
|
|
|
|
@@ -247,7 +294,7 @@ function guiMaterial( gui, mesh, material, geometry ) {
|
|
|
var folder = gui.addFolder( 'THREE.Material' );
|
|
|
|
|
|
folder.add( material, 'transparent' );
|
|
|
- folder.add( material, 'opacity', 0, 1 );
|
|
|
+ folder.add( material, 'opacity', 0, 1 ).step( 0.01 );
|
|
|
// folder.add( material, 'blending', constants.blendingMode );
|
|
|
// folder.add( material, 'blendSrc', constants.destinationFactors );
|
|
|
// folder.add( material, 'blendDst', constants.destinationFactors );
|
|
@@ -257,7 +304,7 @@ function guiMaterial( gui, mesh, material, geometry ) {
|
|
|
// folder.add( material, 'polygonOffset' );
|
|
|
// folder.add( material, 'polygonOffsetFactor' );
|
|
|
// folder.add( material, 'polygonOffsetUnits' );
|
|
|
- folder.add( material, 'alphaTest', 0, 1 );
|
|
|
+ folder.add( material, 'alphaTest', 0, 1 ).step( 0.01 ).onChange( needsUpdate( material, geometry ) );
|
|
|
folder.add( material, 'visible' );
|
|
|
folder.add( material, 'side', constants.side ).onChange( needsUpdate( material, geometry ) );
|
|
|
|
|
@@ -267,10 +314,9 @@ function guiMeshBasicMaterial( gui, mesh, material, geometry ) {
|
|
|
|
|
|
var data = {
|
|
|
color: material.color.getHex(),
|
|
|
- envMaps: envMapKeys,
|
|
|
- map: textureMapKeys,
|
|
|
- specularMap: textureMapKeys,
|
|
|
- alphaMap: textureMapKeys
|
|
|
+ envMaps: envMapKeys[ 0 ],
|
|
|
+ map: diffuseMapKeys[ 0 ],
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
};
|
|
|
|
|
|
var folder = gui.addFolder( 'THREE.MeshBasicMaterial' );
|
|
@@ -282,9 +328,8 @@ function guiMeshBasicMaterial( gui, mesh, material, geometry ) {
|
|
|
folder.add( material, 'fog' );
|
|
|
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
|
- folder.add( data, 'map', textureMapKeys ).onChange( updateTexture( material, 'map', textureMaps ) );
|
|
|
- folder.add( data, 'specularMap', textureMapKeys ).onChange( updateTexture( material, 'specularMap', textureMaps ) );
|
|
|
- folder.add( data, 'alphaMap', textureMapKeys ).onChange( updateTexture( material, 'alphaMap', textureMaps ) );
|
|
|
+ folder.add( data, 'map', diffuseMapKeys ).onChange( updateTexture( material, 'map', diffuseMaps ) );
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
folder.add( material, 'combine', constants.combine );
|
|
|
folder.add( material, 'reflectivity', 0, 1 );
|
|
|
folder.add( material, 'refractionRatio', 0, 1 );
|
|
@@ -293,11 +338,17 @@ function guiMeshBasicMaterial( gui, mesh, material, geometry ) {
|
|
|
|
|
|
function guiMeshDepthMaterial( gui, mesh, material, geometry ) {
|
|
|
|
|
|
+ var data = {
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
+ };
|
|
|
+
|
|
|
var folder = gui.addFolder( 'THREE.MeshDepthMaterial' );
|
|
|
|
|
|
folder.add( material, 'wireframe' );
|
|
|
folder.add( material, 'wireframeLinewidth', 0, 10 );
|
|
|
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function guiMeshNormalMaterial( gui, mesh, material, geometry ) {
|
|
@@ -332,10 +383,9 @@ function guiMeshLambertMaterial( gui, mesh, material, geometry ) {
|
|
|
var data = {
|
|
|
color: material.color.getHex(),
|
|
|
emissive: material.emissive.getHex(),
|
|
|
- envMaps: envMapKeys,
|
|
|
- map: textureMapKeys,
|
|
|
- specularMap: textureMapKeys,
|
|
|
- alphaMap: textureMapKeys
|
|
|
+ envMaps: envMapKeys[ 0 ],
|
|
|
+ map: diffuseMapKeys[ 0 ],
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
};
|
|
|
|
|
|
var folder = gui.addFolder( 'THREE.MeshLambertMaterial' );
|
|
@@ -349,26 +399,39 @@ function guiMeshLambertMaterial( gui, mesh, material, geometry ) {
|
|
|
folder.add( material, 'fog' );
|
|
|
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
|
- folder.add( data, 'map', textureMapKeys ).onChange( updateTexture( material, 'map', textureMaps ) );
|
|
|
- folder.add( data, 'specularMap', textureMapKeys ).onChange( updateTexture( material, 'specularMap', textureMaps ) );
|
|
|
- folder.add( data, 'alphaMap', textureMapKeys ).onChange( updateTexture( material, 'alphaMap', textureMaps ) );
|
|
|
+ folder.add( data, 'map', diffuseMapKeys ).onChange( updateTexture( material, 'map', diffuseMaps ) );
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
folder.add( material, 'combine', constants.combine );
|
|
|
folder.add( material, 'reflectivity', 0, 1 );
|
|
|
folder.add( material, 'refractionRatio', 0, 1 );
|
|
|
|
|
|
}
|
|
|
|
|
|
+function guiMeshMatcapMaterial( gui, mesh, material ) {
|
|
|
+
|
|
|
+ var data = {
|
|
|
+ color: material.color.getHex(),
|
|
|
+ matcap: matcapKeys[ 1 ],
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
+ };
|
|
|
+
|
|
|
+ var folder = gui.addFolder( 'THREE.MeshMatcapMaterial' );
|
|
|
+
|
|
|
+ folder.addColor( data, 'color' ).onChange( handleColorChange( material.color ) );
|
|
|
+ folder.add( data, 'matcap', matcapKeys ).onChange( updateTexture( material, 'matcap', matcaps ) );
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
function guiMeshPhongMaterial( gui, mesh, material, geometry ) {
|
|
|
|
|
|
var data = {
|
|
|
color: material.color.getHex(),
|
|
|
emissive: material.emissive.getHex(),
|
|
|
specular: material.specular.getHex(),
|
|
|
- envMaps: envMapKeys,
|
|
|
- map: textureMapKeys,
|
|
|
- lightMap: textureMapKeys,
|
|
|
- specularMap: textureMapKeys,
|
|
|
- alphaMap: textureMapKeys
|
|
|
+ envMaps: envMapKeys[ 0 ],
|
|
|
+ map: diffuseMapKeys[ 0 ],
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
};
|
|
|
|
|
|
var folder = gui.addFolder( 'THREE.MeshPhongMaterial' );
|
|
@@ -384,10 +447,8 @@ function guiMeshPhongMaterial( gui, mesh, material, geometry ) {
|
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
|
folder.add( material, 'fog' );
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
|
- folder.add( data, 'map', textureMapKeys ).onChange( updateTexture( material, 'map', textureMaps ) );
|
|
|
- folder.add( data, 'lightMap', textureMapKeys ).onChange( updateTexture( material, 'lightMap', textureMaps ) );
|
|
|
- folder.add( data, 'specularMap', textureMapKeys ).onChange( updateTexture( material, 'specularMap', textureMaps ) );
|
|
|
- folder.add( data, 'alphaMap', textureMapKeys ).onChange( updateTexture( material, 'alphaMap', textureMaps ) );
|
|
|
+ folder.add( data, 'map', diffuseMapKeys ).onChange( updateTexture( material, 'map', diffuseMaps ) );
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -396,11 +457,10 @@ function guiMeshStandardMaterial( gui, mesh, material, geometry ) {
|
|
|
var data = {
|
|
|
color: material.color.getHex(),
|
|
|
emissive: material.emissive.getHex(),
|
|
|
- envMaps: envMapKeys,
|
|
|
- map: textureMapKeys,
|
|
|
- lightMap: textureMapKeys,
|
|
|
- specularMap: textureMapKeys,
|
|
|
- alphaMap: textureMapKeys
|
|
|
+ envMaps: envMapKeys[ 0 ],
|
|
|
+ map: diffuseMapKeys[ 0 ],
|
|
|
+ roughnessMap: roughnessMapKeys[ 0 ],
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
};
|
|
|
|
|
|
var folder = gui.addFolder( 'THREE.MeshStandardMaterial' );
|
|
@@ -416,11 +476,11 @@ function guiMeshStandardMaterial( gui, mesh, material, geometry ) {
|
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
|
folder.add( material, 'fog' );
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
|
- folder.add( data, 'map', textureMapKeys ).onChange( updateTexture( material, 'map', textureMaps ) );
|
|
|
- folder.add( data, 'lightMap', textureMapKeys ).onChange( updateTexture( material, 'lightMap', textureMaps ) );
|
|
|
- folder.add( data, 'alphaMap', textureMapKeys ).onChange( updateTexture( material, 'alphaMap', textureMaps ) );
|
|
|
+ folder.add( data, 'map', diffuseMapKeys ).onChange( updateTexture( material, 'map', diffuseMaps ) );
|
|
|
+ folder.add( data, 'roughnessMap', roughnessMapKeys ).onChange( updateTexture( material, 'roughnessMap', roughnessMaps ) );
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
|
|
|
- // TODO roughnessMap and metalnessMap
|
|
|
+ // TODO metalnessMap
|
|
|
|
|
|
}
|
|
|
|
|
@@ -429,11 +489,10 @@ function guiMeshPhysicalMaterial( gui, mesh, material, geometry ) {
|
|
|
var data = {
|
|
|
color: material.color.getHex(),
|
|
|
emissive: material.emissive.getHex(),
|
|
|
- envMaps: envMapKeys,
|
|
|
- map: textureMapKeys,
|
|
|
- lightMap: textureMapKeys,
|
|
|
- specularMap: textureMapKeys,
|
|
|
- alphaMap: textureMapKeys
|
|
|
+ envMaps: envMapKeys[ 0 ],
|
|
|
+ map: diffuseMapKeys[ 0 ],
|
|
|
+ roughnessMap: roughnessMapKeys[ 0 ],
|
|
|
+ alphaMap: alphaMapKeys[ 0 ]
|
|
|
};
|
|
|
|
|
|
var folder = gui.addFolder( 'THREE.MeshPhysicalMaterial' );
|
|
@@ -452,11 +511,11 @@ function guiMeshPhysicalMaterial( gui, mesh, material, geometry ) {
|
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
|
folder.add( material, 'fog' );
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
|
- folder.add( data, 'map', textureMapKeys ).onChange( updateTexture( material, 'map', textureMaps ) );
|
|
|
- folder.add( data, 'lightMap', textureMapKeys ).onChange( updateTexture( material, 'lightMap', textureMaps ) );
|
|
|
- folder.add( data, 'alphaMap', textureMapKeys ).onChange( updateTexture( material, 'alphaMap', textureMaps ) );
|
|
|
+ folder.add( data, 'map', diffuseMapKeys ).onChange( updateTexture( material, 'map', diffuseMaps ) );
|
|
|
+ folder.add( data, 'roughnessMap', roughnessMapKeys ).onChange( updateTexture( material, 'roughnessMap', roughnessMaps ) );
|
|
|
+ folder.add( data, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
|
|
|
- // TODO roughnessMap and metalnessMap
|
|
|
+ // TODO metalnessMap
|
|
|
|
|
|
}
|
|
|
|
|
@@ -487,6 +546,16 @@ function chooseFromHash( gui, mesh, geometry ) {
|
|
|
|
|
|
break;
|
|
|
|
|
|
+ case 'MeshMatcapMaterial' :
|
|
|
+
|
|
|
+ material = new THREE.MeshMatcapMaterial( { matcap: matcaps.porcelainWhite } );
|
|
|
+ guiMaterial( gui, mesh, material, geometry );
|
|
|
+ guiMeshMatcapMaterial( gui, mesh, material, geometry );
|
|
|
+
|
|
|
+ return material;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
case 'MeshPhongMaterial' :
|
|
|
|
|
|
material = new THREE.MeshPhongMaterial( { color: 0x2194CE } );
|