提交 7e5b0024 编写于 作者: D Don McCurdy

GLTFExporter: Support KHR_materials_unlit.

上级 578273ab
...@@ -100,6 +100,7 @@ THREE.GLTFExporter.prototype = { ...@@ -100,6 +100,7 @@ THREE.GLTFExporter.prototype = {
var pending = []; var pending = [];
var nodeMap = {}; var nodeMap = {};
var skins = []; var skins = [];
var extensionsUsed = {};
var cachedData = { var cachedData = {
materials: new Map(), materials: new Map(),
...@@ -647,13 +648,6 @@ THREE.GLTFExporter.prototype = { ...@@ -647,13 +648,6 @@ THREE.GLTFExporter.prototype = {
} }
if ( ! ( material instanceof THREE.MeshStandardMaterial ) ) {
console.warn( 'GLTFExporter: Currently just THREE.MeshStandardMaterial is supported. Material conversion may lose information.' );
}
// @QUESTION Should we avoid including any attribute that has the default value? // @QUESTION Should we avoid including any attribute that has the default value?
var gltfMaterial = { var gltfMaterial = {
...@@ -661,6 +655,18 @@ THREE.GLTFExporter.prototype = { ...@@ -661,6 +655,18 @@ THREE.GLTFExporter.prototype = {
}; };
if ( material instanceof THREE.MeshBasicMaterial ) {
gltfMaterial.extensions = { KHR_materials_unlit: {} };
extensionsUsed[ 'KHR_materials_unlit' ] = true;
} else if ( ! ( material instanceof THREE.MeshStandardMaterial ) ) {
console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' );
}
// pbrMetallicRoughness.baseColorFactor // pbrMetallicRoughness.baseColorFactor
var color = material.color.toArray().concat( [ material.opacity ] ); var color = material.color.toArray().concat( [ material.opacity ] );
...@@ -675,6 +681,11 @@ THREE.GLTFExporter.prototype = { ...@@ -675,6 +681,11 @@ THREE.GLTFExporter.prototype = {
gltfMaterial.pbrMetallicRoughness.metallicFactor = material.metalness; gltfMaterial.pbrMetallicRoughness.metallicFactor = material.metalness;
gltfMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness; gltfMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness;
} else if ( material instanceof THREE.MeshBasicMaterial ) {
gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.0;
gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.9;
} else { } else {
gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.5; gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.5;
...@@ -1505,6 +1516,10 @@ THREE.GLTFExporter.prototype = { ...@@ -1505,6 +1516,10 @@ THREE.GLTFExporter.prototype = {
// Merge buffers. // Merge buffers.
var blob = new Blob( buffers, { type: 'application/octet-stream' } ); var blob = new Blob( buffers, { type: 'application/octet-stream' } );
// Declare extensions.
var extensionsUsedList = Object.keys( extensionsUsed );
if ( extensionsUsedList.length > 0 ) outputJSON.extensionsUsed = extensionsUsedList;
if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) { if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) {
// Update bytelength of the single buffer. // Update bytelength of the single buffer.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册