1 |
- {"ast":null,"code":"import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from \"./glTFLoader.js\";\nimport { GLTFUtils } from \"./glTFLoaderUtils.js\";\nimport { EComponentType } from \"./glTFLoaderInterfaces.js\";\nconst BinaryExtensionBufferName = \"binary_glTF\";\n/**\n * @internal\n * @deprecated\n */\nexport class GLTFBinaryExtension extends GLTFLoaderExtension {\n constructor() {\n super(\"KHR_binary_glTF\");\n }\n loadRuntimeAsync(scene, data, rootUrl, onSuccess) {\n const extensionsUsed = data.json.extensionsUsed;\n if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {\n return false;\n }\n this._bin = data.bin;\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\n return true;\n }\n loadBufferAsync(gltfRuntime, id, onSuccess, onError) {\n if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {\n return false;\n }\n if (id !== BinaryExtensionBufferName) {\n return false;\n }\n this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, error => onError(error.message));\n return true;\n }\n loadTextureBufferAsync(gltfRuntime, id, onSuccess) {\n const texture = gltfRuntime.textures[id];\n const source = gltfRuntime.images[texture.source];\n if (!source.extensions || !(this.name in source.extensions)) {\n return false;\n }\n const sourceExt = source.extensions[this.name];\n const bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];\n const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\n onSuccess(buffer);\n return true;\n }\n loadShaderStringAsync(gltfRuntime, id, onSuccess) {\n const shader = gltfRuntime.shaders[id];\n if (!shader.extensions || !(this.name in shader.extensions)) {\n return false;\n }\n const binaryExtensionShader = shader.extensions[this.name];\n const bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];\n const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\n setTimeout(() => {\n const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);\n onSuccess(shaderString);\n });\n return true;\n }\n}\nGLTFLoader.RegisterExtension(new GLTFBinaryExtension());","map":{"version":3,"names":["GLTFLoaderExtension","GLTFLoader","GLTFLoaderBase","GLTFUtils","EComponentType","BinaryExtensionBufferName","GLTFBinaryExtension","constructor","loadRuntimeAsync","scene","data","rootUrl","onSuccess","extensionsUsed","json","indexOf","name","bin","_bin","CreateRuntime","loadBufferAsync","gltfRuntime","id","onError","readAsync","byteLength","then","error","message","loadTextureBufferAsync","texture","textures","source","images","extensions","sourceExt","bufferView","bufferViews","buffer","GetBufferFromBufferView","UNSIGNED_BYTE","loadShaderStringAsync","shader","shaders","binaryExtensionShader","shaderBytes","setTimeout","shaderString","DecodeBufferToText","RegisterExtension"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/1.0/glTFBinaryExtension.js"],"sourcesContent":["import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from \"./glTFLoader.js\";\nimport { GLTFUtils } from \"./glTFLoaderUtils.js\";\nimport { EComponentType } from \"./glTFLoaderInterfaces.js\";\nconst BinaryExtensionBufferName = \"binary_glTF\";\n/**\n * @internal\n * @deprecated\n */\nexport class GLTFBinaryExtension extends GLTFLoaderExtension {\n constructor() {\n super(\"KHR_binary_glTF\");\n }\n loadRuntimeAsync(scene, data, rootUrl, onSuccess) {\n const extensionsUsed = data.json.extensionsUsed;\n if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {\n return false;\n }\n this._bin = data.bin;\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\n return true;\n }\n loadBufferAsync(gltfRuntime, id, onSuccess, onError) {\n if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {\n return false;\n }\n if (id !== BinaryExtensionBufferName) {\n return false;\n }\n this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, (error) => onError(error.message));\n return true;\n }\n loadTextureBufferAsync(gltfRuntime, id, onSuccess) {\n const texture = gltfRuntime.textures[id];\n const source = gltfRuntime.images[texture.source];\n if (!source.extensions || !(this.name in source.extensions)) {\n return false;\n }\n const sourceExt = source.extensions[this.name];\n const bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];\n const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\n onSuccess(buffer);\n return true;\n }\n loadShaderStringAsync(gltfRuntime, id, onSuccess) {\n const shader = gltfRuntime.shaders[id];\n if (!shader.extensions || !(this.name in shader.extensions)) {\n return false;\n }\n const binaryExtensionShader = shader.extensions[this.name];\n const bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];\n const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\n setTimeout(() => {\n const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);\n onSuccess(shaderString);\n });\n return true;\n }\n}\nGLTFLoader.RegisterExtension(new GLTFBinaryExtension());\n"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,UAAU,EAAEC,cAAc,QAAQ,iBAAiB;AACjF,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,MAAMC,yBAAyB,GAAG,aAAa;AAC/C;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,SAASN,mBAAmB,CAAC;EACzDO,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC,iBAAiB,CAAC;EAC5B;EACAC,gBAAgBA,CAACC,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAE;IAC9C,MAAMC,cAAc,GAAGH,IAAI,CAACI,IAAI,CAACD,cAAc;IAC/C,IAAI,CAACA,cAAc,IAAIA,cAAc,CAACE,OAAO,CAAC,IAAI,CAACC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAACN,I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