{"version":3,"file":"Texture.cjs","sources":["../../src/effects/Texture.tsx"],"sourcesContent":["import { TextureEffect } from 'postprocessing'\nimport { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'\nimport { useLoader } from '@react-three/fiber'\nimport { TextureLoader, RepeatWrapping } from 'three'\n\ntype TextureProps = ConstructorParameters<typeof TextureEffect>[0] & {\n  textureSrc: string\n  /** opacity of provided texture */\n  opacity?: number\n}\n\nexport const Texture = forwardRef<TextureEffect, TextureProps>(function Texture(\n  { textureSrc, texture, opacity = 1, ...props }: TextureProps,\n  ref: Ref<TextureEffect>\n) {\n  const t = useLoader(TextureLoader, textureSrc)\n  useLayoutEffect(() => {\n    // @ts-ignore\n    if ('encoding' in t) t.encoding = 3001 // sRGBEncoding\n    // @ts-ignore\n    else t.colorSpace = 'srgb'\n    t.wrapS = t.wrapT = RepeatWrapping\n  }, [t])\n  const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [props, t, texture])\n  return <primitive ref={ref} object={effect} blendMode-opacity-value={opacity} dispose={null} />\n})\n"],"names":["forwardRef","Texture","useLoader","TextureLoader","useLayoutEffect","RepeatWrapping","useMemo","TextureEffect","jsx"],"mappings":";;;;;;;AAWO,MAAM,UAAUA,MAAA,WAAwC,SAASC,SACtE,EAAE,YAAY,SAAS,UAAU,GAAG,GAAG,MAAM,GAC7C,KACA;AACM,QAAA,IAAIC,MAAAA,UAAUC,MAAA,eAAe,UAAU;AAC7CC,QAAAA,gBAAgB,MAAM;AAEpB,QAAI,cAAc;AAAG,QAAE,WAAW;AAAA;AAE7B,QAAE,aAAa;AAClB,MAAA,QAAQ,EAAE,QAAQC,MAAAA;AAAAA,EAAA,GACnB,CAAC,CAAC,CAAC;AACN,QAAM,SAASC,MAAAA,QAAQ,MAAM,IAAIC,eAAAA,cAAc,EAAE,GAAG,OAAO,SAAS,KAAK,QAAS,CAAA,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;AACjG,SAAAC,+BAAC,eAAU,KAAU,QAAQ,QAAQ,2BAAyB,SAAS,SAAS,KAAM,CAAA;AAC/F,CAAC;;"}