THREE JS ColladaLoader with npm -i is not recognized

Hi, I’m trying to port this THREE JS example to ionic.
webgl loader with collada skinning

I npm installed both THREE JS and the Collada Loader
npm i three --save
npm i three-collada-loader --save
npm install @types/three --save

I import THEE with no problem
import * as THREE from 'three';

But I am not able to import the Collada loader. I’ve tried:

import { ColladaLoader } from 'three-collada-loader';
import { ColladaLoader } from 'three-collada-loader/index';
import * as ColladaLoader from 'three-collada-loader';

But my constructor does not recognize the class
constructor(private colladaLoader: ColladaLoader){};
gets a red undeline in VS Code

Does anyone know why?

You have not installed any type definitions for three-collada-loader

You could use
declare var ColladaLoader : any;

or write your own typedefinitions

I thought they where already installed.

This is what they look like including the Collada Loader code

The declare statement produces an error:

It says non-exported ???

Sorry, I did not knew they included the type definitions from colladaloader inside the @types/three type definitions.

You can import it with:
import {ColladaLoader} from "three";
but I think the type definitions are buggy. I get undefined all the time. I think the type definitions should point to three-collada-loader instead of three

Maybe this can help. Here are typescript and ColladaLoader used:
http://www.gamefromscratch.com/post/2014/07/23/Playing-around-with-ThreeJS-Part-Two-of-a-not-quite-a-tutorial-series.aspx

Hi @Nexi, yea I just tried it but I too get undefined. I’ll take a look at tutorial. Thanks.
image

There are errors in the type definitions i would guess. All methods from the type definitions are shown with typescript but I get errors in the console when using ColladaLoader.

I’ll read up on how to write a typescript type definition file