Three.js: TypeScript: module augmentation, add methods and properties to Object3D

Created on 24 Feb 2018  路  2Comments  路  Source: mrdoob/three.js

Hello there,

I'm having troubles augmenting definitions for the "three" module.

I'd like to add methods and attributes on THREE.Object3D. I've tried many variations of the following example, but none of them seem to work:

augment.d.ts:

/// <reference types="three" />

declare namespace THREE {
    export interface Object3D {
        addBehaviour (klass: any): any;
        getEntity (): any;
    }
}

Usage:

screen shot 2018-02-24 at 19 20 53

Anyone has experience augmenting THREE definitions on TypeScript?
Cheers!

Help (please use the forum)

Most helpful comment

@sidroopdaska I've found some TypeScript open issues about this. Unfortunately, it's not possible to do this currently because of the way the type definitions are written for three.js.

More info:

All 2 comments

Did you figure this out?

@sidroopdaska I've found some TypeScript open issues about this. Unfortunately, it's not possible to do this currently because of the way the type definitions are written for three.js.

More info:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clawconduce picture clawconduce  路  3Comments

filharvey picture filharvey  路  3Comments

zsitro picture zsitro  路  3Comments

Horray picture Horray  路  3Comments

yqrashawn picture yqrashawn  路  3Comments