josdirksen / learning-threejs

Code repository for the examples from the Packt book "Learning Threejs"
3.1k stars 1.27k forks source link

how to extrude multi path in one svg by d3,three.js,d3-threeD #19

Open liyihongcug opened 8 years ago

liyihongcug commented 8 years ago

Error is Uncaught TypeError: Cannot read property 'amount' of undefined !! I update chapter-06\05-extrude-svg.html. you can see below `

`

But It can't run. I am boring so that I can't make progress in this week. I hope you can help me.

All code are below: ` var shapearr=[]; var shape, svgString; var paths=document.querySelectorAll("svg > path[id]") for(var i = 0; i < paths.length; i++) { var path = paths[i]; svgString=path.getAttribute('d'); console.log(svgString); //shape = transformSVGPathExposed(svgString); shape=createMesh(new THREE.ShapeGeometry(drawShape2(svgString))); scene.add(shape); shapearr.push(shape); } ..... var controls = new function () { this.amount =6; //2; this.bevelThickness = 2; this.bevelSize = 0.5; this.bevelEnabled = true; this.bevelSegments = 3; this.bevelEnabled = true; this.curveSegments = 12; this.steps = 1; this.asGeom = function () { scene.remove(shape); var options = { amount: controls.amount, bevelThickness: controls.bevelThickness, bevelSize: controls.bevelSize, bevelSegments: controls.bevelSegments, bevelEnabled: controls.bevelEnabled, curveSegments: controls.curveSegments, steps: controls.steps };

            var paths=document.querySelectorAll("svg > path[id]")
            console.log(shapearr);
            for(var i = 0; i < paths.length; i++) {
                var path = paths[i];
                svgString=path.getAttribute('d');
                console.log(svgString);
               // shape = transformSVGPathExposed(svgString);
                shape=createMesh(new THREE.ExtrudeGeometry(drawShape2(svgString)),options);
                scene.add(shape);
            }
        };

    };

   ``
liyihongcug commented 8 years ago

I sovled the poblem .The answer is upper

ghost commented 7 years ago

@liyihongcug
could you show this result?

liyihongcug commented 7 years ago

codes are above . YOu can find it.