diff --git a/example_parts/qwre b/demo_parts/qwre similarity index 100% rename from example_parts/qwre rename to demo_parts/qwre diff --git a/example_parts/test.json b/demo_parts/test.json similarity index 100% rename from example_parts/test.json rename to demo_parts/test.json diff --git a/example_parts/test2.json b/demo_parts/test2.json similarity index 100% rename from example_parts/test2.json rename to demo_parts/test2.json diff --git a/example_parts/test3.json b/demo_parts/test3.json similarity index 100% rename from example_parts/test3.json rename to demo_parts/test3.json diff --git a/example_parts/test4.json b/demo_parts/test4.json similarity index 100% rename from example_parts/test4.json rename to demo_parts/test4.json diff --git a/example_parts/testt.json b/demo_parts/testt.json similarity index 100% rename from example_parts/testt.json rename to demo_parts/testt.json diff --git a/example_parts/uncomp_2021-04-18T00-32-36.json b/demo_parts/uncomp_2021-04-18T00-32-36.json similarity index 100% rename from example_parts/uncomp_2021-04-18T00-32-36.json rename to demo_parts/uncomp_2021-04-18T00-32-36.json diff --git a/example_parts/uncomp_2021-04-18T00-33-34.json b/demo_parts/uncomp_2021-04-18T00-33-34.json similarity index 100% rename from example_parts/uncomp_2021-04-18T00-33-34.json rename to demo_parts/uncomp_2021-04-18T00-33-34.json diff --git a/example_parts/webpack.prod.js b/demo_parts/webpack.prod.js similarity index 100% rename from example_parts/webpack.prod.js rename to demo_parts/webpack.prod.js diff --git a/lib/STLExporter.js b/extlib/STLExporter.js similarity index 100% rename from lib/STLExporter.js rename to extlib/STLExporter.js diff --git a/lib/TrackballControls.js b/extlib/TrackballControls.js similarity index 100% rename from lib/TrackballControls.js rename to extlib/TrackballControls.js diff --git a/lib/csg-lib.js b/extlib/csg-lib.js similarity index 100% rename from lib/csg-lib.js rename to extlib/csg-lib.js diff --git a/lib/stats.module.js b/extlib/stats.module.js similarity index 100% rename from lib/stats.module.js rename to extlib/stats.module.js diff --git a/lib/stl.js b/extlib/stl.js similarity index 100% rename from lib/stl.js rename to extlib/stl.js diff --git a/lib/three-csg.js b/extlib/three-csg.js similarity index 100% rename from lib/three-csg.js rename to extlib/three-csg.js diff --git a/lib/trackball.js b/extlib/trackball.js similarity index 99% rename from lib/trackball.js rename to extlib/trackball.js index cd27650..dee2fad 100644 --- a/lib/trackball.js +++ b/extlib/trackball.js @@ -4,7 +4,7 @@ import { Quaternion, Vector2, Vector3 -} from '../node_modules/three/src/Three'; +} from 'three/src/Three'; var TrackballControls = function ( object, domElement ) { diff --git a/localhost-key.pem b/https/localhost-key.pem similarity index 100% rename from localhost-key.pem rename to https/localhost-key.pem diff --git a/localhost.pem b/https/localhost.pem similarity index 100% rename from localhost.pem rename to https/localhost.pem diff --git a/https/rootCA.pem b/https/rootCA.pem new file mode 100644 index 0000000..82624ba --- /dev/null +++ b/https/rootCA.pem @@ -0,0 +1,26 @@ +-----BEGIN CERTIFICATE----- +MIIEbjCCAtagAwIBAgIRAKm5AjBIhGb5Ln0os/kCDC4wDQYJKoZIhvcNAQELBQAw +TzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMRIwEAYDVQQLDAlob3dh +cmRAaHAxGTAXBgNVBAMMEG1rY2VydCBob3dhcmRAaHAwHhcNMjEwNDE4MDYxNTM5 +WhcNMzEwNDE4MDYxNTM5WjBPMR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQg +Q0ExEjAQBgNVBAsMCWhvd2FyZEBocDEZMBcGA1UEAwwQbWtjZXJ0IGhvd2FyZEBo +cDCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAKhLnt2Krsa5m+NqqjjX +J5SF9Nm0SGWI89g6nRiJVc2guKFZDXiV0xDz9SFj8Md5ZlX71MtO/3ACx67/VgN4 +As5+yFDEl6ulvesjZR81Xu2aGnR602SmL8Y3Q6sZUTvB3qgjQJExmEzv7ypo6PNX +Uh8Hj1/7qviHsGE8nYn7jfiy8eSnwq57p67UCFKvahBmUMEMHythcXq/zcWUJ5Dw +qjiQJNLUFcIN3Hl7J8QNtskds1Zt+N9TLS8my+cE91JG8T1JnwOn/zWJ1cnTEdls +yQIfbb2/INlkyuTvPkJHKggCrDzmVCxhLpD2aFQ2Qu8RtjmbNN/B7YEUJP8SLrv7 +lWUV7Ic5HQmS+/q27TXOm4z8HWX1GlCzoaj5VyLaPZf62eRIBunGXcvp1GcXLbiy +GCo6+Tz7RiwBX3DpH70Rz8pbz9R/LOPLa2uhlB+r7oCxpqTWrl96l+gxohfnntti +adE5cZDS8/0ITgjXcPAezNHELlJYJSuIewOVzEOr9BYpOQIDAQABo0UwQzAOBgNV +HQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU1LipvY+p +DhxjE8UP8QpCiAfmI3kwDQYJKoZIhvcNAQELBQADggGBAAUDatXb+z8Fb9hz8CHX +CNrHXlppy6/gQvVdQ02SkFVCOqemVCdZPUCM3jAUciXZJapHQNiTam8lTi6muC9m +fHYv1xBXoWc/S7Y8BOpce1R76QEMwEHfqNetquAlFgLmmTuESXMUi1eJJobvS2zS +QLqYfx8AUkZPqDHQnJ5ZVBYqKPFTN9NKg0iR/UHJSt3tUOMyVnkx5lMRZFrUEue1 +l+twzi0+Lhx11Sjx69kDd8qtGYvedcxKacR722LdiR8/YoHFoa3va/CBmLFH63oJ +k+10wNhm7eiubOaBvVit+uORS2ur26/1vFF72TLFTtXCF3mDG8P/6HB0fPzXRliI +cXdoO5+955KS6p+ZmjoMY37NNsnIZ0q3Zd6gj3I+dvhnW1XysDCEWsAiI0BQqC9d +AeZ3LqBbHIyJBantXQqpmAq9+vrYe/oUq0pwhC4cMwpAwE5pvGZgN0nt6acwrr5i +dLW6a1E571sfFFj2zC20kjwL3Sg9E2jSbMFOIiJopdT39Q== +-----END CERTIFICATE----- diff --git a/icon/svgr_raw/extrude_master.svg b/icon/extrude_master.svg similarity index 100% rename from icon/svgr_raw/extrude_master.svg rename to icon/extrude_master.svg diff --git a/icon/svgr_raw/icon_text.svg b/icon/svgr_raw/icon_text.svg deleted file mode 100644 index a91a5ad..0000000 --- a/icon/svgr_raw/icon_text.svg +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/icon/svgr_raw/intersect_thin.svg b/icon/svgr_raw/intersect_thin.svg deleted file mode 100644 index 3d29ff8..0000000 --- a/icon/svgr_raw/intersect_thin.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/icon/svgr_raw/union_thin.svg b/icon/svgr_raw/union_thin.svg deleted file mode 100644 index f02d42b..0000000 --- a/icon/svgr_raw/union_thin.svg +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/src/Scene.js b/src/Scene.js index 6ec6dda..f36931d 100644 --- a/src/Scene.js +++ b/src/Scene.js @@ -3,18 +3,18 @@ import * as THREE from '../node_modules/three/src/Three'; import { Sketch } from './Sketch' import { extrude, flipBufferGeometryNormals } from './extrude' import { onHover, onPick, clearSelection } from './mouseEvents'; -import { _vec2, _vec3, color, awaitSelection, ptObj, setHover } from './shared' +import { _vec2, _vec3, color, awaitSelection, setHover } from './shared' import { AxesHelper } from './axes' -import { TrackballControls } from '../lib/trackball' -import CSG from "../lib/three-csg" -import { STLExporter } from '../lib/stl' +import { TrackballControls } from '../extlib/trackball' +import CSG from "../extlib/three-csg" +import { STLExporter } from '../extlib/stl' let stats if (process.env.NODE_ENV !== 'production') { - const { default: d } = require('../lib/stats.module.js') + const { default: d } = require('../extlib/stats.module.js') stats = new d(); document.getElementById('stats').appendChild(stats.dom); } diff --git a/src/react/fileHelpers.js b/src/react/fileHelpers.js index 32ece26..cb16cbc 100644 --- a/src/react/fileHelpers.js +++ b/src/react/fileHelpers.js @@ -1,3 +1,5 @@ +// https://web.dev/file-system-access/ + const link = document.createElement('a'); link.style.display = 'none'; document.body.appendChild(link); diff --git a/src/react/icons.jsx b/src/react/icons.jsx index dce9f84..1e40e1f 100644 --- a/src/react/icons.jsx +++ b/src/react/icons.jsx @@ -194,62 +194,6 @@ function Extrude(props) { ); } -function Extrude_master(props) { - return ( - - - - - - ); -} - function Flip(props) { return ( - - - - - - - - - - - ); -} - function Intersect(props) { return ( - - - - - ); -} - function Line(props) { return ( - - - - - - ); -} - function Vertical(props) { return ( ); } -export { Arc, Coincident, Dimension, Extrude, Extrude_master, Flip, Horizontal, Icon_text, Intersect, Intersect_thin, Line, Logo, Stl, Subtract, Tangent, Union, Union_thin, Vertical }; \ No newline at end of file +export { Arc, Coincident, Dimension, Extrude, Flip, Horizontal, Intersect, Line, Logo, Stl, Subtract, Tangent, Union, Vertical }; \ No newline at end of file diff --git a/src/react/toolTip copy.jsx b/src/react/toolTip copy.jsx deleted file mode 100644 index 1425a22..0000000 --- a/src/react/toolTip copy.jsx +++ /dev/null @@ -1,78 +0,0 @@ -import React, { useEffect, useRef, useState } from 'react'; - -export const ToolTip = () => { - /** - * Fires when new element is mouseovered, checks if it has a tooltip attribute - * If it does, updates and unhides tooltip element after a preset timeout. - * The timout is reset if user moves off of the tooltipped element - * - * Unfortunately, new mouseover fires for svg children, which clears the - * tooltip state. We add hacky lines labelled svg workaround to bubbleup / ignore - * svg children mouseovers. We use prevTooltip ref check if new svg - * child mouseover is novel. If it's not, we ignore the event - */ - - const [text, setText] = useState(null) - - const ref = useRef() - - const activated = useRef(false) - const timeout = useRef(null) - - const prevTooltip = useRef(null) // svg workaround - - useEffect(() => { - - const svgChildren = ['path', 'g', 'rect', 'circle']; // svg workaround - - document.addEventListener('mouseover', (e) => { - let node = e.target; - - while (svgChildren.includes(node.nodeName)) { // svg workaround - node = node.parentElement // svg workaround - } // svg workaround - - const tooltip = node.getAttribute("tooltip") - - if (tooltip == prevTooltip.current) return // svg workaround - prevTooltip.current = tooltip // svg workaround - - clearTimeout(timeout.current) - if (tooltip) { - let { left, top, width, height } = node.getBoundingClientRect() - left = left + width / 2 - getTextWidth(tooltip) / 2 - 4 // 4 is padding - top = top + height + 6 // 6 is arrow height/width - setText(tooltip) - if (activated.current) { - ref.current.setAttribute('style', `left:${left}px; top:${top}px; visibility:visible`) - } else { - timeout.current = setTimeout(() => { - ref.current.setAttribute('style', `left:${left}px; top:${top}px; visibility:visible`) - activated.current = true - }, 1000); - } - } else { - ref.current.setAttribute('style', `visibility:hidden`) - activated.current = false - } - }) - }, []) - - - return
- {text} -
-
- -} - - -function getTextWidth(text, font = "16px sans-serif") { - // https://stackoverflow.com/a/21015393 - // re-use canvas object for better performance - let canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas")); - let context = canvas.getContext("2d"); - context.font = font; - let metrics = context.measureText(text); - return metrics.width; -} diff --git a/src/react/tree.jsx b/src/react/tree.jsx index e29ddfa..fe77228 100644 --- a/src/react/tree.jsx +++ b/src/react/tree.jsx @@ -1,8 +1,8 @@ -import React, { useReducer, useState, useRef } from 'react'; +import React, { useReducer, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux' -import { MdVisibilityOff, MdVisibility, MdDelete, MdRefresh } from 'react-icons/md' +import { MdVisibilityOff, MdVisibility, MdDelete } from 'react-icons/md' import { FaCube, FaEdit } from 'react-icons/fa' diff --git a/wasm/notes b/wasm/notes deleted file mode 100644 index a1b1761..0000000 --- a/wasm/notes +++ /dev/null @@ -1,144 +0,0 @@ -emcc ./wasm/solver.c ./wasm/libslvs.a -L./wasm/ -lslvs -o ./dist/solver.js -s TOTAL_MEMORY=134217728 -s EXPORTED_FUNCTIONS='[_main, _solver, _free]' - - - -int solver(int nLines, float *ptr) -{ - // for (int i=0; i 0) - { - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - con_id++, g, - SLVS_C_POINTS_COINCIDENT, - 200, - 0.0, - pt_id - 1, pt_id - 2, 0, 0); - } - else - { - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - con_id++, g, - SLVS_C_POINTS_COINCIDENT, - 200, - 0.0, - pt_id - 1, 101, 0, 0); - } - - printf("h:%i\n", h); - - sys.param[sys.params++] = Slvs_MakeParam(h++, g, (float)*ptr++); - sys.param[sys.params++] = Slvs_MakeParam(h++, g, (float)*ptr++); - - sys.entity[sys.entities++] = Slvs_MakePoint2d(pt_id++, g, 200, h - 2, h - 1); - - sys.entity[sys.entities++] = Slvs_MakeLineSegment(line_id++, g, - 200, pt_id - 1, pt_id - 2); - - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - con_id++, g, - SLVS_C_PT_PT_DISTANCE, - 200, - 30.0, - pt_id - 1, pt_id - 2, 0, 0); - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - con_id++, g, - SLVS_C_VERTICAL, - 200, - 0.0, - 0, 0, line_id-1, 0); - } - - /* If the solver fails, then ask it to report which constraints caused - * the problem. */ - sys.calculateFaileds = 1; - - sys.dragged[0] = 10; - sys.dragged[1] = 11; - sys.dragged[2] = 14; - sys.dragged[3] = 15; - - /* And solve. */ - Slvs_Solve(&sys, g); - - // printf("%i,wtf\n", sys.result); - if (sys.result == SLVS_RESULT_OKAY) - { - printf("solved okay\n"); - - for (int i = 0; i < nLines * 4; i++) - { - // *buf_pt_start++ = (float)sys.param[ptStart++].val; - printf("%f\n", sys.param[ptStart++].val); - } - } - else - { - int i; - printf("solve failed: problematic constraints are:"); - for (i = 0; i < sys.faileds; i++) - { - printf(" %d", sys.failed[i]); - } - printf("\n"); - if (sys.result == SLVS_RESULT_INCONSISTENT) - { - printf("system inconsistent\n"); - } - else - { - printf("system nonconvergent\n"); - } - } - sys.params = sys.constraints = sys.entities = 0; - return 0; -} - - - - - - diff --git a/wasm/readme.md b/wasm/readme.md new file mode 100644 index 0000000..d044829 --- /dev/null +++ b/wasm/readme.md @@ -0,0 +1,2 @@ +this wasm backend is based on the SolveSpace geometric constraint solver: +https://github.com/solvespace/solvespace \ No newline at end of file diff --git a/webpack.dev.js b/webpack.dev.js index 360dc83..bd2bf8b 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -5,18 +5,16 @@ const path = require('path'); const fs = require('fs'); module.exports = merge(common, { - mode: 'development', - devtool: 'inline-source-map', devServer: { contentBase: path.join(__dirname, 'dist'), compress: true, port: 9000, https: { - key: fs.readFileSync('./localhost-key.pem'), - cert: fs.readFileSync('./localhost.pem'), - ca: fs.readFileSync('/home/howard/.local/share/mkcert/rootCA.pem'), + key: fs.readFileSync('./https/localhost-key.pem'), + cert: fs.readFileSync('./https/localhost.pem'), + ca: fs.readFileSync('./https/rootCA.pem'), }, },