From 9d067e5e884dd119977c2e85b2c954557930e945 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 11 Apr 2013 11:23:39 -0300 Subject: [PATCH] Arch: fixed errors in webgl exporter --- src/Mod/Arch/importWebGL.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Mod/Arch/importWebGL.py b/src/Mod/Arch/importWebGL.py index a8a8c4a2c..dbb49b7d9 100644 --- a/src/Mod/Arch/importWebGL.py +++ b/src/Mod/Arch/importWebGL.py @@ -110,6 +110,38 @@ def getObjectData(obj): # print result return result + elif obj.isDerivedFrom("Mesh::Feature"): + mesh = obj.Mesh + result = "var geom = new THREE.Geometry();\n" + + # adding vertices data + for p in mesh.Points: + v = p.Vector + i = p.Index + result += tab+"var v"+str(i)+" = new THREE.Vector3("+str(v.x)+","+str(v.y)+","+str(v.z)+");\n" + result += tab+"console.log(geom.vertices)\n" + for p in mesh.Points: + result += tab+"geom.vertices.push(v"+str(p.Index)+");\n" + + # adding facets data + for f in mesh.Facets: + result += tab+"geom.faces.push( new THREE.Face3"+str(f.PointIndices)+" );\n" + + # adding material + col = obj.ViewObject.ShapeColor + rgb = Draft.getrgb(col,testbw=False) + #rgb = "#888888" # test color + result += tab+"var material = new THREE.MeshBasicMaterial( { color: 0x"+str(rgb)[1:]+" } );\n" + + # adding the mesh to the scene + result += tab+"var mesh = new THREE.Mesh( geom, material );\n" + result += tab+"scene.add( mesh );\n"+tab + + # print result + return result + + return "" + def getTestData(): "returns a simple cube as three.js snippet"