提交 9f6d3a9c 编写于 作者: A alteredq

Editor: added more checks for prevention of setting textures to UV-less objects.

Warnings are way too verbose for the moment.
上级 edc4f719
......@@ -218,6 +218,7 @@ Sidebar.Properties.Material = function ( signals ) {
//
var selected = null;
var selectedHasUvs = false;
var canvas = document.createElement( 'canvas' );
var context = canvas.getContext( '2d' );
......@@ -240,8 +241,16 @@ Sidebar.Properties.Material = function ( signals ) {
material = new materials[ materialClass.getValue() ]();
selected.material = material;
if ( selectedHasUvs ) {
material.map = dummyTexture;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
if ( material.color !== undefined ) {
......@@ -276,48 +285,96 @@ Sidebar.Properties.Material = function ( signals ) {
if ( material.map !== undefined ) {
if ( selectedHasUvs ) {
material.map = materialMapEnabled.getValue() === true ? materialMap.getValue() : dummyTexture;
material.needsUpdate = true;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
/*
if ( material.lightMap !== undefined ) {
if ( selectedHasUvs ) {
material.lightMap = materialLightMapEnabled.getValue() === true ? materialLightMap.getValue() : null;
material.needsUpdate = true;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
*/
if ( material.bumpMap !== undefined ) {
if ( selectedHasUvs ) {
material.bumpMap = materialBumpMapEnabled.getValue() === true ? materialBumpMap.getValue() : null;
material.bumpScale = materialBumpScale.getValue();
material.needsUpdate = true;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
if ( material.normalMap !== undefined ) {
if ( selectedHasUvs ) {
material.normalMap = materialNormalMapEnabled.getValue() === true ? materialNormalMap.getValue() : null;
material.needsUpdate = true;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
if ( material.specularMap !== undefined ) {
if ( selectedHasUvs ) {
material.specularMap = materialSpecularMapEnabled.getValue() === true ? materialSpecularMap.getValue() : null;
material.needsUpdate = true;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
if ( material.envMap !== undefined ) {
if ( selectedHasUvs ) {
material.envMap = materialEnvMapEnabled.getValue() === true ? materialEnvMap.getValue() : null;
material.reflectivity = materialReflectivity.getValue();
material.needsUpdate = true;
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
if ( material.opacity !== undefined ) {
......@@ -397,6 +454,7 @@ Sidebar.Properties.Material = function ( signals ) {
if ( object && object.material ) {
selected = object;
selectedHasUvs = object.geometry.faceVertexUvs[ 0 ].length > 0;
container.setDisplay( '' );
......@@ -437,6 +495,8 @@ Sidebar.Properties.Material = function ( signals ) {
if ( material.map !== undefined ) {
if ( selectedHasUvs ) {
if ( material.map !== null ) {
materialMapEnabled.setValue( true );
......@@ -449,6 +509,12 @@ Sidebar.Properties.Material = function ( signals ) {
}
} else {
console.warn( "Can't set texture, model doesn't have texture coordinates" );
}
}
/*
......@@ -560,6 +626,7 @@ Sidebar.Properties.Material = function ( signals ) {
} else {
selected = null;
selectedHasUvs = false;
container.setDisplay( 'none' );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册