Hi,
I am trying to setup a TypeScript project structure for a Three.js web applications.
In the past, I was using @types/three:
But the author seems to have stopped development at r103 saying:
“This is a stub types definition. three provides its own type definitions, so you do not need this installed.”
And indeed, I am checking r105 and all classes have a .d.ts file.
This is awesome knowing I can keep using the latest build and have official typescript definitions… but I have some issues.
Here is where I am at.
In WebStorm, I create an empty typescript project.
I install three.js
npm i three
I setup my tsconfig.json
{
“compilerOptions”: {
“module”: “amd”,
“target”: “es5”,
“sourceMap”: true,
“allowJs”: true,
“outDir”: “built”,
“lib”: [
“dom”,
“es2015”
],
“baseUrl”: “.”,
“paths”: {
“three”: [“node_modules/three/src/Three”]
}
},
“include”: [
“src/**/*”
]
}
And finally I put in my built folder three.min.js and require.js
And as long as I use core three.js it works, and it’s great.
But I cannot seem to use the classes that are in the examples folders.
I know I would have to add some js files to the built folder for it to run, but first of all I cannot even build.
When I try to declare a EffectComposer for example, the WebStorm auto completion proposes to declare:
import {EffectComposer} from “three/examples/jsm/postprocessing/EffectComposer”;
And when I do I get proper autocompletion to the EffectComposer objects.
But at build I get the error:
Cannot find module ‘three/examples/jsm/postprocessing/EffectComposer’.
I’m guessing is has something to do with the way I configure my project.
I must be missing something.
Can anybody help me with that?
How do you configure your TypeScript projects?
Thanks a lot.