Open Command Prompt and navigate to the right folder using cd --your-app-folder--/javascriptsource/--ModuleName--/actions.
Run npm install three.
In the JavaScript action, use the following code to import the library:
// Option 1: Import the entire three.js core library.
import * as THREE from 'three';
const scene = new THREE.Scene();
// Option 2: Import just the parts you need.
import { Scene } from 'three';
const scene = new Scene();
Also, you can create a React Widget also to do the same thing