You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

THREE.FBXLoader加载3D模型不显示且报错:需引入Inflate.min.js外部库的问题求助

Fixing "THREE.FBXLoader: External library Inflate.min.js required" Error

Got it, this error pops up because FBXLoader relies on the Inflate library (part of zlib.js) to decompress compressed FBX files—Three.js doesn’t bundle this dependency by default. Here’s how to resolve it step by step:

1. For vanilla HTML projects (no build tools)

  • First, grab the Inflate.min.js file from the zlib.js project.
  • Add it to your project directory, then include it in your HTML after Three.js but before FBXLoader using a script tag:
    <script src="./path/to/three.min.js"></script>
    <script src="./path/to/Inflate.min.js"></script>
    <script src="./path/to/FBXLoader.js"></script>
    
    The order matters here—this ensures the global Inflate object is available when FBXLoader loads.

2. For npm/yarn-managed projects (Webpack, Vite, etc.)

  • Install the zlibjs package first:
    npm install zlibjs
    # Or use yarn
    yarn add zlibjs
    
  • Then import and expose Inflate globally in your JavaScript/TypeScript file before using FBXLoader:
    import * as THREE from 'three';
    import { Inflate } from 'zlibjs';
    import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
    
    // Make Inflate accessible globally for FBXLoader
    window.Inflate = Inflate;
    
    Some newer setups might let you pass Inflate directly to the loader, but exposing it globally is the most reliable method across Three.js versions.

3. Verify the fix

After setting this up, restart your project and check the browser console— the "Inflate.min.js required" error should be gone. Try loading your FBX model again; it should render as expected if there are no other issues.

Quick notes

  • Always use compatible versions: Stick to the latest stable releases of both Three.js and zlibjs to avoid compatibility gaps.
  • If using a bundler like Vite, double-check that zlibjs isn’t being stripped by tree-shaking (you can mark it as a dependency that needs to be included if needed).

内容的提问来源于stack exchange,提问作者Rohit Syan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 01:42:44