Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with custom geometry and face normal #2030

Closed
lucboutier opened this issue Jun 4, 2012 · 1 comment
Closed

Issue with custom geometry and face normal #2030

lucboutier opened this issue Jun 4, 2012 · 1 comment

Comments

@lucboutier
Copy link

Hi,

I'm quite new to ThreeJS and I have a small issue (probably wrong usage). I'm trying to create a custom geometry and define the faces normals by myself.

I create one normal in one direction and the other one in the opposite direction, as my Mesh is not 2 sided I expect to see only one of the face, however I can see both of them... Any Idea of what I'm doing wrong ?

Thanks!

    <body>

        <script src="../build/Three.js"></script>

        <script src="js/Stats.js"></script>

        <script>
            var container, stats;

            var camera, scene, renderer;


                container = document.createElement( 'div' );
                document.body.appendChild( container );

                scene = new THREE.Scene();

                camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
                camera.up.x = 0;
                camera.up.y = 0;
                camera.up.z = 1;

                camera.position.x = 300;
                camera.position.y = -1000;
                camera.position.z = 1000;

                camera.lookAt(new THREE.Vector3(300, 250, 0));
                scene.add( camera );

                var light, geometry, material;

                scene.add( new THREE.AmbientLight( 0x404040 ) );

                light = new THREE.DirectionalLight( 0xffffff );
                light.position.set( 0, 1, 0 );
                scene.add( light );

                material = new THREE.MeshBasicMaterial( { color: 0xFFFF00, wireframe: false, transparent: false, opacity: 1 } );

                geometry = new THREE.Geometry();
                geometry.vertices.push(new THREE.Vector3(0,0,0));
                geometry.vertices.push(new THREE.Vector3(600,0,0));
                geometry.vertices.push(new THREE.Vector3(0,-500,0));
                geometry.vertices.push(new THREE.Vector3(600,-500,0));
                var face;

                face = new THREE.Face3(0,2,1);
                face.normal.set(0,0,-1);
                geometry.faces.push(face);
                face = new THREE.Face3(2,3,1);
                face.normal.set(0,0,1);
                geometry.faces.push(face);

                geometry.computeCentroids();
                //geometry.computeFaceNormals();
                //geometry.computeTangents();

                var mesh = new THREE.Mesh(geometry, material);

                scene.add(mesh);

                renderer = new THREE.WebGLRenderer( { antialias: true } );
                renderer.setSize( window.innerWidth, window.innerHeight );

                container.appendChild( renderer.domElement );

                renderer.render( scene, camera );


        </script>

    </body>
``
@mrdoob
Copy link
Owner

mrdoob commented Jun 4, 2012

#1979

@mrdoob mrdoob closed this as completed Jun 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants