Skip to content
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

Help using pnextThreeLoader with react #126

Open
mikisf opened this issue Jun 16, 2023 · 2 comments
Open

Help using pnextThreeLoader with react #126

mikisf opened this issue Jun 16, 2023 · 2 comments

Comments

@mikisf
Copy link

mikisf commented Jun 16, 2023

I'm trying to use this library with my react project but I'm struggling to make it work.
The first issue I run into was the error: "window is not defined", which I was able to solve it by importing the component dynamically without server side rendering, doing it like so:

const PNextThreeLoader = dynamic(
  () => import("../components/PNextThreeLoader"),
  {
    ssr: false,
  }
);

After, I tried loading the example pointcloud like this:

useEffect(() => {
    if (sceneVar === undefined) return;
    const baseUrl = "https://cdn.rawgit.com/potree/potree/develop/pointclouds/lion_takanawa/";
    potreeVar
        .loadPointCloud("cloud.js", (url) => `${baseUrl}${url}`)
        .then((pco) => {
            console.log(pco);
            sceneVar.add(pco);
            potreeVar.updatePointClouds([pco], cameraVar, rendererVar);
            rendererVar.render(sceneVar, cameraVar);
        });
}, [sceneVar]);

but I'm not able to see the lion and there is no error in the console.
I've created a sandbox so you can test it: https://codesandbox.io/p/github/mikisf/pNextThreeLoaderReact/draft/hopeful-silence?file=/components/PNextThreeLoader.js:64,3-76,18&workspaceId=9764f67d-193b-4747-b7a4-e67f33e4cfb2
Or in this github repo: https://github.com/mikisf/pNextThreeLoaderReact
Thanks in advance ;)

@mikisf mikisf changed the title pnextThreeLoader with react Hel using pnextThreeLoader with react Jun 16, 2023
@mikisf mikisf changed the title Hel using pnextThreeLoader with react Help using pnextThreeLoader with react Jun 16, 2023
@mikisf mikisf closed this as completed Jun 20, 2023
@mikisf mikisf reopened this Jun 20, 2023
@vanilla-tiramisu
Copy link

How did you deal with this problem then? Struggling to make it work too...

@im-hamza-dev
Copy link

@vanilla-tiramisu you can check this example folder from this repository:

https://github.com/pnext/three-loader/tree/master/example

main.ts and viewer.ts properly provide the implementation with threejs scene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants