Skip to content

Commit

Permalink
Merge pull request #2543 from ousttrue/fix/add_cloth_sample
Browse files Browse the repository at this point in the history
[sample] package.json, URP など
  • Loading branch information
ousttrue authored Dec 24, 2024
2 parents c0c729f + c1f5356 commit 72c6ad3
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 796 deletions.
392 changes: 7 additions & 385 deletions Assets/VRM10/Samples~/ClothSample/ClothViewer/ClothViewer.unity

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions Assets/VRM10/Samples~/ClothSample/ClothViewer/ClothViewerUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,6 @@ void OnReset()
// }
// }

static IMaterialDescriptorGenerator GetVrmMaterialDescriptorGenerator(bool useUrp)
{
if (useUrp)
{
return new UrpVrm10MaterialDescriptorGenerator();
}
else
{
return new BuiltInVrm10MaterialDescriptorGenerator();
}
}

void OnInit(Vrm10Instance vrm)
{
var animator = vrm.GetComponent<Animator>();
Expand Down Expand Up @@ -445,7 +433,6 @@ async void LoadModel(string path)
awaitCaller: m_useAsync.isOn
? new RuntimeOnlyAwaitCaller()
: new ImmediateCaller(),
materialGenerator: GetVrmMaterialDescriptorGenerator(true),
vrmMetaInformationCallback: m_texts.UpdateMeta,
springboneRuntime: m_useJob.isOn
? new UniVRM10.ClothWarp.Jobs.ClothWarpJobRuntime(OnInit)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using UnityEngine;

namespace UniVRM10.Cloth.Viewer
{
/// <summary>
/// Built-in RP と URP の差異を楽に吸収してプリミティブを表示するためのクラス
/// </summary>
public class ClothVisualPrimitive : MonoBehaviour
{
[SerializeField] private PrimitiveType _primitiveType;

public PrimitiveType PrimitiveType
{
get => _primitiveType;
set => _primitiveType = value;
}

private void Start()
{
var visual = GameObject.CreatePrimitive(_primitiveType);
visual.transform.SetParent(transform);
visual.transform.localPosition = Vector3.zero;
visual.transform.localRotation = Quaternion.identity;
visual.transform.localScale = Vector3.one;
}

void OnDrawGizmos()
{
if (!Application.isPlaying)
{
Gizmos.matrix = transform.localToWorldMatrix;
switch (_primitiveType)
{
case PrimitiveType.Sphere:
Gizmos.DrawSphere(Vector3.zero, 1.0f);
break;

case PrimitiveType.Plane:
Gizmos.DrawWireCube(Vector3.zero, new Vector3(10, 0.001f, 10));
break;

default:
// TODO
break;
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 72c6ad3

Please sign in to comment.