Monday, 17 April 2017

Extending three.js in TypeScript

I want to extend three.js in typescript but avoiding using classical prototype extension but use ES6/TS extends.

I'm using typings for code completion.

It works client-side and using <script> tag to import three.js.

But I want to add some testing and for that I need it importing three.js server side.

I'm using the following code:

import * as THREE from 'three';
export class Mesh extends THREE.Mesh
{
    newAttribute?: any;
}

This works on client. But if I try to compile for the server I get this error when compiling:

ReferenceError: THREE is not defined

If I just use the lib, it works well even on server side. But not extending..

What can I be missing?

Thank you in advance!



via Rui d'Orey

No comments:

Post a Comment