问题
I need to export Three Geometry to JSON so I can used with xml3D.
I am trying to find the THREE.GeometryExporter() but I can't. Has it been completely deprecated? It is mentioned here
Once I have the Three JSON I should be able to use this converter to obtain the xml3D JSON.
Has anyone tried this before?
回答1:
You should try the toJSON()
method :
var json = geometry.toJSON();
This method is available for geometries, materials, lights, mesh ...
回答2:
Realease 68 seems to be the last one with GeometyExporter in the examples folder. https://github.com/mrdoob/three.js/tree/r68/examples/js/exporters
Not sure how you expect it to output to xml3D format (I've never tried it), though it should not be too hard to alter if need be.
This three.js json to xml3d converter may come in handy. https://github.com/xml3d/threejs-to-xml3d
回答3:
geometry.toJSON()
wasn't outputting the information in the format I needed to do something similar. My solution was the following:
cannonPoints = geometry.vertices.map(function(v) {
return new CANNON.Vec3( v.x, v.y, v.z )
})
cannonFaces = geometry.faces.map(function(f) {
return [f.a, f.b, f.c]
})
I shared this solution on a similar problem here: Create CANNON.RigidBody from THREE.Mesh or THREE.Geometry
来源:https://stackoverflow.com/questions/30959385/export-threejs-geometry-to-json