|
@@ -87,6 +87,9 @@ function getObjectsKeys( obj ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var textureLoader = new THREE.TextureLoader();
|
|
|
|
+var cubeTextureLoader = new THREE.CubeTextureLoader();
|
|
|
|
+
|
|
var envMaps = ( function () {
|
|
var envMaps = ( function () {
|
|
|
|
|
|
var path = '../../examples/textures/cube/SwedishRoyalCastle/';
|
|
var path = '../../examples/textures/cube/SwedishRoyalCastle/';
|
|
@@ -97,10 +100,10 @@ var envMaps = ( function () {
|
|
path + 'pz' + format, path + 'nz' + format
|
|
path + 'pz' + format, path + 'nz' + format
|
|
];
|
|
];
|
|
|
|
|
|
- var reflectionCube = new THREE.CubeTextureLoader().load( urls );
|
|
|
|
|
|
+ var reflectionCube = cubeTextureLoader.load( urls );
|
|
reflectionCube.format = THREE.RGBFormat;
|
|
reflectionCube.format = THREE.RGBFormat;
|
|
|
|
|
|
- var refractionCube = new THREE.CubeTextureLoader().load( urls );
|
|
|
|
|
|
+ var refractionCube = cubeTextureLoader.load( urls );
|
|
refractionCube.mapping = THREE.CubeRefractionMapping;
|
|
refractionCube.mapping = THREE.CubeRefractionMapping;
|
|
refractionCube.format = THREE.RGBFormat;
|
|
refractionCube.format = THREE.RGBFormat;
|
|
|
|
|
|
@@ -112,30 +115,47 @@ var envMaps = ( function () {
|
|
|
|
|
|
} )();
|
|
} )();
|
|
|
|
|
|
-var envMapKeys = getObjectsKeys( envMaps );
|
|
|
|
|
|
+var diffuseMaps = ( function () {
|
|
|
|
|
|
-var textureMaps = ( function () {
|
|
|
|
|
|
+ var bricks = textureLoader.load( '../../examples/textures/brick_diffuse.jpg' );
|
|
|
|
+ bricks.wrapS = THREE.RepeatWrapping;
|
|
|
|
+ bricks.wrapT = THREE.RepeatWrapping;
|
|
|
|
+ bricks.repeat.set( 9, 1 );
|
|
|
|
|
|
return {
|
|
return {
|
|
none: null,
|
|
none: null,
|
|
- grass: new THREE.TextureLoader().load( '../../examples/textures/terrain/grasslight-thin.jpg' )
|
|
|
|
|
|
+ bricks: bricks
|
|
};
|
|
};
|
|
|
|
|
|
} )();
|
|
} )();
|
|
|
|
|
|
-var textureMapKeys = getObjectsKeys( textureMaps );
|
|
|
|
-
|
|
|
|
var matcaps = ( function () {
|
|
var matcaps = ( function () {
|
|
|
|
|
|
return {
|
|
return {
|
|
none: null,
|
|
none: null,
|
|
- porcelainWhite: new THREE.TextureLoader().load( '../../examples/textures/matcaps/matcap-porcelain-white.jpg' )
|
|
|
|
|
|
+ porcelainWhite: textureLoader.load( '../../examples/textures/matcaps/matcap-porcelain-white.jpg' )
|
|
};
|
|
};
|
|
|
|
|
|
} )();
|
|
} )();
|
|
|
|
|
|
|
|
+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 matcapKeys = getObjectsKeys( matcaps );
|
|
var matcapKeys = getObjectsKeys( matcaps );
|
|
|
|
+var alphaMapKeys = getObjectsKeys( alphaMaps );
|
|
|
|
|
|
function generateVertexColors( geometry ) {
|
|
function generateVertexColors( geometry ) {
|
|
|
|
|
|
@@ -259,7 +279,7 @@ function guiMaterial( gui, mesh, material, geometry ) {
|
|
var folder = gui.addFolder( 'THREE.Material' );
|
|
var folder = gui.addFolder( 'THREE.Material' );
|
|
|
|
|
|
folder.add( material, 'transparent' );
|
|
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, 'blending', constants.blendingMode );
|
|
// folder.add( material, 'blendSrc', constants.destinationFactors );
|
|
// folder.add( material, 'blendSrc', constants.destinationFactors );
|
|
// folder.add( material, 'blendDst', constants.destinationFactors );
|
|
// folder.add( material, 'blendDst', constants.destinationFactors );
|
|
@@ -269,7 +289,7 @@ function guiMaterial( gui, mesh, material, geometry ) {
|
|
// folder.add( material, 'polygonOffset' );
|
|
// folder.add( material, 'polygonOffset' );
|
|
// folder.add( material, 'polygonOffsetFactor' );
|
|
// folder.add( material, 'polygonOffsetFactor' );
|
|
// folder.add( material, 'polygonOffsetUnits' );
|
|
// 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, 'visible' );
|
|
folder.add( material, 'side', constants.side ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'side', constants.side ).onChange( needsUpdate( material, geometry ) );
|
|
|
|
|
|
@@ -279,10 +299,9 @@ function guiMeshBasicMaterial( gui, mesh, material, geometry ) {
|
|
|
|
|
|
var data = {
|
|
var data = {
|
|
color: material.color.getHex(),
|
|
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' );
|
|
var folder = gui.addFolder( 'THREE.MeshBasicMaterial' );
|
|
@@ -294,9 +313,8 @@ function guiMeshBasicMaterial( gui, mesh, material, geometry ) {
|
|
folder.add( material, 'fog' );
|
|
folder.add( material, 'fog' );
|
|
|
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
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, 'combine', constants.combine );
|
|
folder.add( material, 'reflectivity', 0, 1 );
|
|
folder.add( material, 'reflectivity', 0, 1 );
|
|
folder.add( material, 'refractionRatio', 0, 1 );
|
|
folder.add( material, 'refractionRatio', 0, 1 );
|
|
@@ -344,10 +362,9 @@ function guiMeshLambertMaterial( gui, mesh, material, geometry ) {
|
|
var data = {
|
|
var data = {
|
|
color: material.color.getHex(),
|
|
color: material.color.getHex(),
|
|
emissive: material.emissive.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' );
|
|
var folder = gui.addFolder( 'THREE.MeshLambertMaterial' );
|
|
@@ -361,9 +378,8 @@ function guiMeshLambertMaterial( gui, mesh, material, geometry ) {
|
|
folder.add( material, 'fog' );
|
|
folder.add( material, 'fog' );
|
|
|
|
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
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, 'combine', constants.combine );
|
|
folder.add( material, 'reflectivity', 0, 1 );
|
|
folder.add( material, 'reflectivity', 0, 1 );
|
|
folder.add( material, 'refractionRatio', 0, 1 );
|
|
folder.add( material, 'refractionRatio', 0, 1 );
|
|
@@ -390,11 +406,9 @@ function guiMeshPhongMaterial( gui, mesh, material, geometry ) {
|
|
color: material.color.getHex(),
|
|
color: material.color.getHex(),
|
|
emissive: material.emissive.getHex(),
|
|
emissive: material.emissive.getHex(),
|
|
specular: material.specular.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' );
|
|
var folder = gui.addFolder( 'THREE.MeshPhongMaterial' );
|
|
@@ -410,10 +424,8 @@ function guiMeshPhongMaterial( gui, mesh, material, geometry ) {
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'fog' );
|
|
folder.add( material, 'fog' );
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
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 ) );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -422,11 +434,9 @@ function guiMeshStandardMaterial( gui, mesh, material, geometry ) {
|
|
var data = {
|
|
var data = {
|
|
color: material.color.getHex(),
|
|
color: material.color.getHex(),
|
|
emissive: material.emissive.getHex(),
|
|
emissive: material.emissive.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.MeshStandardMaterial' );
|
|
var folder = gui.addFolder( 'THREE.MeshStandardMaterial' );
|
|
@@ -442,9 +452,8 @@ function guiMeshStandardMaterial( gui, mesh, material, geometry ) {
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'fog' );
|
|
folder.add( material, 'fog' );
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
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, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
|
|
|
// TODO roughnessMap and metalnessMap
|
|
// TODO roughnessMap and metalnessMap
|
|
|
|
|
|
@@ -455,11 +464,9 @@ function guiMeshPhysicalMaterial( gui, mesh, material, geometry ) {
|
|
var data = {
|
|
var data = {
|
|
color: material.color.getHex(),
|
|
color: material.color.getHex(),
|
|
emissive: material.emissive.getHex(),
|
|
emissive: material.emissive.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.MeshPhysicalMaterial' );
|
|
var folder = gui.addFolder( 'THREE.MeshPhysicalMaterial' );
|
|
@@ -478,9 +485,8 @@ function guiMeshPhysicalMaterial( gui, mesh, material, geometry ) {
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'vertexColors', constants.colors ).onChange( needsUpdate( material, geometry ) );
|
|
folder.add( material, 'fog' );
|
|
folder.add( material, 'fog' );
|
|
folder.add( data, 'envMaps', envMapKeys ).onChange( updateTexture( material, 'envMap', envMaps ) );
|
|
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, 'alphaMap', alphaMapKeys ).onChange( updateTexture( material, 'alphaMap', alphaMaps ) );
|
|
|
|
|
|
// TODO roughnessMap and metalnessMap
|
|
// TODO roughnessMap and metalnessMap
|
|
|
|
|