threejs-assets

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Asset Loading and Optimization

资产加载与优化

Use the project's installed versions and existing architecture. These instructions supplement the user's task; they do not authorize unrelated changes or external actions.
Inventory format, dimensions, units, animation clips, material features, texture sizes, provenance, and transfer size. Prefer a web-ready glTF/GLB pipeline when conversion is acceptable. Preserve source files and semantic names needed by application logic.
Configure GLTFLoader with the decoders the asset actually requires. Match decoder/transcoder binaries to the installed libraries, resolve their URLs through the build's asset conventions, and detect KTX2 support against the active renderer. Do not assume a compressed file needs only a single network request.
Represent loading, ready, failure, and retry explicitly. Unknown content length calls for indeterminate progress. On navigation or rapid selection, guard stale async completions with a generation token or supported cancellation; release late results that no longer have an owner. A manager's progress percentage is not necessarily download-byte percentage.
Budget decoded GPU texture memory as well as transfer bytes. Consider resizing, mesh simplification, Meshopt/Draco, and KTX2/Basis individually; compare decode time and visual quality before accepting a pipeline. Preserve required animation, skinning, morph targets, and metadata.
Cache immutable source assets and clone scene instances appropriately; skinned models need skeleton-aware cloning. Define cache eviction separately from component unmount. For user uploads, limit size/complexity, handle external URI policy and malformed files, and revoke object URLs after their consumers finish.
Verify missing decoder files, failed textures, rapid model switching, nested deployment paths, representative animation clips, and memory after repeated replacement.
使用项目已安装的版本和现有架构。这些说明是对用户任务的补充;它们不授权无关的更改或外部操作。
盘点格式、尺寸、单位、动画片段、材质特性、纹理大小、来源和传输大小。在允许转换时,优先采用 Web 就绪的 glTF/GLB 管线。保留应用逻辑所需的源文件和语义名称。
使用资产实际需要的解码器配置 GLTFLoader。将解码器/转码器二进制文件与已安装的库匹配,通过构建的资产约定解析其 URL,并针对当前渲染器检测 KTX2 支持。不要假设压缩文件只需要单次网络请求。
明确表示加载、就绪、失败和重试状态。未知的内容长度需要不确定进度。在导航或快速选择时,使用生成令牌或支持的取消机制来防范过期的异步完成;释放那些不再有所有者的延迟结果。管理器的进度百分比不一定是下载字节百分比。
预算解码后的 GPU 纹理内存以及传输字节。分别考虑调整大小、网格简化、Meshopt/Draco 和 KTX2/Basis;在接受管线之前比较解码时间和视觉质量。保留所需的动画、蒙皮、变形目标和元数据。
适当缓存不可变的源资产并克隆场景实例;蒙皮模型需要感知骨骼的克隆。将缓存逐出与组件卸载分开定义。对于用户上传的内容,限制大小/复杂度,处理外部 URI 策略和畸形文件,并在其使用者完成后撤销对象 URL。
验证缺失的解码器文件、失败的纹理、快速的模型切换、嵌套部署路径、代表性动画片段,以及重复替换后的内存情况。

API reference

API 参考

Consult the official documentation for exact signatures and revision-specific behavior. If documentation access is unavailable, inspect installed types/source and state any remaining uncertainty.
查阅官方文档以获取确切的签名和版本特定行为。如果无法访问文档,请检查已安装的类型/源码并说明任何剩余的不确定性。