1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular2 using threejs Orbitcontrols

Discussão em 'Angular' iniciado por grunk, Setembro 11, 2024.

  1. grunk

    grunk Guest

    I'm trying to use threejs exemple inside my angular (cli) 2 app.

    So i have installed threejs :

    npm install three --save


    then added typings :

    npm install @types/three --save-dev


    Finally my component looks like this :

    import { Component, OnInit } from '@angular/core';
    import * as THREE from 'three';

    @Component({
    selector: 'app-testthreejs',
    templateUrl: './testthreejs.component.html',
    styleUrls: ['./testthreejs.component.css']
    })
    export class TestthreejsComponent implements OnInit {
    //
    }


    With this i can use some functionality from THREE without any problem.

    I would like to use some of the exemple available in node_modules/three/examples/js/ and more precisely OrbitControl. The typings give me the autocompletion in visual studio code : [​IMG]

    But as soon as i tried to use it i have the following error :


    TypeError: WEBPACK_IMPORTED_MODULE_1_three.OrbitControls is not a constructor

    Is there any way to make available OrbitControls (and other exemples) via some import ? Should i simply include control.js in my html ?

    What's the best way to deal with this ?

    Continue reading...

Compartilhe esta Página