@react-three/postprocessing 2.17.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effects/SelectiveBloom.cjs +19 -12
- package/dist/effects/SelectiveBloom.cjs.map +1 -1
- package/dist/effects/SelectiveBloom.d.ts +4 -0
- package/dist/effects/SelectiveBloom.js +19 -12
- package/dist/effects/SelectiveBloom.js.map +1 -1
- package/dist/effects/Texture.cjs +2 -2
- package/dist/effects/Texture.cjs.map +1 -1
- package/dist/effects/Texture.d.ts +2 -0
- package/dist/effects/Texture.js +2 -2
- package/dist/effects/Texture.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ const SelectiveBloom = React.forwardRef(function SelectiveBloom2({
|
|
|
13
13
|
selection = [],
|
|
14
14
|
selectionLayer = 10,
|
|
15
15
|
lights = [],
|
|
16
|
+
inverted = false,
|
|
17
|
+
ignoreBackground = false,
|
|
16
18
|
luminanceThreshold,
|
|
17
19
|
luminanceSmoothing,
|
|
18
20
|
intensity,
|
|
@@ -28,18 +30,23 @@ const SelectiveBloom = React.forwardRef(function SelectiveBloom2({
|
|
|
28
30
|
const invalidate = fiber.useThree((state) => state.invalidate);
|
|
29
31
|
const { scene, camera } = React.useContext(EffectComposer.EffectComposerContext);
|
|
30
32
|
const effect = React.useMemo(
|
|
31
|
-
() =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
() => {
|
|
34
|
+
const effect2 = new postprocessing.SelectiveBloomEffect(scene, camera, {
|
|
35
|
+
blendFunction: postprocessing.BlendFunction.ADD,
|
|
36
|
+
luminanceThreshold,
|
|
37
|
+
luminanceSmoothing,
|
|
38
|
+
intensity,
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
kernelSize,
|
|
42
|
+
mipmapBlur,
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
effect2.inverted = inverted;
|
|
46
|
+
effect2.ignoreBackground = ignoreBackground;
|
|
47
|
+
return effect2;
|
|
48
|
+
},
|
|
49
|
+
[scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props]
|
|
43
50
|
);
|
|
44
51
|
const api = React.useContext(Selection.selectionContext);
|
|
45
52
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectiveBloom.cjs","sources":["../../src/effects/SelectiveBloom.tsx"],"sourcesContent":["import { SelectiveBloomEffect, BlendFunction } from 'postprocessing'\nimport type { BloomEffectOptions } from 'postprocessing'\nimport React, { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type SelectiveBloomProps = BloomEffectOptions &\n Partial<{\n lights: Object3D[] | ObjectRef[]\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n }>\n\nconst addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)\nconst removeLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.disable(effect.selection.layer)\n\nexport const SelectiveBloom = forwardRef(function SelectiveBloom(\n {\n selection = [],\n selectionLayer = 10,\n lights = [],\n luminanceThreshold,\n luminanceSmoothing,\n intensity,\n width,\n height,\n kernelSize,\n mipmapBlur,\n\n ...props\n }: SelectiveBloomProps,\n forwardRef: Ref<SelectiveBloomEffect>\n) {\n if (lights.length === 0) {\n console.warn('SelectiveBloom requires lights to work.')\n }\n\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n ()
|
|
1
|
+
{"version":3,"file":"SelectiveBloom.cjs","sources":["../../src/effects/SelectiveBloom.tsx"],"sourcesContent":["import { SelectiveBloomEffect, BlendFunction } from 'postprocessing'\nimport type { BloomEffectOptions } from 'postprocessing'\nimport React, { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type SelectiveBloomProps = BloomEffectOptions &\n Partial<{\n lights: Object3D[] | ObjectRef[]\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n inverted: boolean\n ignoreBackground: boolean\n }>\n\nconst addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)\nconst removeLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.disable(effect.selection.layer)\n\nexport const SelectiveBloom = forwardRef(function SelectiveBloom(\n {\n selection = [],\n selectionLayer = 10,\n lights = [],\n inverted = false,\n ignoreBackground = false,\n luminanceThreshold,\n luminanceSmoothing,\n intensity,\n width,\n height,\n kernelSize,\n mipmapBlur,\n\n ...props\n }: SelectiveBloomProps,\n forwardRef: Ref<SelectiveBloomEffect>\n) {\n if (lights.length === 0) {\n console.warn('SelectiveBloom requires lights to work.')\n }\n\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n () => {\n const effect = new SelectiveBloomEffect(scene, camera, {\n blendFunction: BlendFunction.ADD,\n luminanceThreshold,\n luminanceSmoothing,\n intensity,\n width,\n height,\n kernelSize,\n mipmapBlur,\n ...props,\n });\n effect.inverted = inverted;\n effect.ignoreBackground = ignoreBackground;\n return effect;\n },\n [scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props]\n )\n\n const api = useContext(selectionContext)\n\n useEffect(() => {\n // Do not allow array selection if declarative selection is active\n // TODO: array selection should probably be deprecated altogether\n if (!api && selection) {\n effect.selection.set(\n Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]\n )\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }, [effect, selection, api, invalidate])\n\n useEffect(() => {\n effect.selection.layer = selectionLayer\n invalidate()\n }, [effect, invalidate, selectionLayer])\n\n useEffect(() => {\n if (lights && lights.length > 0) {\n lights.forEach((light) => addLight(resolveRef(light), effect))\n invalidate()\n return () => {\n lights.forEach((light) => removeLight(resolveRef(light), effect))\n invalidate()\n }\n }\n }, [effect, invalidate, lights, selectionLayer])\n\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect.selection, invalidate])\n\n return <primitive ref={forwardRef} object={effect} dispose={null} />\n})\n"],"names":["forwardRef","SelectiveBloom","useThree","useContext","EffectComposerContext","useMemo","effect","SelectiveBloomEffect","BlendFunction","selectionContext","useEffect","resolveRef"],"mappings":";;;;;;;;;AAoBA,MAAM,WAAW,CAAC,OAAiB,WAAiC,MAAM,OAAO,OAAO,OAAO,UAAU,KAAK;AAC9G,MAAM,cAAc,CAAC,OAAiB,WAAiC,MAAM,OAAO,QAAQ,OAAO,UAAU,KAAK;AAErG,MAAA,iBAAiBA,MAAAA,WAAW,SAASC,gBAChD;AAAA,EACE,YAAY,CAAC;AAAA,EACb,iBAAiB;AAAA,EACjB,SAAS,CAAC;AAAA,EACV,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,GAAG;AACL,GACAD,aACA;AACI,MAAA,OAAO,WAAW,GAAG;AACvB,YAAQ,KAAK,yCAAyC;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IAEf;AAAA,KACC,CAAC,QAAQ,YAAY,QAAQ,cAAc,CAAC;AAE/CD,QAAAA,UAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,KACC,CAAC,KAAK,OAAO,WAAW,UAAU,CAAC;AAEtC,wCAAQ,aAAU,EAAA,KAAKV,aAAY,QAAQ,QAAQ,SAAS,KAAM,CAAA;AACpE,CAAC;;"}
|
|
@@ -7,10 +7,14 @@ export type SelectiveBloomProps = BloomEffectOptions & Partial<{
|
|
|
7
7
|
lights: Object3D[] | ObjectRef[];
|
|
8
8
|
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[];
|
|
9
9
|
selectionLayer: number;
|
|
10
|
+
inverted: boolean;
|
|
11
|
+
ignoreBackground: boolean;
|
|
10
12
|
}>;
|
|
11
13
|
export declare const SelectiveBloom: React.ForwardRefExoticComponent<BloomEffectOptions & Partial<{
|
|
12
14
|
lights: Object3D[] | ObjectRef[];
|
|
13
15
|
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[];
|
|
14
16
|
selectionLayer: number;
|
|
17
|
+
inverted: boolean;
|
|
18
|
+
ignoreBackground: boolean;
|
|
15
19
|
}> & React.RefAttributes<SelectiveBloomEffect>>;
|
|
16
20
|
export {};
|
|
@@ -11,6 +11,8 @@ const SelectiveBloom = forwardRef(function SelectiveBloom2({
|
|
|
11
11
|
selection = [],
|
|
12
12
|
selectionLayer = 10,
|
|
13
13
|
lights = [],
|
|
14
|
+
inverted = false,
|
|
15
|
+
ignoreBackground = false,
|
|
14
16
|
luminanceThreshold,
|
|
15
17
|
luminanceSmoothing,
|
|
16
18
|
intensity,
|
|
@@ -26,18 +28,23 @@ const SelectiveBloom = forwardRef(function SelectiveBloom2({
|
|
|
26
28
|
const invalidate = useThree((state) => state.invalidate);
|
|
27
29
|
const { scene, camera } = useContext(EffectComposerContext);
|
|
28
30
|
const effect = useMemo(
|
|
29
|
-
() =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
() => {
|
|
32
|
+
const effect2 = new SelectiveBloomEffect(scene, camera, {
|
|
33
|
+
blendFunction: BlendFunction.ADD,
|
|
34
|
+
luminanceThreshold,
|
|
35
|
+
luminanceSmoothing,
|
|
36
|
+
intensity,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
kernelSize,
|
|
40
|
+
mipmapBlur,
|
|
41
|
+
...props
|
|
42
|
+
});
|
|
43
|
+
effect2.inverted = inverted;
|
|
44
|
+
effect2.ignoreBackground = ignoreBackground;
|
|
45
|
+
return effect2;
|
|
46
|
+
},
|
|
47
|
+
[scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props]
|
|
41
48
|
);
|
|
42
49
|
const api = useContext(selectionContext);
|
|
43
50
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectiveBloom.js","sources":["../../src/effects/SelectiveBloom.tsx"],"sourcesContent":["import { SelectiveBloomEffect, BlendFunction } from 'postprocessing'\nimport type { BloomEffectOptions } from 'postprocessing'\nimport React, { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type SelectiveBloomProps = BloomEffectOptions &\n Partial<{\n lights: Object3D[] | ObjectRef[]\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n }>\n\nconst addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)\nconst removeLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.disable(effect.selection.layer)\n\nexport const SelectiveBloom = forwardRef(function SelectiveBloom(\n {\n selection = [],\n selectionLayer = 10,\n lights = [],\n luminanceThreshold,\n luminanceSmoothing,\n intensity,\n width,\n height,\n kernelSize,\n mipmapBlur,\n\n ...props\n }: SelectiveBloomProps,\n forwardRef: Ref<SelectiveBloomEffect>\n) {\n if (lights.length === 0) {\n console.warn('SelectiveBloom requires lights to work.')\n }\n\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n ()
|
|
1
|
+
{"version":3,"file":"SelectiveBloom.js","sources":["../../src/effects/SelectiveBloom.tsx"],"sourcesContent":["import { SelectiveBloomEffect, BlendFunction } from 'postprocessing'\nimport type { BloomEffectOptions } from 'postprocessing'\nimport React, { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type SelectiveBloomProps = BloomEffectOptions &\n Partial<{\n lights: Object3D[] | ObjectRef[]\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n inverted: boolean\n ignoreBackground: boolean\n }>\n\nconst addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)\nconst removeLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.disable(effect.selection.layer)\n\nexport const SelectiveBloom = forwardRef(function SelectiveBloom(\n {\n selection = [],\n selectionLayer = 10,\n lights = [],\n inverted = false,\n ignoreBackground = false,\n luminanceThreshold,\n luminanceSmoothing,\n intensity,\n width,\n height,\n kernelSize,\n mipmapBlur,\n\n ...props\n }: SelectiveBloomProps,\n forwardRef: Ref<SelectiveBloomEffect>\n) {\n if (lights.length === 0) {\n console.warn('SelectiveBloom requires lights to work.')\n }\n\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n () => {\n const effect = new SelectiveBloomEffect(scene, camera, {\n blendFunction: BlendFunction.ADD,\n luminanceThreshold,\n luminanceSmoothing,\n intensity,\n width,\n height,\n kernelSize,\n mipmapBlur,\n ...props,\n });\n effect.inverted = inverted;\n effect.ignoreBackground = ignoreBackground;\n return effect;\n },\n [scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props]\n )\n\n const api = useContext(selectionContext)\n\n useEffect(() => {\n // Do not allow array selection if declarative selection is active\n // TODO: array selection should probably be deprecated altogether\n if (!api && selection) {\n effect.selection.set(\n Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]\n )\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }, [effect, selection, api, invalidate])\n\n useEffect(() => {\n effect.selection.layer = selectionLayer\n invalidate()\n }, [effect, invalidate, selectionLayer])\n\n useEffect(() => {\n if (lights && lights.length > 0) {\n lights.forEach((light) => addLight(resolveRef(light), effect))\n invalidate()\n return () => {\n lights.forEach((light) => removeLight(resolveRef(light), effect))\n invalidate()\n }\n }\n }, [effect, invalidate, lights, selectionLayer])\n\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect.selection, invalidate])\n\n return <primitive ref={forwardRef} object={effect} dispose={null} />\n})\n"],"names":["SelectiveBloom","forwardRef","effect"],"mappings":";;;;;;;AAoBA,MAAM,WAAW,CAAC,OAAiB,WAAiC,MAAM,OAAO,OAAO,OAAO,UAAU,KAAK;AAC9G,MAAM,cAA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ACd;EACV,GAAA,CAAC,QAAQ,YAAY,cAAc,CAAC;AAEvC,YAAU,MAAM;AACV,QAAA,UAAU,OAAO,SAAS,GAAG;AACxB,aAAA,QAAQ,CAAC,UAAU,SAAS,WAAW,KAAK,GAAG,MAAM,CAAC;AAClD;AACX,aAAO,MAAM;AACJ,eAAA,QAAQ,CAAC,UAAU,YAAY,WAAW,KAAK,GAAG,MAAM,CAAC;AACrD;MAAA;AAAA,IAEf;AAAA,KACC,CAAC,QAAQ,YAAY,QAAQ,cAAc,CAAC;AAE/C,YAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,KACC,CAAC,KAAK,OAAO,WAAW,UAAU,CAAC;AAEtC,6BAAQ,aAAU,EAAA,KAAKD,aAAY,QAAQ,QAAQ,SAAS,KAAM,CAAA;AACpE,CAAC;"}
|
package/dist/effects/Texture.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const postprocessing = require("postprocessing");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const fiber = require("@react-three/fiber");
|
|
7
7
|
const THREE = require("three");
|
|
8
|
-
const Texture = React.forwardRef(function Texture2({ textureSrc, texture, ...props }, ref) {
|
|
8
|
+
const Texture = React.forwardRef(function Texture2({ textureSrc, texture, opacity = 1, ...props }, ref) {
|
|
9
9
|
const t = fiber.useLoader(THREE.TextureLoader, textureSrc);
|
|
10
10
|
React.useLayoutEffect(() => {
|
|
11
11
|
if ("encoding" in t)
|
|
@@ -15,7 +15,7 @@ const Texture = React.forwardRef(function Texture2({ textureSrc, texture, ...pro
|
|
|
15
15
|
t.wrapS = t.wrapT = THREE.RepeatWrapping;
|
|
16
16
|
}, [t]);
|
|
17
17
|
const effect = React.useMemo(() => new postprocessing.TextureEffect({ ...props, texture: t || texture }), [props, t, texture]);
|
|
18
|
-
return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, dispose: null });
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, "blendMode-opacity-value": opacity, dispose: null });
|
|
19
19
|
});
|
|
20
20
|
exports.Texture = Texture;
|
|
21
21
|
//# sourceMappingURL=Texture.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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}\n\nexport const Texture = forwardRef<TextureEffect, TextureProps>(function Texture(\n { textureSrc, texture, ...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} dispose={null} />\n})\n"],"names":["forwardRef","Texture","useLoader","TextureLoader","useLayoutEffect","RepeatWrapping","useMemo","TextureEffect"],"mappings":";;;;;;;
|
|
1
|
+
{"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;;"}
|
package/dist/effects/Texture.js
CHANGED
|
@@ -3,7 +3,7 @@ import { TextureEffect } from "postprocessing";
|
|
|
3
3
|
import { forwardRef, useLayoutEffect, useMemo } from "react";
|
|
4
4
|
import { useLoader } from "@react-three/fiber";
|
|
5
5
|
import { TextureLoader, RepeatWrapping } from "three";
|
|
6
|
-
const Texture = forwardRef(function Texture2({ textureSrc, texture, ...props }, ref) {
|
|
6
|
+
const Texture = forwardRef(function Texture2({ textureSrc, texture, opacity = 1, ...props }, ref) {
|
|
7
7
|
const t = useLoader(TextureLoader, textureSrc);
|
|
8
8
|
useLayoutEffect(() => {
|
|
9
9
|
if ("encoding" in t)
|
|
@@ -13,7 +13,7 @@ const Texture = forwardRef(function Texture2({ textureSrc, texture, ...props },
|
|
|
13
13
|
t.wrapS = t.wrapT = RepeatWrapping;
|
|
14
14
|
}, [t]);
|
|
15
15
|
const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [props, t, texture]);
|
|
16
|
-
return /* @__PURE__ */ jsx("primitive", { ref, object: effect, dispose: null });
|
|
16
|
+
return /* @__PURE__ */ jsx("primitive", { ref, object: effect, "blendMode-opacity-value": opacity, dispose: null });
|
|
17
17
|
});
|
|
18
18
|
export {
|
|
19
19
|
Texture
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Texture.js","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}\n\nexport const Texture = forwardRef<TextureEffect, TextureProps>(function Texture(\n { textureSrc, texture, ...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} dispose={null} />\n})\n"],"names":["Texture"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Texture.js","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":["Texture"],"mappings":";;;;;AAWO,MAAM,UAAU,WAAwC,SAASA,SACtE,EAAE,YAAY,SAAS,UAAU,GAAG,GAAG,MAAM,GAC7C,KACA;AACM,QAAA,IAAI,UAAU,eAAe,UAAU;AAC7C,kBAAgB,MAAM;AAEpB,QAAI,cAAc;AAAG,QAAE,WAAW;AAAA;AAE7B,QAAE,aAAa;AAClB,MAAA,QAAQ,EAAE,QAAQ;AAAA,EAAA,GACnB,CAAC,CAAC,CAAC;AACN,QAAM,SAAS,QAAQ,MAAM,IAAI,cAAc,EAAE,GAAG,OAAO,SAAS,KAAK,QAAS,CAAA,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;AACjG,SAAA,oBAAC,eAAU,KAAU,QAAQ,QAAQ,2BAAyB,SAAS,SAAS,KAAM,CAAA;AAC/F,CAAC;"}
|