Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //修改 index.js
- function save( blob, filename ) {
- const url = URL.createObjectURL( blob );
- const link = document.createElement( 'a' );
- link.href = url;
- link.download = filename || 'data.json';
- link.style = 'display: none';
- document.body.appendChild( link );
- link.click();
- URL.revokeObjectURL( url );
- document.body.removeChild( link );
- }
- function saveArrayBuffer( buffer, filename ) {
- save( new Blob( [ buffer ], { type: 'application/octet-stream' } ), filename );
- }
- function saveString( text, filename ) {
- save( new Blob( [ text ], { type: 'text/plain' } ), filename );
- }
- const exportBtn = document.getElementById( 'export' );
- exportBtn.addEventListener( 'click', function() {
- let output = scene.toJSON();
- output = JSON.stringify( output, null, '\t' );
- output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
- saveString( output, 'scene.json' );
- });
- // 修改 index.css
- button#export {
- z-index: 10;
- position: absolute;
- left: 120px;
- }
- // 修改 index.html
- <button type="button" id="export">Export</button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement