private static async UniTask <Plain> CreateFloor(WorldLayer layer) { var timing = layer.GetValidScreen().TimingPoints.Update; var plain = new Plain(); plain.Scale = new Vector3(40f); plain.Shader = new PhongShader(); var config = new TextureConfig(TextureExpansionMode.NearestNeighbor, TextureShrinkMode.NearestNeighbor, TextureMipmapMode.None, TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge); var texture = await Resources.Sandbox["floor.png"].LoadTextureAsync(config, timing); plain.AddComponent(texture); plain.Rotation = Quaternion.FromAxisAngle(Vector3.UnitX, -90.ToRadian()); plain.Updated += _ => { var k = plain.GetValidScreen().Keyboard; if (k.IsPress(Elffy.InputSystem.Keys.Down)) { plain.Position.Y -= 0.5f; } else if (k.IsPress(Elffy.InputSystem.Keys.Up)) { plain.Position.Y += 0.5f; } }; return(await plain.Activate(layer)); }
private static async UniTask <Cube> CreateBox(WorldLayer layer) { var timing = layer.GetValidScreen().TimingPoints.Update; var cube = new Cube(); cube.Position = new(-3, 0.5f, 0); cube.Shader = new PhongShader(); cube.AddComponent(await Resources.Sandbox["box.png"].LoadTextureAsync(timing)); await cube.Activate(layer); cube.StartCoroutine(static async(coroutine, cube) =>