修复一些列bug。

This commit is contained in:
tengge1 2019-09-23 20:40:47 +08:00
parent 11e181f1e8
commit 439cdc8a8b
4 changed files with 30 additions and 6 deletions

View File

@ -8720,8 +8720,12 @@
if ( this.normalMap && this.normalMap.isTexture ) {
data.normalMap = this.normalMap.toJSON( meta ).uuid;
data.normalMapType = this.normalMapType;
data.normalScale = this.normalScale.toArray();
if(this.normalMapType) {
data.normalMapType = this.normalMapType;
}
if(this.normalScale) {
data.normalScale = this.normalScale.toArray();
}
}

View File

@ -224,7 +224,7 @@ class MaterialComponent extends React.Component {
<NumberProperty label={_t('Roughness')} name={'roughness'} value={roughness} show={showRoughness} onChange={this.handleChange}></NumberProperty>
<NumberProperty label={_t('MetalNess')} name={'metalness'} value={metalness} show={showMetalness} onChange={this.handleChange}></NumberProperty>
<ColorProperty label={_t('Emissive')} name={'emissive'} value={emissive} show={showEmissive} onChange={this.handleChange}></ColorProperty>
<ColorProperty label={_t('Specular')} name={'specular'} value={specular} show={showSpecular} onChange={this.handleChange}></ColorProperty>
<NumberProperty label={_t('Specular')} name={'specular'} value={specular} show={showSpecular} onChange={this.handleChange}></NumberProperty>
<NumberProperty label={_t('Shininess')} name={'shininess'} value={shininess} show={showShininess} onChange={this.handleChange}></NumberProperty>
<NumberProperty label={_t('ClearCoat')} name={'clearCoat'} value={clearCoat} show={showClearCoat} onChange={this.handleChange}></NumberProperty>
<NumberProperty label={_t('ClearCoatRoughness')} name={'clearCoatRoughness'} value={clearCoatRoughness} show={showClearCoatRoughness} onChange={this.handleChange}></NumberProperty>
@ -319,7 +319,7 @@ class MaterialComponent extends React.Component {
if (material.specular !== undefined) {
state.showSpecular = true;
state.specular = `#${material.specular.getHexString()}`;
state.specular = `#${material.specular}`;
} else {
state.showSpecular = false;
}
@ -547,8 +547,8 @@ class MaterialComponent extends React.Component {
editor.execute(new SetMaterialColorCommand(object, 'emissive', emissive));
}
if (material.specular !== undefined && `#${material.specular.getHexString()}` !== specular) {
editor.execute(new SetMaterialColorCommand(object, 'specular', specular));
if (material.specular !== undefined && `#${material.specular}` !== specular) {
editor.execute(new SetMaterialValueCommand(object, 'specular', specular));
}
if (material.shininess !== undefined && Math.abs(material.shininess - shininess) >= 0.01) {

View File

@ -44,6 +44,14 @@ MaterialSerializer.prototype.toJSON = function (obj) {
json.emissive = obj.emissive;
json.emissiveIntensity = obj.emissiveIntensity;
json.emissiveMap = obj.emissiveMap == null ? null : (new TexturesSerializer()).toJSON(obj.emissiveMap);
if (obj.specular !== undefined) {
json.specular = obj.specular;
}
if (obj.specularMap !== undefined) {
json.specularMap = (new TexturesSerializer()).toJSON(obj.specularMap);
}
json.envMap = obj.envMap == null ? null : (new TexturesSerializer()).toJSON(obj.envMap);
json.envMapIntensity = obj.envMapIntensity;
json.flatShading = obj.flatShading;
@ -117,6 +125,14 @@ MaterialSerializer.prototype.fromJSON = function (json, parent, server) {
obj.emissive = json.emissive === undefined ? undefined : new THREE.Color(json.emissive);
obj.emissiveIntensity = json.emissiveIntensity;
obj.emissiveMap = json.emissiveMap == null ? null : (new TexturesSerializer()).fromJSON(json.emissiveMap, undefined, server);
if (json.specular !== undefined) {
obj.specular = json.specular;
}
if (json.specularMap !== undefined) {
obj.specularMap = (new TexturesSerializer()).toJSON(json.specularMap);
}
obj.envMap = json.envMap == null ? null : (new TexturesSerializer()).fromJSON(json.envMap, undefined, server);
obj.envMapIntensity = json.envMapIntensity;
obj.flatShading = json.flatShading;

View File

@ -36,6 +36,8 @@ ShaderMaterialSerializer.prototype.toJSON = function (obj) {
json.vertexShader = obj.vertexShader;
json.fragmentShader = obj.fragmentShader;
json.extensions = obj.extensions;
return json;
};
@ -64,6 +66,8 @@ ShaderMaterialSerializer.prototype.fromJSON = function (json, parent, server) {
obj.vertexShader = json.vertexShader;
obj.fragmentShader = json.fragmentShader;
obj.extensions = json.extensions;
return obj;
};