5

I've really tried my best to solve this with my own research, but unfortunately I'm an absolute novice with three.js and javascript and I really need some help.

I am trying to import a model from threex (google threex -- I can't post another link) into my three.js scene. Unfortunately, when I add the code to do so as follows:

    var spaceship = null;
THREEx.SpaceShips.loadSpaceFighter03(function(object3d){
    scene.add(object3d)
    spaceship = object3d
})

I end up with a blank scene, and this error in my javascript console:

Uncaught TypeError: (intermediate value).fromArray is not a function.:8000/bower_components/threex.spaceships/examples/vendor/three.js/examples/js/loaders/MTLLoader.js:299

Which leads me to the (supposedly) offending line of code in MTLLoader.js (whatever that file is.)

params[ 'ambient' ] = new THREE.Color().fromArray( value );

I don't know what's happening, and I'm in a bit over my head I think. Does anybody know how to fix this?

I am working off of this tutorial: https://www.youtube.com/watch?v=vw5_YyM4hn8 (if it helps, the sample code for that segment of the tutorial is found here: https://github.com/jeromeetienne/flying-spaceship-minigame/blob/master/step1-01-naked-spaceship.html -- I can't see any problems -- I've so far tried to follow the steps very closely.)

Thanks in advance.

spwoco
  • 83
  • 5
  • 2
    Threex is compatible with a version of three.js that is a year old. Since you are just learning, I would suggest you follow this advice: http://stackoverflow.com/questions/11966779/learning-webgl-and-three-js/11970687#11970687. – WestLangley May 02 '15 at 15:53
  • Thank you! After checking the changelogs from previous three.js versions, I see that the fromArray() function has changed. I guess I suspected something like that... Where did you find the compatibility information for threex? I can't seem to find any documentation specifying what version of three.js it's explicitly compatible with. – spwoco May 04 '15 at 18:24
  • https://github.com/jeromeetienne/threex/tree/master/vendor – WestLangley May 04 '15 at 18:32
  • 1
    this threex should definitly be updated :) just a note. i definitly agree on the need to understand the underlying technologies. I would like to point out that there is value in packaging extensions tho. it can be seen in jQuery ecosystem, or unity asset library. It avoids everybody to redo the same thing over and over. my 2 cents :) – Jerome Etienne May 05 '15 at 12:35
  • I followed the advice on in the highest voted answer in the Meta SO and edited the answer and other useful info from the comments to a Community Wiki answer, see "Question with no answers, but issue solved in the comments" for rationale: http://meta.stackoverflow.com/questions/251597/question-with-no-answers-but-issue-solved-in-the-comments . Perhaps not so relevant with this not so generic question but figured is useful anyhow in order to clean the list of unanswered questions. Also people do encounter these version incompatibilities often. – antont Jul 31 '15 at 14:47

1 Answers1

1

This is a version incompatibility between current three.js and the code used from that threex. Threex is compatible with a version of three.js that is a year old.

When learning three.js, this has good advice: Learning WebGL and three.js

The version of three.js that threex uses can be seen in https://github.com/jeromeetienne/threex/tree/master/vendor

Community
  • 1
  • 1
antont
  • 2,320
  • 14
  • 19