1 line
122 KiB
Plaintext
1 line
122 KiB
Plaintext
|
|
{"version":3,"file":"GLTFExporter.cjs","sources":["../../src/exporters/GLTFExporter.js"],"sourcesContent":["import {\n REVISION,\n BufferAttribute,\n ClampToEdgeWrapping,\n Color,\n DoubleSide,\n InterpolateDiscrete,\n InterpolateLinear,\n LinearFilter,\n LinearMipmapLinearFilter,\n LinearMipmapNearestFilter,\n MathUtils,\n Matrix4,\n MirroredRepeatWrapping,\n NearestFilter,\n NearestMipmapLinearFilter,\n NearestMipmapNearestFilter,\n PropertyBinding,\n RGBAFormat,\n RepeatWrapping,\n Scene,\n Texture,\n CompressedTexture,\n Vector3,\n PlaneGeometry,\n ShaderMaterial,\n Uniform,\n Mesh,\n PerspectiveCamera,\n WebGLRenderer,\n} from 'three'\nimport { version } from '../_polyfill/constants'\n\nasync function readAsDataURL(blob) {\n const buffer = await blob.arrayBuffer()\n const data = btoa(String.fromCharCode(...new Uint8Array(buffer)))\n return `data:${blob.type || ''};base64,${data}`\n}\n\nlet _renderer\nlet fullscreenQuadGeometry\nlet fullscreenQuadMaterial\nlet fullscreenQuad\n\nfunction decompress(texture, maxTextureSize = Infinity, renderer = null) {\n if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new PlaneGeometry(2, 2, 1, 1)\n if (!fullscreenQuadMaterial)\n fullscreenQuadMaterial = new ShaderMaterial({\n uniforms: { blitTexture: new Uniform(texture) },\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = vec4(position.xy * 1.0,0.,.999999);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D blitTexture; \n varying vec2 vUv;\n\n void main(){ \n gl_FragColor = vec4(vUv.xy, 0, 1);\n \n #ifdef IS_SRGB\n gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n #else\n gl_FragColor = texture2D( blitTexture, vUv);\n #endif\n }\n `,\n })\n\n fullscreenQuadMaterial.uniforms.blitTexture.value = texture\n fullscreenQuadMaterial.defines.IS_SRGB =\n 'colorSpace' in texture ? texture.colorSpace === 'srgb' : texture.encoding === 3001\n fullscreenQuadMaterial.needsUpdate = true\n\n if (!fullscreenQuad) {\n fullscreenQuad = new Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial)\n fullscreenQuad.frustrumCulled = false\n }\n\n const _camera = new PerspectiveCamera()\n const _scene = new Scene()\n _scene.add(fullscreenQuad)\n\n if (!renderer) {\n renderer = _renderer = new WebGLRenderer({ antialias: false })\n }\n\n renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize))\n renderer.clear()\n renderer.render(_scene, _camera)\n\n const readableTexture = new Texture(renderer.domElement)\n\n readableTexture.minFilter = texture.minFilter\n readableTexture.magFilter = texture.magFilter\n readableTexture.wrapS = texture.wrapS\n readableTexture.wrapT = texture.wrapT\n readableTexture.name = texture.name\n\n if (_renderer) {\n _renderer.dispose()\n _renderer = null\n }\n\n return readableTexture\n}\n\n/**\n * The KHR_mesh_quantization extension allows these extra attribute component types\n *\n * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#extending-mesh-attributes\n */\nconst KHR_mesh_quantization_ExtraAttrTypes = {\n POSITION: [\n 'byte',\n 'byte normalized',\n 'unsigned byte',\n 'unsigned byte normalized',\n 'short',\n 'short normalized',\n 'unsigned short',\n 'unsigned short normalized',\n ],\n NORMAL: ['byte normalized', 'short normalized'],\n TANGENT: ['byte normalized', 'short normalized'],\n TEXCOORD: ['byte', 'byte normalized', 'unsigned byte', 'short', 'short normalized', 'unsigned short'],\n}\n\nconst GLTFExporter = /* @__PURE__ */ (() => {\n class GLTFExporter {\n /**\n * Static utility functions\n */\n static Utils = {\n insertKeyframe: function (track, time) {\n const tolerance = 0.001 // 1ms\n const valueSize = track
|