@@ -14,6 +14,7 @@ import {
1414 Bounds3 ,
1515 bounds3Merge ,
1616 bounds3Center ,
17+ vec3Add ,
1718} from "../../abstract-3d.js" ;
1819import { dxf , Handle } from "./dxf-encoding.js" ;
1920import { dxfPlane } from "./dxf-geometries/dxf-plane.js" ;
@@ -38,7 +39,7 @@ export function renderScenes(scenes: ReadonlyArray<DxfScene>, baseOptions?: Opti
3839 const { groups } = dxfGroups (
3940 view . scene ,
4041 { ...baseOptions , ...view . options , view : undefined , origin : "Center" } ,
41- view . pos ,
42+ vec3Add ( view . pos , view . scene . center_deprecated ?? vec3Zero ) ,
4243 handle
4344 ) ;
4445 allGroups += groups ;
@@ -53,14 +54,16 @@ export const render = (scene: Scene, options?: Optional<DxfOptions>): string =>
5354 const bounds = bounds3FromPosAndSize ( center , scene . size_deprecated ) ;
5455 const offset =
5556 options ?. origin === "Center" ? vec3Zero : vec3 ( Math . abs ( bounds . min . x ) , Math . abs ( bounds . min . y ) , - bounds . max . z ) ;
56- const res = dxfGroups ( scene , options , offset , { handle : 0x1000 } ) ;
57+ const res = dxfGroups ( { ...scene , groups : [ group ( [ ] , offset , vec3Zero , scene . groups ) ] } , options , center , {
58+ handle : 0x1000 ,
59+ } ) ;
5760 return dxf ( res . groups , center , scene . size_deprecated ) ;
5861} ;
5962
6063const dxfGroups = (
6164 scene : Scene ,
6265 options : Optional < DxfOptions > | undefined ,
63- offset : Vec3 ,
66+ center : Vec3 ,
6467 handleRef : Handle //make sure we start with a value higher than any other handle id's used in the header
6568) : { readonly groups : string } => {
6669 const opts : DxfOptions = {
@@ -69,9 +72,7 @@ const dxfGroups = (
6972 cylinderSideCount : DEFAULT_CYLINDER_SIDE_COUNT ,
7073 } ;
7174 const unitRot = vec3RotCombine ( rotationForCameraPos ( opts . view ) , scene . rotation_deprecated ?? vec3Zero ) ;
72- const center = scene . center_deprecated ?? vec3Zero ;
73- const groupRoot = group ( [ ] , offset , vec3Zero , scene . groups ) ;
74- return { groups : dxfGroup ( groupRoot , center , unitRot , opts , handleRef ) } ;
75+ return { groups : scene . groups . reduce ( ( a , c ) => a + dxfGroup ( c , center , unitRot , opts , handleRef ) , "" ) } ;
7576} ;
7677
7778function dxfGroup ( g : Group , parentPos : Vec3 , parentRot : Vec3 , options : DxfOptions , handleRef : Handle ) : string {
0 commit comments