summit/frontend/node_modules/three-stdlib/loaders/FBXLoader.cjs.map

1 line
157 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"FBXLoader.cjs","sources":["../../src/loaders/FBXLoader.js"],"sourcesContent":["import {\n AmbientLight,\n AnimationClip,\n Bone,\n BufferGeometry,\n ClampToEdgeWrapping,\n Color,\n DirectionalLight,\n EquirectangularReflectionMapping,\n Euler,\n FileLoader,\n Float32BufferAttribute,\n Group,\n Line,\n LineBasicMaterial,\n Loader,\n LoaderUtils,\n MathUtils,\n Matrix3,\n Matrix4,\n Mesh,\n MeshLambertMaterial,\n MeshPhongMaterial,\n NumberKeyframeTrack,\n Object3D,\n OrthographicCamera,\n PerspectiveCamera,\n PointLight,\n PropertyBinding,\n Quaternion,\n QuaternionKeyframeTrack,\n RepeatWrapping,\n Skeleton,\n SkinnedMesh,\n SpotLight,\n Texture,\n TextureLoader,\n Uint16BufferAttribute,\n Vector3,\n Vector4,\n VectorKeyframeTrack,\n} from 'three'\nimport { unzlibSync } from 'fflate'\nimport { NURBSCurve } from '../curves/NURBSCurve'\nimport { decodeText } from '../_polyfill/LoaderUtils'\nimport { UV1 } from '../_polyfill/uv1'\n\n/**\n * Loader loads FBX file and generates Group representing FBX scene.\n * Requires FBX file to be >= 7.0 and in ASCII or >= 6400 in Binary format\n * Versions lower than this may load but will probably have errors\n *\n * Needs Support:\n * Morph normals / blend shape normals\n *\n * FBX format references:\n * \thttps://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html (C++ SDK reference)\n *\n * Binary format specification:\n *\thttps://code.blender.org/2013/08/fbx-binary-file-format-specification/\n */\n\nlet fbxTree\nlet connections\nlet sceneGraph\n\nclass FBXLoader extends Loader {\n constructor(manager) {\n super(manager)\n }\n\n load(url, onLoad, onProgress, onError) {\n const scope = this\n\n const path = scope.path === '' ? LoaderUtils.extractUrlBase(url) : scope.path\n\n const loader = new FileLoader(this.manager)\n loader.setPath(scope.path)\n loader.setResponseType('arraybuffer')\n loader.setRequestHeader(scope.requestHeader)\n loader.setWithCredentials(scope.withCredentials)\n\n loader.load(\n url,\n function (buffer) {\n try {\n onLoad(scope.parse(buffer, path))\n } catch (e) {\n if (onError) {\n onError(e)\n } else {\n console.error(e)\n }\n\n scope.manager.itemError(url)\n }\n },\n onProgress,\n onError,\n )\n }\n\n parse(FBXBuffer, path) {\n if (isFbxFormatBinary(FBXBuffer)) {\n fbxTree = new BinaryParser().parse(FBXBuffer)\n } else {\n const FBXText = convertArrayBufferToString(FBXBuffer)\n\n if (!isFbxFormatASCII(FBXText)) {\n throw new Error('THREE.FBXLoader: Unknown format.')\n }\n\n if (getFbxVersion(FBXText) < 7000) {\n throw new Error('THREE.FBXLoader: FBX version not supported, FileVersion: ' + getFbxVersion(FBXText))\n }\n\n fbxTree = new TextParser().parse(FBXText)\n }\n\n // console.log( fbxTree );\n\n const textureLoader = new TextureLoader(this.manager)\n .setPath(this.resourcePath || path)\n .setCrossOrigin(this.crossOrigin)\n\n return new FBXTreeParser(textureLoader, this.manager).parse(fbxTree)\n }\n}\n\n// Parse the FBXTree object returned by the BinaryParser or TextParser and return a Group\nclass FBXTreeParser {\n constructor(textureLoader, manager) {\n this.textureLoader = textureLoader\n this.manager = manager\n }\n\n parse() {\n connections = this.parseConnections()\n\n const images = this.parseImages()\n const textures = this.parseTextures(images)\n const materials = this.parseMaterials(textures)\n const deformers = this.parseDeformers()\n const geometryMap = new GeometryParser().parse(deformers)\n\n this.parseScene(deformers, geometryMap, materials)\n\n return sceneGraph\n }\n\n // Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry )\n // and details the connection type\n parseConnections() {\n const connectionMap = new Map()\n\n if ('Connect