mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-08 03:48:19 -05:00
@@ -33,6 +33,9 @@ namespace UniGLTF
|
||||
public gltfMorphTarget ToGltf(glTF gltf, int bufferIndex, bool useNormal)
|
||||
{
|
||||
var positionAccessorIndex = gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, m_positions.ToArray(), glBufferTarget.ARRAY_BUFFER);
|
||||
gltf.accessors[positionAccessorIndex].min = m_positions.Aggregate(m_positions[0], (a, b) => new Vector3(Mathf.Min(a.x, b.x), Math.Min(a.y, b.y), Mathf.Min(a.z, b.z))).ToArray();
|
||||
gltf.accessors[positionAccessorIndex].max = m_positions.Aggregate(m_positions[0], (a, b) => new Vector3(Mathf.Max(a.x, b.x), Math.Max(a.y, b.y), Mathf.Max(a.z, b.z))).ToArray();
|
||||
|
||||
var normalAccessorIndex = -1;
|
||||
if (useNormal)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,24 @@ namespace UniGLTF
|
||||
public static class TextureSamplerUtil
|
||||
{
|
||||
#region Export
|
||||
public static glFilter ExportFilterMode(Texture texture)
|
||||
// MagFilter は 2種類だけ
|
||||
public static glFilter ExportMagFilter(Texture texture)
|
||||
{
|
||||
switch (texture.filterMode)
|
||||
{
|
||||
case FilterMode.Point:
|
||||
return glFilter.NEAREST;
|
||||
|
||||
case FilterMode.Bilinear:
|
||||
case FilterMode.Trilinear:
|
||||
return glFilter.LINEAR;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static glFilter ExportMinFilter(Texture texture)
|
||||
{
|
||||
switch (texture.filterMode)
|
||||
{
|
||||
@@ -68,13 +85,14 @@ namespace UniGLTF
|
||||
|
||||
public static glTFTextureSampler Export(Texture texture)
|
||||
{
|
||||
var filter = ExportFilterMode(texture);
|
||||
var magFilter = ExportMagFilter(texture);
|
||||
var minFilter = ExportMinFilter(texture);
|
||||
var wrapS = ExportWrapMode(GetWrapS(texture));
|
||||
var wrapT = ExportWrapMode(GetWrapT(texture));
|
||||
return new glTFTextureSampler
|
||||
{
|
||||
magFilter = filter,
|
||||
minFilter = filter,
|
||||
magFilter = magFilter,
|
||||
minFilter = minFilter,
|
||||
wrapS = wrapS,
|
||||
wrapT = wrapT,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user