internal static async Task AddSvrfModel(GameObject gameObject, MediaModel model, SvrfModelOptions options) { var gltfComponent = gameObject.AddComponent <GLTFComponent>(); // Do not load the model automatically: let us call .Load() method manually and await it. SetGltfComponentField(gltfComponent, "loadOnStart", false); gltfComponent.GLTFUri = model.GetMainGltfFile(); SetGltfComponentField(gltfComponent, "shaderOverride", options.ShaderOverride); await gltfComponent.Load(); var gltfRoot = gameObject.transform.GetChild(0); var occluder = FindDescendant(gltfRoot, "Occluder"); // GLTF models are right-handed, but the Unity coordinates are left-handed, // so rotating the model around Y axis. gltfRoot.transform.Rotate(Vector3.up, 180); if (occluder == null) { return; } if (options.WithOccluder) { var meshRenderer = occluder.transform.Find("Primitive").GetComponent <SkinnedMeshRenderer>(); // If we need to handle occlusion, apply our custom shader to handle it. meshRenderer.sharedMaterials[0].shader = Shader.Find("Svrf/Occluder"); } else { // If we don't need to handle occlusion, hide the occluder. occluder.gameObject.SetActive(false); } }