How to import the PLYLoader in next.js app? ( with react-three-fiber )

Hi.
I am developing an application to display .ply files on Next.js with react-three-fiber.
I refered below example, but when I try to import the PLYLoader, it throws an error. Does anyone know of a solution?

The example I refer to

https://sbcode.net/threejs/loaders-ply/

How do I import:

import { PLYLoader } from 'three/examples/jsm/loaders/PLYLoader'

Error:

I’m afraid this is a very basic question.

three/jsm is untranspiled, it can’t run in node. we have made a mirror for module usage, tree-shaking and better dependency management GitHub - pmndrs/three-stdlib: Stand-alone library of threejs examples designed to run without transpilatio

import { PLYLoader } from 'three-stdlib'

this will universally help using three in node or ssr.

1 Like

@drcmda
Thanks for giving me a solution! It works!