Skip to content

Commit 35e5c70

Browse files
committed
export extremely large jsons
1 parent cc06a10 commit 35e5c70

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

editor/js/Menubar.File.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ Menubar.File = function ( editor ) {
8686
}
8787

8888
var output = geometry.toJSON();
89-
output = JSON.stringify( output, null, '\t' );
90-
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
89+
try {
90+
output = JSON.stringify( output, null, '\t' );
91+
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
92+
} catch ( oops ) {
93+
output = JSON.stringify( output );
94+
}
9195

9296
exportString( output, 'geometry.json' );
9397

@@ -111,8 +115,12 @@ Menubar.File = function ( editor ) {
111115
}
112116

113117
var output = object.toJSON();
114-
output = JSON.stringify( output, null, '\t' );
115-
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
118+
try {
119+
output = JSON.stringify( output, null, '\t' );
120+
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
121+
} catch ( oops ) {
122+
output = JSON.stringify( output );
123+
}
116124

117125
exportString( output, 'model.json' );
118126

@@ -127,8 +135,12 @@ Menubar.File = function ( editor ) {
127135
option.onClick( function () {
128136

129137
var output = editor.scene.toJSON();
130-
output = JSON.stringify( output, null, '\t' );
131-
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
138+
try {
139+
output = JSON.stringify( output, null, '\t' );
140+
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
141+
} catch ( oops ) {
142+
output = JSON.stringify( output );
143+
}
132144

133145
exportString( output, 'scene.json' );
134146

0 commit comments

Comments
 (0)