Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        THREE.Geometry geometry;

        AddRenderObject(new THREE.SphereGeometry(75, 20, 10), material, new Vector3(-400, 0, 200));

        AddRenderObject(new THREE.IcosahedronGeometry(75, 1), material, new Vector3(-200, 0, 200));

        AddRenderObject(new THREE.OctahedronGeometry(75, 2), material, new Vector3(0, 0, 200));

        AddRenderObject(new THREE.TetrahedronGeometry(75, 0), material, new Vector3(200, 0, 200));

        AddRenderObject(new THREE.PlaneGeometry(100, 100, 4, 4), material, new Vector3(-400, 0, 0));

        geometry = AddRenderObject(new THREE.BoxGeometry(100, 100, 100, 4, 4, 4), material, new Vector3(-200, 0, 0));

        AddRenderObject(new THREE.CircleGeometry(50, 20, 0, Mathf.PI * 2), material, new Vector3(0, 0, 0));

        AddRenderObject(new THREE.RingGeometry(10, 50, 20, 5, 0, Mathf.PI * 2), material, new Vector3(200, 0, 0));

        AddRenderObject(new THREE.CylinderGeometry(25, 75, 100, 40, 5, false), material, new Vector3(400, 0, 0));

        //
        List <Vector3> points = new List <Vector3>();

        for (var i = 0; i < 50; i++)
        {
            points.Add(new Vector3(Mathf.Sin(i * 0.2f) * Mathf.Sin(i * 0.1f) * 15 + 50, 0, (i - 5) * 2));
        }
        AddRenderObject(new THREE.LatheGeometry(points, 20), material, new Vector3(-400, 0, -200));

        AddRenderObject(new THREE.TorusGeometry(50, 20, 20, 20), material, new Vector3(-200, 0, -200));

        AddRenderObject(new THREE.TorusKnotGeometry(50, 10, 50, 20), material, new Vector3(0, 0, -200));


        THREE.Line     lineMesh = new THREE.Line(new THREE.Geometry(), wireMaterial);
        THREE.Geometry geo      = geometry;
        for (int i = 0; i < geo.faces.Count; i++)
        {
            THREE.Face3 _face = geo.faces[i];
            List <int>  tri   = _face.GetTriangles();

            for (int n = 0; n < tri.Count; n++)
            {
                Vector3           normal = _face.vertexNormals[n];
                THREE.ArrowHelper arrow  = new THREE.ArrowHelper(normal, geo.vertices[tri[n]], 10, Color.green);
                lineMesh.Add(arrow);
            }
        }

        AddRenderLineObject(lineMesh.geo, wireMaterial, new Vector3(-200, 0, 0));
    }
    // Use this for initialization
    protected override void Init()
    {
        base.Init();

        THREE.MeshThreeJs drawNormalMesh;

        THREE.MeshThreeJs threeMesh;
        threeMesh          = new THREE.MeshThreeJs(new THREE.SphereGeometry(75, 20, 10), material);
        threeMesh.position = new Vector3(-400, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.IcosahedronGeometry(75, 1), material);
        threeMesh.position = new Vector3(-200, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.OctahedronGeometry(75, 2), material);
        threeMesh.position = new Vector3(0, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.TetrahedronGeometry(75, 0), material);
        threeMesh.position = new Vector3(200, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.PlaneGeometry(100, 100, 4, 4), material);
        threeMesh.position = new Vector3(-400, 0, 0);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.BoxGeometry(100, 100, 100, 4, 4, 4), material);
        threeMesh.position = new Vector3(-200, 0, 0);
        scene.Add(threeMesh);

        drawNormalMesh = threeMesh;         // Draw Normal Mesh

        threeMesh          = new THREE.MeshThreeJs(new THREE.CircleGeometry(50, 20, 0, Mathf.PI * 2), material);
        threeMesh.position = new Vector3(0, 0, 0);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.RingGeometry(10, 50, 20, 5, 0, Mathf.PI * 2), material);
        threeMesh.position = new Vector3(200, 0, 0);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.CylinderGeometry(25, 75, 100, 40, 5, false), material);
        threeMesh.position = new Vector3(400, 0, 0);
        scene.Add(threeMesh);


        //
        List <Vector3> points = new List <Vector3>();

        for (var i = 0; i < 50; i++)
        {
            points.Add(new Vector3(Mathf.Sin(i * 0.2f) * Mathf.Sin(i * 0.1f) * 15 + 50, 0, (i - 5) * 2));
        }

        threeMesh          = new THREE.MeshThreeJs(new THREE.LatheGeometry(points, 20), material);
        threeMesh.position = new Vector3(-400, 0, -200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.TorusGeometry(50, 20, 20, 20), material);
        threeMesh.position = new Vector3(-200, 0, -200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.TorusKnotGeometry(50, 10, 50, 20), material);
        threeMesh.position = new Vector3(0, 0, -200);
        scene.Add(threeMesh);

        /*
         * threeMesh = new THREE.AxisHelper( 50 );
         * threeMesh.position.set( 200, 0, -200 );
         * scene.Add( threeMesh );
         *
         * threeMesh = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );
         * threeMesh.position.set( 400, 0, -200 );
         * scene.Add( threeMesh );
         */

        THREE.Line lineMesh = new THREE.Line(new THREE.Geometry(), wireMaterial);
        lineMesh.position = drawNormalMesh.position;

        THREE.Geometry geo = drawNormalMesh.geo;
        for (int i = 0; i < geo.faces.Count; i++)
        {
            THREE.Face3 _face = geo.faces[i];
            int[]       tri   = _face.GetTriangles();

            for (int n = 0; n < tri.Length; n++)
            {
                Vector3           normal = _face.vertexNormals[n];
                THREE.ArrowHelper arrow  = new THREE.ArrowHelper(normal, geo.vertices[tri[n]], 10, Color.green);
                lineMesh.Add(arrow);
            }
        }

        scene.Add(lineMesh);
    }