mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-30 14:53:09 -05:00
TextureImportName の使っていないところを削除
This commit is contained in:
@@ -84,21 +84,6 @@ namespace UniGLTF
|
||||
return new TextureImportParam(name, ".png", null, offset, scale, sampler, TextureImportTypes.StandardMap, metallicFactor, roughnessFactor, getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default);
|
||||
}
|
||||
|
||||
public static TextureImportName CreateNameExt(glTF gltf, int textureIndex, TextureImportTypes textureType)
|
||||
{
|
||||
if (textureIndex < 0 || textureIndex >= gltf.textures.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
var gltfTexture = gltf.textures[textureIndex];
|
||||
if (gltfTexture.source < 0 || gltfTexture.source >= gltf.images.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
var gltfImage = gltf.images[gltfTexture.source];
|
||||
return new TextureImportName(textureType, gltfTexture.name, gltfImage.GetExt(), gltfImage.uri);
|
||||
}
|
||||
|
||||
public static SamplerParam CreateSampler(glTF gltf, int index)
|
||||
{
|
||||
var gltfTexture = gltf.textures[index];
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace VRMShaders
|
||||
{
|
||||
public struct TextureImportName
|
||||
public static class TextureImportName
|
||||
{
|
||||
public readonly string GltfName;
|
||||
public readonly string ConvertedName;
|
||||
|
||||
public readonly string Ext;
|
||||
public readonly string Uri;
|
||||
public readonly string ExtractKey;
|
||||
|
||||
public static string GetExtractKey(TextureImportTypes type, string gltfName, string convertedName, string uri)
|
||||
{
|
||||
if (type == TextureImportTypes.StandardMap)
|
||||
@@ -20,7 +14,7 @@ namespace VRMShaders
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(uri) && !uri.StartsWith("data:"))
|
||||
if (!string.IsNullOrEmpty(uri) && !uri.StartsWith("data:", StringComparison.Ordinal))
|
||||
{
|
||||
// external image
|
||||
return Path.GetFileNameWithoutExtension(uri);
|
||||
@@ -33,30 +27,9 @@ namespace VRMShaders
|
||||
}
|
||||
}
|
||||
|
||||
public TextureImportName(TextureImportTypes textureType, string gltfName, string ext, string uri)
|
||||
{
|
||||
GltfName = gltfName;
|
||||
ConvertedName = TextureImportName.Convert(gltfName, textureType);
|
||||
Ext = ext;
|
||||
Uri = uri;
|
||||
ExtractKey = GetExtractKey(textureType, gltfName, ConvertedName, uri);
|
||||
}
|
||||
|
||||
public string GltfFileName => $"{GltfName}{Ext}";
|
||||
|
||||
public string ConvertedFileName => $"{ConvertedName}.png";
|
||||
|
||||
public const string NORMAL_SUFFIX = ".normal";
|
||||
public const string STANDARD_SUFFIX = ".standard";
|
||||
public static string Convert(string name, TextureImportTypes textureType)
|
||||
{
|
||||
switch (textureType)
|
||||
{
|
||||
case TextureImportTypes.StandardMap: return $"{name}{STANDARD_SUFFIX}";
|
||||
case TextureImportTypes.NormalMap: return $"{name}{NORMAL_SUFFIX}";
|
||||
default: return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static string RemoveSuffix(string src)
|
||||
{
|
||||
if (src.EndsWith(NORMAL_SUFFIX))
|
||||
|
||||
Reference in New Issue
Block a user