import { Mesh } from "../src/Mesh"; import { Scene } from "../src/Scene"; import type { PBRMaterial } from "../src/materials/PBRMaterial"; import type { YawnCore } from "./core-mock"; export const triangle = { positions: [-1, -1, 0, 1, -1, 0, 0, 1, 0], normals: [0, 0, 1, 0, 0, 1, 0, 0, 1], tangents: [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1], uvs: [0, 0, 1, 0, 0.5, 1], uvs2: [0.1, 0.1, 0.9, 0.1, 0.5, 0.9], colors: [1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1], indices: [0, 1, 2], }; export async function createScene() { const scene = new Scene({} as HTMLCanvasElement); await scene.ready; return scene; } export function testCore(scene: Scene) { return scene.core as unknown as YawnCore; } export function latestGraph(scene: Scene): any { return testCore(scene).graphs.at(-1); } export function renderPipeline(graph: any, id: string) { return graph.pipelines.render.find((pipeline: any) => pipeline.id === id); } export function pbrPipelines(graph: any) { return graph.pipelines.render.filter((pipeline: any) => pipeline.id.startsWith("forward-pbr-"), ); } export function forwardPasses(graph: any) { return graph.passes.filter( (pass: any) => pass.type === "render" && pass.pipeline.startsWith("forward-"), ); } export function detailedMesh( scene: Scene, material: PBRMaterial, vertexData: Record> = triangle, ) { return new Mesh(scene, { material, vertexData }); }