0

I am making my first steps coding with JavaScript and playing with Three.js.

I was exploring and I found an amazing tutorial of Paul Lewis to make an interactive liquid sphere. Here is the codepen that I made http://codepen.io/gnazoa/pen/ZQzEqX

I am trying to change the code to animate an external model that I am loading using the Binary Loader. I have the following code but it doesn't work http://codepen.io/gnazoa/pen/MKgWxE.

The google chrome JavaScript console tells that there is a syntax error in this function

function createObjects() {
    var numberOfImages = 46,
        images = [];

    for (var i = 1; i <= numberOfImages; i++) {
        images.push('sources/instagram2/image' + i + ".jpg");
    }

    var urls = images.sort(function () {
        return .6 - Math.random()
    }).slice(0, 6);

    textureCube = THREE.ImageUtils.loadTextureCube(urls);
    var loader = new THREE.BinaryLoader();
    loader.load("https://raw.githubusercontent.com/mrdoob/three.js/master/examples/obj/walt/WaltHead_bin.js", function ( Geometry ) {
        var Material = new THREE.MeshLambertMaterial({
            color: 0xEEEEEE,
            envMap: textureCube,
            shininess: 200,
            shading: THREE.SmoothShading,
        });

        sphere = new THREE.Mesh(Geometry, Material);
        sphere.geometry.dynamic = true;
        sphere.position.y = 0;
        scene.add(sphere);
    });

    lightFront = new THREE.PointLight(0xFFFFFF, 1.5);
    lightFront.position.y = 400;
    scene.add(lightFront);

    // and another from the bottom
    lightBottom = new THREE.DirectionalLight(0xFFFFFF, 1.3);
    lightBottom.position.y = -240;
    scene.add(lightBottom);
}

I have one week watching tutorials and reading books to solve this problem and I can't do it. I know that maybe is something really easy for an experimented person so if you can give me a conseil it would be amazing.

Thank you very much

WestLangley
  • 102,557
  • 10
  • 276
  • 276
Gabriel Nazoa
  • 229
  • 4
  • 16
  • the loader.load line has an error (the string is outside the "") – drys Dec 01 '15 at 16:22
  • Remove one of the doubled quotes `""` on each site of the url – Andreas Dec 01 '15 at 16:24
  • Thank you @drys. But even if I changed this detail the code doesn't work. The javaScript console tells me the same error. – Gabriel Nazoa Dec 01 '15 at 16:27
  • Thank you @Andreas But even if I changed this detail the code doesn't work. The javaScript console tells me the same error. – Gabriel Nazoa Dec 01 '15 at 16:31
  • The codepen does not show a syntax error on my side... it fails to load a script now. Because of that, you do not have the desired functions and objects defined. – drys Dec 01 '15 at 16:37
  • this might help http://stackoverflow.com/questions/17341122/link-and-execute-external-javascript-file-hosted-on-github – drys Dec 01 '15 at 16:42
  • Thank you very much @drys I'm solving it. But I don't think that it is the problem because I have all the files on my computer with all the correct links and it shows me a syntax error. – Gabriel Nazoa Dec 01 '15 at 16:49
  • I already fixed the problem. Codepen is correctly loading the script. But The same syntax problem in the function that I sowed you still happening. – Gabriel Nazoa Dec 01 '15 at 16:59
  • @drys please help me – Gabriel Nazoa Dec 01 '15 at 17:14

0 Answers0