1

i am trying to do my own version of a planetarium based on the book Up and running and i am getting a problem when trying to make a skybox.

I am using Chrome and the javascript console bring up an error "Uncaught TypeError: undefined is not a function" in the line where the material is defined.

Am i missing some library? Or is it some change in three.js? I am using r55. The code is the following:

Thank you!

var urlPrefix   = "images/skybox/";
var urls = [ 
urlPrefix + "skyboxmid.jpg", urlPrefix + "skyboxback.jpg",
urlPrefix + "skyboxleft.jpg", urlPrefix + "skyboxfront.jpg",
urlPrefix + "skyboxright.jpg", urlPrefix + "skyboxtop.jpg" ];

var textureCube = THREE.ImageUtils.loadTextureCube( urls );
var shader  = THREE.ShaderLib['normalmap'];
shader.uniforms["tNormal"].texture = textureCube;
var material = new THREE.MeshShaderMaterial({
    fragmentShader  : shader.fragmentShader,
    vertexShader    : shader.vertexShader,
    uniforms    : shader.uniforms
});

skybox  = new THREE.Mesh( new THREE.CubeGeometry( 100000, 100000, 100000, 1, 1, 1, null, true ), material );
scene.addObject( skybox ); 

1 Answer 1

10

It is now

new THREE.ShaderMaterial()

and

shader.uniforms["tNormal"].value = textureCube;

The Up and Running book you are using is out of date.

Search the three.js examples directory instead. There are other ways of creating skyboxes.

three.js r.55

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.