Giter Site home page Giter Site logo

Comments (6)

xavierjs avatar xavierjs commented on May 23, 2024 1

I suppose it worked so I close the issue. @ghostlexly when someone takes time to help you to solve an issue, you should at least say thank you, your mother should have taught you that.

from jeelizfacefilter.

xavierjs avatar xavierjs commented on May 23, 2024

First, Hi

NextJS runs JavaScript code on the server side.
But some browser APIs like WebGL or MediaStream API cannot run on the server side. Jeeliz FaceFilter relies on WebGL and MediaStream API. So you need to tell NextJS to force execution on the client side.

To run code on the client side with NextJS you can use dynamic.
At the beginning of the component importing the AR component
( the AR Component is AppCanvas - https://github.com/jeeliz/jeelizFaceFilter/blob/master/reactThreeFiberDemo/src/js/components/AppCanvas.js )

import dynamic from 'next/dynamic'

Then:

const AppCanvasDyn = dynamic(
    () => {
      return import("AppCanvas");
    },
    { ssr: false }
  );

Then in the rendering, you render < AppCanvasDyn/> instead of <AppCanvas/>

from jeelizfacefilter.

xavierjs avatar xavierjs commented on May 23, 2024

@ghostlexly does it help to make it work with NextJS?

from jeelizfacefilter.

usama203 avatar usama203 commented on May 23, 2024

I suppose it worked so I close the issue. @ghostlexly when someone takes time to help you to solve an issue, you should at least say thank you, your mother should have taught you that.

Thank you brother it really helps. I was stuck on same issue almost 3 hours.

from jeelizfacefilter.

omgcx1222 avatar omgcx1222 commented on May 23, 2024

First, Hi

NextJS runs JavaScript code on the server side. But some browser APIs like WebGL or MediaStream API cannot run on the server side. Jeeliz FaceFilter relies on WebGL and MediaStream API. So you need to tell NextJS to force execution on the client side.

To run code on the client side with NextJS you can use dynamic. At the beginning of the component importing the AR component ( the AR Component is AppCanvas - https://github.com/jeeliz/jeelizFaceFilter/blob/master/reactThreeFiberDemo/src/js/components/AppCanvas.js )

import dynamic from 'next/dynamic'

Then:

const AppCanvasDyn = dynamic(
    () => {
      return import("AppCanvas");
    },
    { ssr: false }
  );

Then in the rendering, you render < AppCanvasDyn/> instead of <AppCanvas/>

An 'ARCanvas' cannot be used as a JSX component. Its element type 'ReactElement<any, any> | Component | null' is not a valid JSX element. error message is displayed when the yarn build command is run. @types/react": "18.2.25"

`const JEELIZVTOWIDGET = useRef();
useEffect(() => {
if (!JEELIZVTOWIDGET.current) {
import("jeelizvtowidget").then((module) => {
JEELIZVTOWIDGET.current = module.JEELIZVTOWIDGET;

    init_VTOWidget({
      placeHolder,
      canvas,
      toggle_loading,
      sku: tryOnProduct.ar_model_url,
      JEELIZVTOWIDGET: JEELIZVTOWIDGET.current,
    });
  });
} else {
  JEELIZVTOWIDGET.current?.resume(true);
}

return () => {
  JEELIZVTOWIDGET.current?.destroy();
  // JEELIZVTOWIDGET?.pause(true);
};

}, [tryOnProduct.ar_model_url]);`

I use it this way, No problems with development and build, but I don't know if there are other problems

from jeelizfacefilter.

ghostlexly avatar ghostlexly commented on May 23, 2024

I suppose it worked so I close the issue. @ghostlexly when someone takes time to help you to solve an issue, you should at least say thank you, your mother should have taught you that.

I just never received the notifications for your messages, but thanks for the solution, even if it's late. I always appreciate the community's help here.
We never had the solution, my company has just removed the filter idea from the roadmap.

from jeelizfacefilter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.