Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer, web workflow engine and protocol, tooling, docs and task records. Large generated evidence, user-testing archives, build snapshots and imported test assets remain untracked. Co-Authored-By: Claude Code <noreply@anthropic.com>
9 lines
787 B
TypeScript
9 lines
787 B
TypeScript
export type NativeUVBounds = [number,number,number,number]; // min U, min V, max U, max V
|
|
export interface NativeUVCustomRegion { enabled:boolean; bounds:NativeUVBounds }
|
|
export function parseNativeUVBounds(value:unknown, requireArea=true):NativeUVBounds {
|
|
if(!Array.isArray(value)||value.length!==4||value.some(n=>typeof n!=='number'||!Number.isFinite(n)||!Number.isFinite(Math.fround(n))))throw new Error('UV 区域需要四个有限坐标');
|
|
const bounds=value.map(Math.fround) as NativeUVBounds;
|
|
if(requireArea&&(!(bounds[2]>bounds[0])||!(bounds[3]>bounds[1])||!Number.isFinite(Math.fround(bounds[2]-bounds[0]))||!Number.isFinite(Math.fround(bounds[3]-bounds[1]))))throw new Error('UV 区域的最大坐标必须大于最小坐标,且范围不能溢出');
|
|
return bounds;
|
|
}
|