Files
workinf_Blender_Wasm/web/protocol/uv-custom-region.ts
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
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>
2026-11-10 11:18:01 +08:00

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;
}