@@ -197,6 +197,31 @@ function exportObject(object, elements, obj::Modia3D.Composition.Object3D, coord
197197 return (r_obj, R_obj)
198198end
199199
200+ function exportObject (object, elements, obj:: Modia3D.Composition.Object3D , grid:: Modia3D.Shapes.Grid , initPos, initRot)
201+ r_obj = Modia3D. ZeroVector3D
202+ R_obj = Shapes. rotateAxis2z (grid. axis, Modia3D. NullRotation)
203+ name = Modia3D. fullName (obj)
204+ geometryName = name * " .geometry"
205+ array = []
206+ for i in 0 : div (grid. length+ 1e-12 , grid. distance)
207+ x = i * grid. distance - grid. length/ 2
208+ push! (array, x, - grid. width/ 2 , 0 )
209+ push! (array, x, grid. width/ 2 , 0 )
210+ end
211+ for i in 0 : div (grid. width+ 1e-12 , grid. distance)
212+ y = i * grid. distance - grid. width/ 2
213+ push! (array, - grid. length/ 2 , y, 0 )
214+ push! (array, grid. length/ 2 , y, 0 )
215+ end
216+ position = (; itemSize= 3 , type= " Float32Array" , array= array)
217+ geometry = (; name= geometryName, uuid= name2uuid (geometryName), type= " BufferGeometry" , data= (; attributes= (; position= position)))
218+ materialName = name * " .material"
219+ material = (; name= materialName, uuid= name2uuid (materialName), type= " LineBasicMaterial" , color= ((255 * 0 + 0 )* 256 + 255 ), linewidth= grid. lineWidth)
220+ objectInfo = getObjectInfo (name, geometry, material, initPos, initRot, type= " LineSegments" , R_obj= R_obj)
221+ printInfoToFile (object, elements, geometry, material, nothing , objectInfo)
222+ return (r_obj, R_obj)
223+ end
224+
200225function printInfoToFile (object, elements, geometry, material, shape, objectInfo)
201226 push! (elements. geometries, geometry)
202227 if ! isnothing (material)
@@ -249,8 +274,8 @@ function getObjectInfoMesh(obj, initPos, initRot, scale, R_obj, meshInfo)
249274 return meshInfo
250275end
251276
252- function getObjectInfo (name, geometry, material, initPos, initRot; r_obj= Modia3D. ZeroVector3D, R_obj= Modia3D. NullRotation, scale= ones (3 ))
253- return (; name= name, uuid= name2uuid (name), type= :Mesh , geometry= get (geometry, :uuid , nothing ), material= get (material, :uuid , " " ), position= initPos+ initRot' * r_obj, rotation= Modia3D. rot123fromR (R_obj* initRot), scale= scale)
277+ function getObjectInfo (name, geometry, material, initPos, initRot; type = " Mesh " , r_obj= Modia3D. ZeroVector3D, R_obj= Modia3D. NullRotation, scale= ones (3 ))
278+ return (; name= name, uuid= name2uuid (name), type= type , geometry= get (geometry, :uuid , nothing ), material= get (material, :uuid , " " ), position= initPos+ initRot' * r_obj, rotation= Modia3D. rot123fromR (R_obj* initRot), scale= scale)
254279end
255280
256281printVisuMaterialToJSON (obj, visuMaterial) = nothing
@@ -302,6 +327,10 @@ function printObjectToJSON(object, elements, obj; initPos=obj.r_abs, initRot=obj
302327 coordinateSystem:: Modia3D.Shapes.CoordinateSystem = obj. shape
303328 (r_obj, R_obj) = exportObject (object, elements, obj, coordinateSystem, initPos, initRot)
304329
330+ elseif shapeKind == Modia3D. GridKind
331+ grid:: Modia3D.Shapes.Grid = obj. shape
332+ (r_obj, R_obj) = exportObject (object, elements, obj, grid, initPos, initRot)
333+
305334 elseif shapeKind == Modia3D. FileMeshKind
306335 fileMesh:: Modia3D.Shapes.FileMesh = obj. shape
307336 (r_obj, R_obj) = exportObject (object, elements, obj, fileMesh, initPos, initRot)
0 commit comments