import { describe, it, expect } from 'vitest'; import '../test/webgpu-stub'; import { logic, reactive } from '@feng3d/reactivity'; import './CylinderGeometry'; import type { CylinderGeometry } from './CylinderGeometry'; import type { GeometryLogic } from '../geometry/Geometry'; import { runReactiveTests } from '../test/reactiveGeometryTest'; function makeLogic(): [GeometryLogic, Record] { const geo = { __type__: 'CylinderGeometry', topRadius: 2, bottomRadius: 2, height: 5, segmentsW: 8, segmentsH: 1, } as CylinderGeometry; const g = logic(geo) as GeometryLogic; return [g, reactive(geo) as unknown as Record]; } runReactiveTests('CylinderGeometry', makeLogic, 'height', 10, 'segmentsW', ['topRadius', 'bottomRadius', 'height', 'segmentsW', 'segmentsH', 'yUp']); /** 测试辅助:经 beforeRender 读取渲染数据(接口已不暴露 vertices/indices/draw getter) */ function readRenderData(lg: { beforeRender(ro: never): void }): { vertices: Record }>; indices: ArrayLike; draw: Record } { const ro = {} as never; lg.beforeRender(ro); return ro as unknown as { vertices: Record }>; indices: ArrayLike; draw: Record }; } describe('CylinderGeometry 基础验证', () => { it('segmentsW=8 有顶点', () => { const geo = { __type__: 'CylinderGeometry', topRadius: 2, bottomRadius: 2, height: 5, segmentsW: 8, segmentsH: 1, } as CylinderGeometry; const g = logic(geo) as GeometryLogic; expect(readRenderData(g).vertices['a_position'].data.length).toBeGreaterThan(0); }); });