THREE JS ColladaLoader with npm -i is not recognized


#1

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?


How to make ionic2 work with threejs and three-obj-loader
#2

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

You could use
declare var ColladaLoader : any;

or write your own typedefinitions


#3

I thought they where already installed.


#4

This is what they look like including the Collada Loader code


#5

The declare statement produces an error:

It says non-exported ???


#6

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


#7

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


#8

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.


#9

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