@@ -19,18 +19,25 @@ export class NBTExporter extends IExporter {
1919 } ;
2020 }
2121
22- private _processChunk ( blockMesh : BlockMesh , min : Vector3 , blockNameToIndex : Map < string , number > , palette : any ) : Buffer {
22+ private _processChunk ( blockMesh : BlockMesh , minOr : Vector3 | "doNotConstrain" , blockNameToIndex : Map < string , number > , palette : any ) : Buffer {
23+ const constrainToChunkSize = minOr !== "doNotConstrain" ;
24+ const totalBounds = blockMesh . getVoxelMesh ( ) . getBounds ( ) ;
25+ const min = constrainToChunkSize ? minOr as Vector3 : totalBounds . min ;
26+
2327 const blocks : any [ ] = [ ] ;
2428 for ( const block of blockMesh . getBlocks ( ) ) {
2529 const pos = block . voxel . position ;
2630 const blockIndex = blockNameToIndex . get ( block . blockInfo . name ) ;
2731
2832 if ( blockIndex !== undefined ) {
29- if ( pos . x >= min . x && pos . x < min . x + 48 && pos . y >= min . y && pos . y < min . y + 48 && pos . z >= min . z && pos . z < min . z + 48 ) {
33+ if ( ! constrainToChunkSize || pos . x >= min . x && pos . x < min . x + 48 && pos . y >= min . y && pos . y < min . y + 48 && pos . z >= min . z && pos . z < min . z + 48 ) {
3034 const translatedPos = Vector3 . sub ( block . voxel . position , min ) ;
31- ASSERT ( translatedPos . x >= 0 && translatedPos . x < 48 ) ;
32- ASSERT ( translatedPos . y >= 0 && translatedPos . y < 48 ) ;
33- ASSERT ( translatedPos . z >= 0 && translatedPos . z < 48 ) ;
35+
36+ if ( constrainToChunkSize ) {
37+ ASSERT ( translatedPos . x >= 0 && translatedPos . x < 48 ) ;
38+ ASSERT ( translatedPos . y >= 0 && translatedPos . y < 48 ) ;
39+ ASSERT ( translatedPos . z >= 0 && translatedPos . z < 48 ) ;
40+ }
3441
3542 blocks . push ( {
3643 pos : {
@@ -48,7 +55,7 @@ export class NBTExporter extends IExporter {
4855 }
4956 }
5057 }
51- ASSERT ( blocks . length < 48 * 48 * 48 ) ;
58+ ASSERT ( ! constrainToChunkSize || blocks . length < 48 * 48 * 48 ) ;
5259
5360 const nbt : NBT = {
5461 type : TagType . Compound ,
@@ -62,7 +69,7 @@ export class NBTExporter extends IExporter {
6269 type : TagType . List ,
6370 value : {
6471 type : TagType . Int ,
65- value : [ 48 , 48 , 48 ] ,
72+ value : constrainToChunkSize ? [ 48 , 48 , 48 ] : totalBounds . getDimensions ( ) . add ( 1 ) . toArray ( ) ,
6673 } ,
6774 } ,
6875 palette : {
@@ -119,6 +126,10 @@ export class NBTExporter extends IExporter {
119126 }
120127 }
121128
129+ const full_region_buffer = this . _processChunk ( blockMesh , "doNotConstrain" , blockNameToIndex , palette ) ;
130+ regions . push ( { content : full_region_buffer , name : `full` } ) ;
131+
132+
122133 const out : TStructureExport = {
123134 type : 'multiple' ,
124135 extension : '.nbt' ,
0 commit comments