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

update error handler of useDomSyncer #60

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 17, 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
437 changes: 218 additions & 219 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.

66 changes: 33 additions & 33 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.38",
"version": "1.0.39",
"description": "The only difficult part is coding the shaders",
"main": "./build/use-shader-fx.umd.cjs",
"module": "./build/use-shader-fx.js",
Expand Down
38 changes: 19 additions & 19 deletions packages/use-shader-fx/src/hooks/useDomSyncer/index.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,32 @@ export const useDomSyncer = (

updateParams && setParams(updateParams);

errorHandler(params);

if (refreshTrigger) {
createMesh({
if (errorHandler(params)) {
if (refreshTrigger) {
createMesh({
params,
size,
scene,
});

intersectionHandler({
isIntersectingRef,
isIntersectingOnceRef,
params,
});

setRefreshTrigger(false);
}

updateDomRects({
params,
size,
resolutionRef,
scene,
});

intersectionHandler({
isIntersectingRef,
isIntersectingOnceRef,
params,
});

setRefreshTrigger(false);
}

updateDomRects({
params,
size,
resolutionRef,
scene,
isIntersectingRef,
});

return updateRenderTarget(gl);
},
[
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { DomSyncerParams } from "..";
import { ISDEV } from "../../../libs/constants";

export const errorHandler = (params: DomSyncerParams) => {
const domLength = params.dom?.length;
const textureLength = params.texture?.length;
const resolutionLength = params.resolution?.length;

if (!domLength || !textureLength || !resolutionLength) {
throw new Error("No dom or texture or resolution is set");
ISDEV && console.warn("No dom or texture or resolution is set");
return false;
}

if (domLength !== textureLength || domLength !== resolutionLength) {
throw new Error("Match dom, texture and resolution length");
ISDEV && console.warn("not Match dom , texture and resolution length");
return false;
}

return true;
};
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Size } from "@react-three/fiber";
import { setUniform } from "../../../utils/setUniforms";
import { DomSyncerMaterial } from "./createMesh";
import { useCallback, useRef } from "react";
import { ISDEV } from "../../../libs/constants";

type UpdateDomRect = ({
params,
Expand Down Expand Up @@ -34,7 +35,8 @@ export const useUpdateDomRect = (): UseUpdateDomRectReturn => {
scene.children.forEach((mesh, i) => {
const domElement = params.dom![i];
if (!domElement) {
throw new Error("DOM is null.");
ISDEV && console.warn("DOM is null.");
return;
}

// DOMRect is updated even outside the intersection
Expand Down
1 change: 1 addition & 0 deletions packages/use-shader-fx/src/libs/constants.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ISDEV = process.env.NODE_ENV === "development";
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { DomSyncerParams } from "..";
export declare const errorHandler: (params: DomSyncerParams) => void;
export declare const errorHandler: (params: DomSyncerParams) => boolean;
1 change: 1 addition & 0 deletions packages/use-shader-fx/types/libs/constants.d.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const ISDEV: boolean;

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