0

したがって、ユーザーの目的のディメンションを生成し、カスタマイズされた .csv ファイルに表示するこのコードがありますnew THREE.Geometry()。これは、ほとんどの人にとって話題から外れているかもしれません。でもねえ、私はThree.jsを初めて使ったばかりです

私の問題は次のとおりです。

  • を挿入する方法が見つかりませんgeometry.morphTargets。または単に、適切な使用方法がわからない

だからここに私のコードがあります:

   //custom Object height and width
    customHeightWidth(customWidth, customHeight);

       function customHeightWidth(width, height){

        material = new THREE.MeshBasicMaterial({
        map: THREE.ImageUtils.loadTexture(uploadedFile),
        side: THREE.DoubleSide,
        overdraw: true,
        wireframe: false
        });
    //objects
     combined = new THREE.PlaneGeometry(width, height, 30, 10);

     geometry = new THREE.Geometry();

     geometry.name: "target1", vertices.push( new THREE.Vector3( -(width),  height, 0 ) );
     geometry.name: "target2", vertices.push( new THREE.Vector3( -(width), -(height), 0 ) );
     geometry.name: "target3", vertices.push( new THREE.Vector3(  width, -(height), 0 ) );

     geometry.computeBoundingSphere();
     geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );

     geometry1 = new THREE.Geometry();

     geometry1.vertices.push( new THREE.Vector3( width,  height, 0 ) );
     geometry1.vertices.push( new THREE.Vector3( -(width), height, 0 ) );
     geometry1.vertices.push( new THREE.Vector3(  width, -(height), 0 ) );
     geometry1.computeBoundingSphere();

     geometry1.faces.push( new THREE.Face3( 0, 1, 2 ) );

      // 1st box
        var mesh1 = new THREE.Mesh(geometry);
        var mesh2 = new THREE.Mesh(geometry1);

            //activating the meshs
        THREE.GeometryUtils.merge(combined, mesh1);
        THREE.GeometryUtils.merge(combined, mesh2);


             mesh = new THREE.Mesh(combined, material);
         this.scene.add(mesh);
        };
          }

       var animate = function() {
       requestAnimationFrame(animate);
       //mesh.rotation.x += 0.01; 
       //mesh.rotation.y -= 0.006;
       renderer.render(scene, camera);
       }

 init();
 animate();
4

2 に答える 2

0

//モーフターゲットの読み取り

for(i=o;i<geometry.morphTargets.length;i++) {
morphTargets = geometry.morphTargets[i].vertices;
return morphTargets;
}

//モーフターゲットのロード

loadMorphTargets = function (morphTargets) {
        if (morphTargets !== undefined) {
            var i, l, v, vl, dstVertices, srcVertices;
            //for (i = 0, l = morphTargets.length; i < l; i++) {
            geometry.morphTargets[i] = {};
            geometry.morphTargets[i].name = morphTargets.name;
            geometry.morphTargets[i].vertices = [];
            var dstVertices = geometry.morphTargets[i].vertices;
            var srcVertices = morphTargets.vertices;
            for (v = 0, vl = srcVertices.length; v < vl; v += 3) {
                var vertex = new THREE.Vector3();
                vertex.x = srcVertices[ v ];
                vertex.y = srcVertices[ v + 1 ];
                vertex.z = srcVertices[ v + 2 ];
                dstVertices.push(vertex);
            }
        }
    };

私はそれがあなたに役立つと思います。

于 2016-10-26T11:43:14.987 に答える