0

It a quite a general question. I'm building a webapp with Angular Js (v1.5/1.6) and I wish to add some little 3D animated models using Three Js.

I already tried to set up little things but Angular refuse all Three Js methods... So if anyone of you know or already saw any tutorial, books, article in this area please do not hesitate to share.

Thanks everyone.

2
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Commented Sep 4, 2017 at 8:46
  • 1
    Oh @Juan Ferrer I didn't knew that sorry. I will update soon so with codes and details. Thank you Commented Sep 4, 2017 at 10:06

1 Answer 1

1

There are quite a lot of examples on how to integrate ThreeJS and Angular 1/2.

In my experience the best way to achieve that is by creating a directive that will initialize ThreeJS (create camera, scene, etc...) and like any other directive will communicate with the controller throw the scope (using $watch).

For example:

angular.module('nxGeometry', []).directive('nxGeometry', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
              var camera, scene, geometry, renderer, material, object, container;
              function init() {
                  scene = new THREE.Scene();
                  // continue init threejs stuff 
              }
        }
    }
});

You can see a complete example here (not mine): https://jsfiddle.net/awolf2904/y0dvo582/

Sign up to request clarification or add additional context in comments.

1 Comment

This is awesome! thank you a lot you made my day :) 5*

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.