Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

v1.0.32 #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
takuma-hmng8 merged 1 commit into main from dev
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
829 changes: 425 additions & 404 deletions packages/use-shader-fx/build/use-shader-fx.js
View file Open in desktop

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/use-shader-fx/build/use-shader-fx.js.map
View file Open in desktop

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions packages/use-shader-fx/build/use-shader-fx.umd.cjs
View file Open in desktop

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/use-shader-fx/build/use-shader-fx.umd.cjs.map
View file Open in desktop

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/use-shader-fx/package-lock.json
View file Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/use-shader-fx/package.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmng8/use-shader-fx",
"version": "1.0.31",
"version": "1.0.32",
"description": "wide variety of shader effects for React",
"main": "./build/use-shader-fx.umd.cjs",
"module": "./build/use-shader-fx.js",
Expand Down
17 changes: 17 additions & 0 deletions packages/use-shader-fx/src/utils/useDoubleFBO.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const useDoubleFBO = ({
isSizeUpdate = false,
samples = 0,
depthBuffer = false,
depthTexture = false,
}: UseFboProps): UseDoubleFBOReturn => {
const renderTarget = useRef<RenderTarget>({
read: null,
Expand All @@ -60,6 +61,7 @@ export const useDoubleFBO = ({
});

const resolution = useResolution(size, dpr);

const initRenderTargets = useMemo(() => {
const read = new THREE.WebGLRenderTarget(resolution.x, resolution.y, {
...FBO_OPTION,
Expand All @@ -71,9 +73,24 @@ export const useDoubleFBO = ({
samples,
depthBuffer,
});

if (depthTexture) {
read.depthTexture = new THREE.DepthTexture(
resolution.x,
resolution.y,
THREE.FloatType
);
write.depthTexture = new THREE.DepthTexture(
resolution.x,
resolution.y,
THREE.FloatType
);
}

return { read, write };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

renderTarget.current.read = initRenderTargets.read;
renderTarget.current.write = initRenderTargets.write;

Expand Down
31 changes: 24 additions & 7 deletions packages/use-shader-fx/src/utils/useSingleFBO.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ export type UseFboProps = {
isSizeUpdate?: boolean;
/** Defines the count of MSAA samples. Can only be used with WebGL 2. Default is 0. */
samples?: number;
/** Renders to the depth buffer. Default is false. */
/** Renders to the depth buffer. Unlike the three.js, Default is false. */
depthBuffer?: boolean;
/** If set, the scene depth will be rendered to this texture. Default is false. */
depthTexture?: boolean;
};

type FBOUpdateFunction = (
Expand All @@ -51,17 +53,32 @@ export const useSingleFBO = ({
isSizeUpdate = false,
samples = 0,
depthBuffer = false,
depthTexture = false,
}: UseFboProps): UseSingleFBOReturn => {
const renderTarget = useRef<THREE.WebGLRenderTarget>();

const resolution = useResolution(size, dpr);

renderTarget.current = useMemo(
() =>
new THREE.WebGLRenderTarget(resolution.x, resolution.y, {
...FBO_OPTION,
samples,
depthBuffer,
}),
() => {
const target = new THREE.WebGLRenderTarget(
resolution.x,
resolution.y,
{
...FBO_OPTION,
samples,
depthBuffer,
}
);
if (depthTexture) {
target.depthTexture = new THREE.DepthTexture(
resolution.x,
resolution.y,
THREE.FloatType
);
}
return target;
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
Expand Down
2 changes: 1 addition & 1 deletion packages/use-shader-fx/types/utils/useDoubleFBO.d.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ type UseDoubleFBOReturn = [
* @param isSizeUpdate Whether to resize when resizing occurs. If isDpr is true, set FBO to setSize even if dpr is changed, default:false
* @returns [{read:THREE.WebGLRenderTarget,write:THREE.WebGLRenderTarget} , updateFBO] -Receives the RenderTarget as the first argument and the update function as the second argument.
*/
export declare const useDoubleFBO: ({ scene, camera, size, dpr, isSizeUpdate, samples, depthBuffer, }: UseFboProps) => UseDoubleFBOReturn;
export declare const useDoubleFBO: ({ scene, camera, size, dpr, isSizeUpdate, samples, depthBuffer, depthTexture, }: UseFboProps) => UseDoubleFBOReturn;
export {};
6 changes: 4 additions & 2 deletions packages/use-shader-fx/types/utils/useSingleFBO.d.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export type UseFboProps = {
isSizeUpdate?: boolean;
/** Defines the count of MSAA samples. Can only be used with WebGL 2. Default is 0. */
samples?: number;
/** Renders to the depth buffer. Default is false. */
/** Renders to the depth buffer. Unlike the three.js, Default is false. */
depthBuffer?: boolean;
/** If set, the scene depth will be rendered to this texture. Default is false. */
depthTexture?: boolean;
};
type FBOUpdateFunction = (gl: THREE.WebGLRenderer,
/** call before FBO is rendered */
Expand All @@ -25,5 +27,5 @@ type UseSingleFBOReturn = [THREE.WebGLRenderTarget, FBOUpdateFunction];
* @param isSizeUpdate Whether to resize when resizing occurs. If isDpr is true, set FBO to setSize even if dpr is changed, default:false
* @returns [THREE.WebGLRenderTarget , updateFBO] -Receives the RenderTarget as the first argument and the update function as the second argument.
*/
export declare const useSingleFBO: ({ scene, camera, size, dpr, isSizeUpdate, samples, depthBuffer, }: UseFboProps) => UseSingleFBOReturn;
export declare const useSingleFBO: ({ scene, camera, size, dpr, isSizeUpdate, samples, depthBuffer, depthTexture, }: UseFboProps) => UseSingleFBOReturn;
export {};

AltStyle によって変換されたページ (->オリジナル) /