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

GLTFExporter: Support KHR_materials_unlit.

上级 578273ab
......@@ -100,6 +100,7 @@ THREE.GLTFExporter.prototype = {
var pending = [];
var nodeMap = {};
var skins = [];
var extensionsUsed = {};
var cachedData = {
materials: new Map(),
......@@ -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?
var gltfMaterial = {
......@@ -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
var color = material.color.toArray().concat( [ material.opacity ] );
......@@ -675,6 +681,11 @@ THREE.GLTFExporter.prototype = {
gltfMaterial.pbrMetallicRoughness.metallicFactor = material.metalness;
gltfMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness;
} else if ( material instanceof THREE.MeshBasicMaterial ) {
gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.0;
gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.9;
} else {
gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.5;
......@@ -1505,6 +1516,10 @@ THREE.GLTFExporter.prototype = {
// Merge buffers.
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 ) {
// Update bytelength of the single buffer.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册