fix discard new sketch and render on load
This commit is contained in:
parent
4e68e61b67
commit
0258bb39bd
File diff suppressed because one or more lines are too long
@ -26,7 +26,6 @@ export default async (
|
||||
throwIfExistingHandleNotGood = false
|
||||
) => {
|
||||
options.fileName = options.fileName || 'Untitled';
|
||||
console.log(options.fileName,"ddddddddddd")
|
||||
const accept = {};
|
||||
if (options.mimeTypes) {
|
||||
options.mimeTypes.push(blob.type);
|
||||
|
@ -74,9 +74,9 @@ export const Dialog = () => {
|
||||
}
|
||||
|
||||
const sketchCancel = () => {
|
||||
if (sc.activeSketch.hasChanged
|
||||
|| sc.activeSketch.idOnActivate != id
|
||||
|| sc.activeSketch.c_idOnActivate != sc.activeSketch.c_id
|
||||
if (!sc.activeSketch.hasChanged
|
||||
&& sc.activeSketch.idOnActivate == id
|
||||
&& sc.activeSketch.c_idOnActivate == sc.activeSketch.c_id
|
||||
) {
|
||||
if (sc.newSketch) {
|
||||
dispatch({ type: 'delete-node', id: sc.activeSketch.obj3d.name })
|
||||
|
@ -55,11 +55,11 @@ export const DropDown = () => {
|
||||
</div>
|
||||
{
|
||||
open &&
|
||||
<div className="absolute drop-down-top w-full p-1 rounded bg-gray-700"
|
||||
<div className="absolute drop-down-top -left-10 w-48 p-1 rounded bg-gray-700"
|
||||
onClick={handleInsideClick}
|
||||
>
|
||||
{arr.map(([url, name], idx) => (
|
||||
<div className="w-auto h-8 p-0.5 flex items-center bg-transparent text-gray-200
|
||||
<div className="w-full h-8 p-0.5 flex items-center bg-transparent text-gray-200
|
||||
hover:bg-gray-500 "
|
||||
key={idx}
|
||||
>
|
||||
|
@ -1,14 +1,14 @@
|
||||
|
||||
|
||||
import {
|
||||
fileOpen,
|
||||
fileSave,
|
||||
} from '../../extlib/fs/index';
|
||||
|
||||
// import {
|
||||
// fileOpen,
|
||||
// fileSave,
|
||||
// } from 'browser-fs-access';
|
||||
// } from '../../extlib/fs/index';
|
||||
|
||||
import {
|
||||
fileOpen,
|
||||
fileSave,
|
||||
} from 'browser-fs-access';
|
||||
|
||||
// https://web.dev/file-system-access/
|
||||
|
||||
@ -46,56 +46,12 @@ export async function saveFile(fileHandle, file, dispatch) {
|
||||
}
|
||||
};
|
||||
|
||||
// export async function saveFileAs(file, dispatch) {
|
||||
|
||||
|
||||
// try {
|
||||
// console.log('heeeeeeeeeeeeeer')
|
||||
// const fileHandle = await fileSave(new Blob([file], { type: 'application/json' }), {
|
||||
// fileName: 'unamed',
|
||||
// extensions: ['.json'],
|
||||
// })
|
||||
|
||||
// dispatch({ type: 'set-file-handle', fileHandle, modified: false })
|
||||
|
||||
// } catch (ex) {
|
||||
|
||||
// const msg = 'Unable to save file.';
|
||||
// console.error(msg, ex);
|
||||
// alert(msg);
|
||||
// return;
|
||||
// }
|
||||
// };
|
||||
|
||||
export async function saveFileAs(file, dispatch) {
|
||||
let fileHandle;
|
||||
try {
|
||||
|
||||
const opts = {
|
||||
suggestedName: 'test',
|
||||
types: [{
|
||||
description: 'Text file',
|
||||
accept: { 'application/json': ['.json'] },
|
||||
}],
|
||||
};
|
||||
fileHandle = await showSaveFilePicker(opts)
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
if (ex.name === 'AbortError') {
|
||||
console.log('aborted')
|
||||
return;
|
||||
}
|
||||
const msg = 'An error occured trying to open the file.';
|
||||
console.error(msg, ex);
|
||||
alert(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const writable = await fileHandle.createWritable();
|
||||
await writable.write(file);
|
||||
await writable.close()
|
||||
const fileHandle = await fileSave(new Blob([file], { type: 'application/json' }), {
|
||||
extensions: ['.json'],
|
||||
})
|
||||
|
||||
dispatch({ type: 'set-file-handle', fileHandle, modified: false })
|
||||
|
||||
@ -109,6 +65,7 @@ export async function saveFileAs(file, dispatch) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
export async function openFile(dispatch) {
|
||||
let file
|
||||
|
||||
|
@ -51,7 +51,7 @@ export const NavBar = () => {
|
||||
const addSketch = () => {
|
||||
const sketch = sc.addSketch()
|
||||
if (!sketch) {
|
||||
alert('please select a plane or 3 points to define sketch plane')
|
||||
alert('please select a plane or 3 points to set the sketch plane')
|
||||
return
|
||||
}
|
||||
|
||||
@ -106,9 +106,9 @@ export const NavBar = () => {
|
||||
dispatch({ type: 'set-dialog', action: 'extrude', target: sc.activeSketch })
|
||||
|
||||
}, 'Extrude'],
|
||||
[Icon.Dimension, () => sc.activeSketch.command('d'), 'Dimension (D)'],
|
||||
[Icon.Line, () => sc.activeSketch.command('l'), 'Line (L)'],
|
||||
[Icon.Arc, () => sc.activeSketch.command('a'), 'Arc (A)'],
|
||||
[Icon.Dimension, () => sc.activeSketch.command('d'), 'Dimension (D)'],
|
||||
[Icon.Coincident, () => sc.activeSketch.command('c'), 'Coincident (C)'],
|
||||
[Icon.Vertical, () => sc.activeSketch.command('v'), 'Vertical (V)'],
|
||||
[Icon.Horizontal, () => sc.activeSketch.command('h'), 'Horizontal (H)'],
|
||||
@ -124,10 +124,10 @@ export const NavBar = () => {
|
||||
const partModeButtons = [
|
||||
[FaEdit, addSketch, 'Sketch'],
|
||||
[Icon.Extrude, () => {
|
||||
console.log(treeEntries.byId[sc.selected[0].name], 'here')
|
||||
if (sc.selected[0] && treeEntries.byId[sc.selected[0].name].obj3d) {
|
||||
try {
|
||||
dispatch({ type: 'set-dialog', action: 'extrude', target: treeEntries.byId[sc.selected[0].name] })
|
||||
} else {
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
alert('please select a sketch from the left pane extrude')
|
||||
}
|
||||
|
||||
@ -187,8 +187,7 @@ export const NavBar = () => {
|
||||
))
|
||||
}
|
||||
</div>
|
||||
{/* <div className='w-auto h-full flex-1 items-center justify-end flex-shrink-1 hidden lg:flex'> */}
|
||||
<div className='w-auto h-full flex-1 items-center justify-end flex-shrink-1 flex'>
|
||||
<div className='w-auto h-full flex-1 items-center justify-end flex-shrink-1 hidden lg:flex'>
|
||||
<DropDown />
|
||||
<a href='https://github.com/twpride/threeCAD' className='h-full w=auto'>
|
||||
<FaGithub className="btn-green w-auto h-full p-3.5"></FaGithub>
|
||||
|
@ -12,7 +12,7 @@ export const Tree = () => {
|
||||
|
||||
return <div className='sideNav flex flex-col bg-gray-800'>
|
||||
<div className='w-full text-gray-50 h-9 text-lg mx-1 border-0 flex items-center focus:outline-none bg-transparent'>
|
||||
{fileHandle ? fileHandle.name.replace(/\.[^/.]+$/, "") : 'untitled'}
|
||||
{fileHandle ? fileHandle.name.replace(/\.[^/.]+$/, "") : 'Untitled'}
|
||||
</div>
|
||||
{treeEntries.allIds.map((entId, idx) => (
|
||||
<TreeEntry key={idx} entId={entId} />
|
||||
|
2
todo.txt
2
todo.txt
@ -38,6 +38,7 @@ file save, stl export// done
|
||||
seperate scene from init logic only init cam and rendere // not an issue , ended up just splicing (1)
|
||||
add download button, different from save button // done
|
||||
- vertical and horzontal baseline to dimension to / or just smart ordinate dir dimenensing // done
|
||||
- auto snap done
|
||||
|
||||
|
||||
|
||||
@ -53,7 +54,6 @@ lighting messed up
|
||||
|
||||
|
||||
reattach sketch
|
||||
auto snap
|
||||
highlight button to indicate active mode
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user