Loading PCD files using NPM and Three.js

Hi, I want to import a point-cloud model into the scene using THREE.js.
I’m using a Node module that I installed through npm.

Do I have to install PCD.Loader or it is included in THREE.js ?

Any suggestion would be appreciated.
Thanks!

all you need is npm install three and then you go

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

...
new PCDLoader().load(url, data => ...)
1 Like

Hey thank you !
npm install three is done.
Seems I’m still doing something wrong and that the problem occurs with the path of my PCB file. Here is the screenshot:

I succeeded ! :slight_smile:
I just changed the path to: ‘https://unpkg.com/three@0.126.1/examples/jsm/loaders/PCDLoader’ and it’s working.

Thank you so much!

that makes no sense imo. you also shouldn’t fetch three from a shaky cdn. i mean are you ok with your app failing 10 times day randomly?

npm create vite
cd project-folder
npm install three
npm run dev

you go into your editor and start working. if you import * THREE from 'three' and import { PCDLoader } from 'three/examples/jsm/loaders/PCDLoader' it has to work. but if you’re using modules you can’t mix because modules have unique namespaces, if you take something from here and there it will cause double imports or worse.

Actually, I was working in such way as it was explained in the tutorial on the link : Three.js Tutorial Crash Course - 2021 - YouTube
However, I will do as you said and probably pick another tutorial.
Thanks for suggestions, they help a lot :slight_smile: