mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2024-11-23 08:34:14 -05:00
Add new optional command line parameter --doubleSidedMaterial to force materials to be rendered on both sides
This commit is contained in:
parent
dc2500a65c
commit
fba3cdf4e9
@ -114,6 +114,7 @@ As a convenience the PBR textures may be supplied directly to the command line.
|
||||
| `--input-up-axis` | Up axis of the obj. | No |
|
||||
| `--output-up-axis` | Up axis of the converted glTF. | No |
|
||||
| `--triangle-winding-order-sanitization` | Apply triangle winding order sanitization. | No |
|
||||
| `--doubleSidedMaterial` | Allow the material properties to be double-sided | No, default `false` |
|
||||
|
||||
## Build Instructions
|
||||
|
||||
|
@ -160,6 +160,11 @@ const argv = yargs
|
||||
type: "boolean",
|
||||
default: defaults.triangleWindingOrderSanitization,
|
||||
},
|
||||
doubleSidedMaterial: {
|
||||
describe: "Allow the material properties to be double-sided",
|
||||
type: "boolean",
|
||||
default: defaults.doubleSidedMaterial,
|
||||
},
|
||||
})
|
||||
.parse(args);
|
||||
|
||||
@ -216,6 +221,7 @@ const options = {
|
||||
inputUpAxis: argv.inputUpAxis,
|
||||
outputUpAxis: argv.outputUpAxis,
|
||||
triangleWindingOrderSanitization: argv.triangleWindingOrderSanitization,
|
||||
doubleSidedMaterial: argv.doubleSidedMaterial,
|
||||
};
|
||||
|
||||
console.time("Total");
|
||||
|
@ -846,8 +846,13 @@ function createSpecularGlossinessMaterial(material, options) {
|
||||
} else {
|
||||
const alpha = material.alpha;
|
||||
diffuseFactor[3] = alpha;
|
||||
|
||||
if (options.doubleSidedMaterial) {
|
||||
transparent = true;
|
||||
} else {
|
||||
transparent = alpha < 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (defined(diffuseTexture)) {
|
||||
transparent = transparent || diffuseTexture.transparent;
|
||||
@ -927,8 +932,13 @@ function createMetallicRoughnessMaterial(material, options) {
|
||||
} else {
|
||||
const alpha = material.alpha;
|
||||
baseColorFactor[3] = alpha;
|
||||
|
||||
if (options.doubleSidedMaterial) {
|
||||
transparent = true;
|
||||
} else {
|
||||
transparent = alpha < 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (defined(baseColorTexture)) {
|
||||
transparent = transparent || baseColorTexture.transparent;
|
||||
|
@ -40,6 +40,7 @@ module.exports = obj2gltf;
|
||||
* @param {Logger} [options.logger] A callback function for handling logged messages. Defaults to console.log.
|
||||
* @param {Writer} [options.writer] A callback function that writes files that are saved as separate resources.
|
||||
* @param {String} [options.outputDirectory] Output directory for writing separate resources when options.writer is not defined.
|
||||
* @param {Boolean} [options.doubleSidedMaterial=false] Allows materials to be double sided.
|
||||
* @return {Promise} A promise that resolves to the glTF JSON or glb buffer.
|
||||
*/
|
||||
function obj2gltf(objPath, options) {
|
||||
@ -54,6 +55,10 @@ function obj2gltf(objPath, options) {
|
||||
options.checkTransparency,
|
||||
defaults.checkTransparency
|
||||
);
|
||||
options.doubleSidedMaterial = defaultValue(
|
||||
options.doubleSidedMaterial,
|
||||
defaults.doubleSidedMaterial
|
||||
);
|
||||
options.secure = defaultValue(options.secure, defaults.secure);
|
||||
options.packOcclusion = defaultValue(
|
||||
options.packOcclusion,
|
||||
@ -179,6 +184,12 @@ obj2gltf.defaults = {
|
||||
* @default false
|
||||
*/
|
||||
checkTransparency: false,
|
||||
/**
|
||||
* Gets and sets whether a material will be doubleSided or not
|
||||
* @type Boolean
|
||||
* @default false
|
||||
*/
|
||||
doubleSidedMaterial: false,
|
||||
/**
|
||||
* Gets or sets whether the source model can reference paths outside of its directory.
|
||||
* @type Boolean
|
||||
|
Loading…
Reference in New Issue
Block a user