简体   繁体   中英

interactive liquid metal ball with Three.js

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

Today I am watching the tutorial of Paul Lewis to make an interactive liquid metal ball with Three.js like this one http://lab.aerotwist.com/webgl/reactive-ball/

I was asking me if it's possible to make it with an external model using the ThreeBinaryLoader. I change the code to this http://codepen.io/gnazoa/pen/wKVLNG but it doesn't work because I have a syntax error here

sphereGeometry = loader.load( 
    "sources/obj/mmlogo/mm_logo.js", 
    function(
      200,      // radius
      60,       // resolution x
      30);      // resolution y

So I tryed with another syntax:

var loader = new THREE.BinaryLoader();
            loader.load( "sources/obj/mmlogo/mm_logo.js", function ( sphereGeometry ) {

                var material = new THREE.MeshPhongMaterial( {
                    color: 0x515151,
                    morphTargets: true,
                    overdraw: 0.5,
                    envMap: reflectionCube,
                    combine: THREE.AddOperation,
                    reflectivity: 1,
                    shininess: 0,
                    side: THREE.DoubleSide,
                } );

And I am still with same syntax problem.

I know that maybe is something really simple but for me have been very hard because I am learning and this something really complex.

Do you know if it's possible to make it with a correct syntax?

Try this:

var loader = new THREE.BinaryLoader();
loader.load( "sources/obj/mmlogo/mm_logo.js", function ( sphereGeometry ) {

    var material = new THREE.MeshPhongMaterial( {
        color: 0x515151,
        morphTargets: true,
        overdraw: 0.5,
        envMap: reflectionCube,
        combine: THREE.AddOperation,
        reflectivity: 1,
        shininess: 0,
        side: THREE.DoubleSide
    } );
});

You have forgotten to close Your function with }); . I wloud suggest using some IDE with syntax checking. Run time errors in Javascript will give You enough fun. ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM