@shapediver/viewer.data-engine.material-engine
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -36,3 +36,11 @@ import { ITreeNode } from '@shapediver/viewer.shared.node-tree'; | ||
private getClassAndSpecificId; | ||
/** | ||
* Multiply two colors | ||
* | ||
* @param color1 | ||
* @param color2 | ||
* @returns | ||
*/ | ||
private multiplyColors; | ||
} | ||
//# sourceMappingURL=MaterialEngine.d.ts.map |
@@ -136,6 +136,7 @@ "use strict"; | ||
if (data.color) { | ||
presetData.color = data.color; | ||
presetData.color = this.multiplyColors(data.color, presetData.color); | ||
} | ||
else if (data.diffuse) { | ||
presetData.color = data.diffuse; | ||
// multiply color with diffuse | ||
presetData.color = this.multiplyColors(data.diffuse, presetData.color); | ||
} | ||
@@ -167,3 +168,3 @@ // emission is ignored | ||
if (data.color) | ||
presetData.color = data.color; | ||
presetData.color = this.multiplyColors(data.color, presetData.color); | ||
presetData.side = data.side; | ||
@@ -207,3 +208,3 @@ if (data.metalness || data.metalness === 0) | ||
if (data.color) | ||
presetData.color = data.color; | ||
presetData.color = this.multiplyColors(data.color, presetData.color); | ||
presetData.side = data.side; | ||
@@ -420,4 +421,21 @@ if (data.metalness || data.metalness === 0) | ||
} | ||
/** | ||
* Multiply two colors | ||
* | ||
* @param color1 | ||
* @param color2 | ||
* @returns | ||
*/ | ||
multiplyColors(color1, color2) { | ||
if (!color2) | ||
return color1; | ||
return [ | ||
Math.min(255, (color1[0] * color2[0]) / 255), | ||
Math.min(255, (color1[1] * color2[1]) / 255), | ||
Math.min(255, (color1[2] * color2[2]) / 255), | ||
Math.min(255, ((color1[3] !== undefined ? color1[3] : 255) * (color2[3] !== undefined ? color2[3] : 255)) / 255) | ||
]; | ||
} | ||
} | ||
exports.MaterialEngine = MaterialEngine; | ||
//# sourceMappingURL=MaterialEngine.js.map |
{ | ||
"name": "@shapediver/viewer.data-engine.material-engine", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "", | ||
@@ -43,10 +43,10 @@ "keywords": [], | ||
"@shapediver/sdk.geometry-api-sdk-v2": "1.8.2", | ||
"@shapediver/viewer.data-engine.shared-types": "3.0.0", | ||
"@shapediver/viewer.shared.node-tree": "3.0.0", | ||
"@shapediver/viewer.shared.services": "3.0.0", | ||
"@shapediver/viewer.shared.types": "3.0.0", | ||
"@shapediver/viewer.data-engine.shared-types": "3.0.1", | ||
"@shapediver/viewer.shared.node-tree": "3.0.1", | ||
"@shapediver/viewer.shared.services": "3.0.1", | ||
"@shapediver/viewer.shared.types": "3.0.1", | ||
"axios": "^1.2.6", | ||
"gl-matrix": "3.3.0" | ||
}, | ||
"gitHead": "b6b0010bf5d5652aa338df8016405d97f33fcabb" | ||
"gitHead": "cae477cab82d2cddddec9cbea6fec7bc2392552b" | ||
} |
@@ -144,5 +144,6 @@ /* eslint-disable no-prototype-builtins */ | ||
if (data.color) { | ||
presetData.color = data.color; | ||
presetData.color = this.multiplyColors(data.color, presetData.color); | ||
} else if (data.diffuse) { | ||
presetData.color = data.diffuse; | ||
// multiply color with diffuse | ||
presetData.color = this.multiplyColors(data.diffuse, presetData.color); | ||
} | ||
@@ -184,3 +185,3 @@ | ||
if (data.color) | ||
presetData.color = data.color; | ||
presetData.color = this.multiplyColors(data.color, presetData.color); | ||
@@ -238,3 +239,3 @@ presetData.side = data.side; | ||
if (data.color) | ||
presetData.color = data.color; | ||
presetData.color = this.multiplyColors(data.color, presetData.color); | ||
@@ -514,3 +515,20 @@ presetData.side = data.side; | ||
/** | ||
* Multiply two colors | ||
* | ||
* @param color1 | ||
* @param color2 | ||
* @returns | ||
*/ | ||
private multiplyColors(color1: number[], color2?: number[]): number[] { | ||
if (!color2) return color1; | ||
return [ | ||
Math.min(255, (color1[0] * color2[0]) / 255), | ||
Math.min(255, (color1[1] * color2[1]) / 255), | ||
Math.min(255, (color1[2] * color2[2]) / 255), | ||
Math.min(255, ((color1[3] !== undefined ? color1[3] : 255) * (color2[3] !== undefined ? color2[3] : 255)) / 255) | ||
]; | ||
} | ||
// #endregion Private Methods (3) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
89901
1290
+ Added@shapediver/viewer.data-engine.shared-types@3.0.1(transitive)
+ Added@shapediver/viewer.settings@1.0.2(transitive)
+ Added@shapediver/viewer.shared.build-data@3.0.1(transitive)
+ Added@shapediver/viewer.shared.math@3.0.1(transitive)
+ Added@shapediver/viewer.shared.node-tree@3.0.1(transitive)
+ Added@shapediver/viewer.shared.services@3.0.1(transitive)
+ Added@shapediver/viewer.shared.types@3.0.1(transitive)
- Removed@shapediver/viewer.data-engine.shared-types@3.0.0(transitive)
- Removed@shapediver/viewer.settings@1.0.1(transitive)
- Removed@shapediver/viewer.shared.build-data@3.0.0(transitive)
- Removed@shapediver/viewer.shared.math@3.0.0(transitive)
- Removed@shapediver/viewer.shared.node-tree@3.0.0(transitive)
- Removed@shapediver/viewer.shared.services@3.0.0(transitive)
- Removed@shapediver/viewer.shared.types@3.0.0(transitive)