chili3d 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/main.yml +26 -0
- package/.vscode/c_cpp_properties.json +30 -0
- package/.vscode/launch.json +21 -0
- package/.vscode/settings.json +8 -0
- package/Dockerfile +7 -0
- package/LICENSE +661 -0
- package/README.md +184 -0
- package/biome.json +67 -0
- package/compose.yml +7 -0
- package/cpp/CMakeLists.txt +96 -0
- package/cpp/CMakePresets.json +43 -0
- package/cpp/README.md +21 -0
- package/cpp/src/converter.cpp +413 -0
- package/cpp/src/factory.cpp +612 -0
- package/cpp/src/geometry.cpp +204 -0
- package/cpp/src/mesher.cpp +330 -0
- package/cpp/src/opencascade.cpp +414 -0
- package/cpp/src/shape.cpp +447 -0
- package/cpp/src/shared.cpp +83 -0
- package/cpp/src/shared.hpp +211 -0
- package/cpp/src/transient.cpp +29 -0
- package/cpp/src/utils.cpp +114 -0
- package/cpp/src/utils.hpp +25 -0
- package/cpp/test/index.html +146 -0
- package/package.json +49 -0
- package/packages/chili/package.json +11 -0
- package/packages/chili/src/application.ts +200 -0
- package/packages/chili/src/bodys/arc.ts +61 -0
- package/packages/chili/src/bodys/boolean.ts +32 -0
- package/packages/chili/src/bodys/box.ts +73 -0
- package/packages/chili/src/bodys/circle.ts +57 -0
- package/packages/chili/src/bodys/cone.ts +64 -0
- package/packages/chili/src/bodys/cylinder.ts +69 -0
- package/packages/chili/src/bodys/ellipse.ts +85 -0
- package/packages/chili/src/bodys/face.ts +72 -0
- package/packages/chili/src/bodys/fuse.ts +44 -0
- package/packages/chili/src/bodys/index.ts +16 -0
- package/packages/chili/src/bodys/line.ts +48 -0
- package/packages/chili/src/bodys/polygon.ts +40 -0
- package/packages/chili/src/bodys/prism.ts +49 -0
- package/packages/chili/src/bodys/pyramid.ts +64 -0
- package/packages/chili/src/bodys/rect.ts +69 -0
- package/packages/chili/src/bodys/revolve.ts +54 -0
- package/packages/chili/src/bodys/sphere.ts +48 -0
- package/packages/chili/src/bodys/sweep.ts +67 -0
- package/packages/chili/src/bodys/wire.ts +36 -0
- package/packages/chili/src/commands/application/index.ts +10 -0
- package/packages/chili/src/commands/application/newDocument.ts +17 -0
- package/packages/chili/src/commands/application/openDocument.ts +35 -0
- package/packages/chili/src/commands/application/performanceTest.ts +64 -0
- package/packages/chili/src/commands/application/saveDocument.ts +24 -0
- package/packages/chili/src/commands/application/toFile.ts +35 -0
- package/packages/chili/src/commands/application/toggleDynamicWorkplane.ts +15 -0
- package/packages/chili/src/commands/application/wechatGroup.ts +42 -0
- package/packages/chili/src/commands/boolean.ts +109 -0
- package/packages/chili/src/commands/create/arc.ts +110 -0
- package/packages/chili/src/commands/create/bezier.ts +116 -0
- package/packages/chili/src/commands/create/box.ts +59 -0
- package/packages/chili/src/commands/create/circle.ts +54 -0
- package/packages/chili/src/commands/create/cone.ts +104 -0
- package/packages/chili/src/commands/create/converter.ts +159 -0
- package/packages/chili/src/commands/create/copySubShape.ts +37 -0
- package/packages/chili/src/commands/create/curveProjection.ts +61 -0
- package/packages/chili/src/commands/create/cylinder.ts +96 -0
- package/packages/chili/src/commands/create/ellipse.ts +95 -0
- package/packages/chili/src/commands/create/group.ts +205 -0
- package/packages/chili/src/commands/create/index.ts +26 -0
- package/packages/chili/src/commands/create/line.ts +61 -0
- package/packages/chili/src/commands/create/loft.ts +149 -0
- package/packages/chili/src/commands/create/offset.ts +131 -0
- package/packages/chili/src/commands/create/polygon.ts +104 -0
- package/packages/chili/src/commands/create/prism.ts +52 -0
- package/packages/chili/src/commands/create/pyramid.ts +56 -0
- package/packages/chili/src/commands/create/rect.ts +105 -0
- package/packages/chili/src/commands/create/revolve.ts +62 -0
- package/packages/chili/src/commands/create/section.ts +31 -0
- package/packages/chili/src/commands/create/sphere.ts +48 -0
- package/packages/chili/src/commands/create/sweep.ts +39 -0
- package/packages/chili/src/commands/create/thickSolid.ts +50 -0
- package/packages/chili/src/commands/createActCommand.ts +26 -0
- package/packages/chili/src/commands/createCommand.ts +41 -0
- package/packages/chili/src/commands/delete.ts +38 -0
- package/packages/chili/src/commands/folder.ts +18 -0
- package/packages/chili/src/commands/importExport.ts +97 -0
- package/packages/chili/src/commands/index.ts +17 -0
- package/packages/chili/src/commands/measure/angle.ts +130 -0
- package/packages/chili/src/commands/measure/index.ts +6 -0
- package/packages/chili/src/commands/measure/length.ts +57 -0
- package/packages/chili/src/commands/measure/select.module.css +68 -0
- package/packages/chili/src/commands/measure/select.ts +228 -0
- package/packages/chili/src/commands/modify/array.ts +447 -0
- package/packages/chili/src/commands/modify/break.ts +78 -0
- package/packages/chili/src/commands/modify/brush.ts +100 -0
- package/packages/chili/src/commands/modify/chamfer.ts +70 -0
- package/packages/chili/src/commands/modify/explode.ts +91 -0
- package/packages/chili/src/commands/modify/fillet.ts +69 -0
- package/packages/chili/src/commands/modify/index.ts +16 -0
- package/packages/chili/src/commands/modify/mirror.ts +49 -0
- package/packages/chili/src/commands/modify/move.ts +39 -0
- package/packages/chili/src/commands/modify/removeFeature.ts +56 -0
- package/packages/chili/src/commands/modify/removeSubShapes.ts +44 -0
- package/packages/chili/src/commands/modify/rotate.ts +112 -0
- package/packages/chili/src/commands/modify/split.ts +81 -0
- package/packages/chili/src/commands/modify/transformedCommand.ts +100 -0
- package/packages/chili/src/commands/modify/trim.ts +254 -0
- package/packages/chili/src/commands/multistepCommand.ts +125 -0
- package/packages/chili/src/commands/redo.ts +16 -0
- package/packages/chili/src/commands/undo.ts +16 -0
- package/packages/chili/src/commands/workingPlane.ts +150 -0
- package/packages/chili/src/comparers/NumberEqualityComparer.ts +12 -0
- package/packages/chili/src/comparers/XYZEqualityComparer.ts +12 -0
- package/packages/chili/src/comparers/index.ts +5 -0
- package/packages/chili/src/document.ts +145 -0
- package/packages/chili/src/editEventHandler.ts +20 -0
- package/packages/chili/src/index.ts +12 -0
- package/packages/chili/src/selection.ts +178 -0
- package/packages/chili/src/services/commandService.ts +105 -0
- package/packages/chili/src/services/editorService.ts +46 -0
- package/packages/chili/src/services/hotkeyService.ts +102 -0
- package/packages/chili/src/services/index.ts +6 -0
- package/packages/chili/src/snap/dimension.ts +33 -0
- package/packages/chili/src/snap/handlers/angleSnapEventHandler.ts +60 -0
- package/packages/chili/src/snap/handlers/index.ts +7 -0
- package/packages/chili/src/snap/handlers/lengthSnapEventHandler.ts +117 -0
- package/packages/chili/src/snap/handlers/pointSnapEventHandler.ts +176 -0
- package/packages/chili/src/snap/handlers/snapEventHandler.ts +288 -0
- package/packages/chili/src/snap/index.ts +6 -0
- package/packages/chili/src/snap/snap.ts +50 -0
- package/packages/chili/src/snap/snaps/axisSnap.ts +57 -0
- package/packages/chili/src/snap/snaps/baseSnap.ts +69 -0
- package/packages/chili/src/snap/snaps/featurePointStrategy.ts +64 -0
- package/packages/chili/src/snap/snaps/index.ts +7 -0
- package/packages/chili/src/snap/snaps/objectSnap.ts +264 -0
- package/packages/chili/src/snap/snaps/planeSnap.ts +55 -0
- package/packages/chili/src/snap/snaps/pointOnCurveSnap.ts +24 -0
- package/packages/chili/src/snap/tracking/axis.ts +32 -0
- package/packages/chili/src/snap/tracking/axisTracking.ts +46 -0
- package/packages/chili/src/snap/tracking/index.ts +6 -0
- package/packages/chili/src/snap/tracking/objectTracking.ts +90 -0
- package/packages/chili/src/snap/tracking/trackingBase.ts +40 -0
- package/packages/chili/src/snap/tracking/trackingSnap.ts +201 -0
- package/packages/chili/src/step/angleStep.ts +32 -0
- package/packages/chili/src/step/index.ts +8 -0
- package/packages/chili/src/step/lengthStep.ts +32 -0
- package/packages/chili/src/step/pointStep.ts +87 -0
- package/packages/chili/src/step/selectStep.ts +130 -0
- package/packages/chili/src/step/step.ts +55 -0
- package/packages/chili/src/utils.ts +19 -0
- package/packages/chili/test/command.test.ts +4 -0
- package/packages/chili-builder/package.json +13 -0
- package/packages/chili-builder/src/additionalModule.ts +15 -0
- package/packages/chili-builder/src/appBuilder.ts +176 -0
- package/packages/chili-builder/src/defaultDataExchange.ts +152 -0
- package/packages/chili-builder/src/index.ts +5 -0
- package/packages/chili-builder/src/ribbon.ts +129 -0
- package/packages/chili-controls/package.json +9 -0
- package/packages/chili-controls/src/collection.ts +96 -0
- package/packages/chili-controls/src/controls.ts +83 -0
- package/packages/chili-controls/src/converters/colorConverter.ts +39 -0
- package/packages/chili-controls/src/converters/index.ts +8 -0
- package/packages/chili-controls/src/converters/numberConverter.ts +15 -0
- package/packages/chili-controls/src/converters/stringConverter.ts +13 -0
- package/packages/chili-controls/src/converters/urlConverter.ts +10 -0
- package/packages/chili-controls/src/converters/xyzConverter.ts +28 -0
- package/packages/chili-controls/src/expander/expander.module.css +38 -0
- package/packages/chili-controls/src/expander/expander.ts +59 -0
- package/packages/chili-controls/src/expander/index.ts +4 -0
- package/packages/chili-controls/src/htmlProps.ts +10 -0
- package/packages/chili-controls/src/index.ts +10 -0
- package/packages/chili-controls/src/radioGroup.module.css +20 -0
- package/packages/chili-controls/src/radioGroup.ts +54 -0
- package/packages/chili-controls/src/utils.ts +20 -0
- package/packages/chili-controls/test/converter.test.ts +70 -0
- package/packages/chili-controls/test/styleMock.js +4 -0
- package/packages/chili-core/package.json +7 -0
- package/packages/chili-core/src/application.ts +38 -0
- package/packages/chili-core/src/command/command.ts +154 -0
- package/packages/chili-core/src/command/commandKeys.ts +8 -0
- package/packages/chili-core/src/command/decarator.ts +43 -0
- package/packages/chili-core/src/command/index.ts +6 -0
- package/packages/chili-core/src/config.ts +145 -0
- package/packages/chili-core/src/constants.ts +8 -0
- package/packages/chili-core/src/dataExchange.ts +12 -0
- package/packages/chili-core/src/document.ts +25 -0
- package/packages/chili-core/src/editor.ts +12 -0
- package/packages/chili-core/src/foundation/asyncController.ts +55 -0
- package/packages/chili-core/src/foundation/binding.ts +132 -0
- package/packages/chili-core/src/foundation/collection.ts +208 -0
- package/packages/chili-core/src/foundation/converter.ts +9 -0
- package/packages/chili-core/src/foundation/deepObserver.ts +154 -0
- package/packages/chili-core/src/foundation/disposable.ts +18 -0
- package/packages/chili-core/src/foundation/dto/index.ts +9 -0
- package/packages/chili-core/src/foundation/equalityComparer.ts +6 -0
- package/packages/chili-core/src/foundation/gc.ts +36 -0
- package/packages/chili-core/src/foundation/history.ts +237 -0
- package/packages/chili-core/src/foundation/id.ts +25 -0
- package/packages/chili-core/src/foundation/index.ts +26 -0
- package/packages/chili-core/src/foundation/lazy.ts +18 -0
- package/packages/chili-core/src/foundation/linkedList.ts +141 -0
- package/packages/chili-core/src/foundation/logger.ts +45 -0
- package/packages/chili-core/src/foundation/messageType.ts +8 -0
- package/packages/chili-core/src/foundation/objectStorage.ts +50 -0
- package/packages/chili-core/src/foundation/observer.ts +147 -0
- package/packages/chili-core/src/foundation/precision.ts +8 -0
- package/packages/chili-core/src/foundation/pubsub.ts +74 -0
- package/packages/chili-core/src/foundation/result.ts +69 -0
- package/packages/chili-core/src/foundation/storage.ts +10 -0
- package/packages/chili-core/src/foundation/transaction.ts +77 -0
- package/packages/chili-core/src/foundation/utils/debounce.ts +15 -0
- package/packages/chili-core/src/foundation/utils/download.ts +16 -0
- package/packages/chili-core/src/foundation/utils/index.ts +6 -0
- package/packages/chili-core/src/foundation/utils/readFileAsync.ts +84 -0
- package/packages/chili-core/src/i18n/i18n.ts +107 -0
- package/packages/chili-core/src/i18n/index.ts +5 -0
- package/packages/chili-core/src/i18n/keys.ts +265 -0
- package/packages/chili-core/src/index.ts +26 -0
- package/packages/chili-core/src/material.ts +269 -0
- package/packages/chili-core/src/math/boundingBox.ts +226 -0
- package/packages/chili-core/src/math/index.ts +14 -0
- package/packages/chili-core/src/math/line.ts +55 -0
- package/packages/chili-core/src/math/lineSegment.ts +166 -0
- package/packages/chili-core/src/math/mathUtils.ts +45 -0
- package/packages/chili-core/src/math/matrix4.ts +414 -0
- package/packages/chili-core/src/math/plane.ts +96 -0
- package/packages/chili-core/src/math/planeAngle.ts +53 -0
- package/packages/chili-core/src/math/quaternion.ts +131 -0
- package/packages/chili-core/src/math/ray.ts +30 -0
- package/packages/chili-core/src/math/xy.ts +104 -0
- package/packages/chili-core/src/math/xyz.ts +181 -0
- package/packages/chili-core/src/model/component.ts +305 -0
- package/packages/chili-core/src/model/facebaseNode.ts +17 -0
- package/packages/chili-core/src/model/folderNode.ts +289 -0
- package/packages/chili-core/src/model/geometryNode.ts +185 -0
- package/packages/chili-core/src/model/groupNode.ts +19 -0
- package/packages/chili-core/src/model/index.ts +12 -0
- package/packages/chili-core/src/model/meshNode.ts +53 -0
- package/packages/chili-core/src/model/node.ts +315 -0
- package/packages/chili-core/src/model/shapeNode.ts +195 -0
- package/packages/chili-core/src/model/visualNode.ts +39 -0
- package/packages/chili-core/src/modelManager.ts +147 -0
- package/packages/chili-core/src/navigation.ts +58 -0
- package/packages/chili-core/src/property.ts +60 -0
- package/packages/chili-core/src/selection.ts +33 -0
- package/packages/chili-core/src/selectionFilter.ts +28 -0
- package/packages/chili-core/src/serialize/index.ts +4 -0
- package/packages/chili-core/src/serialize/serializer.ts +231 -0
- package/packages/chili-core/src/service.ts +10 -0
- package/packages/chili-core/src/shape/curve.ts +174 -0
- package/packages/chili-core/src/shape/geometry.ts +17 -0
- package/packages/chili-core/src/shape/index.ts +12 -0
- package/packages/chili-core/src/shape/lineType.ts +7 -0
- package/packages/chili-core/src/shape/meshData.ts +347 -0
- package/packages/chili-core/src/shape/shape.ts +104 -0
- package/packages/chili-core/src/shape/shapeConverter.ts +17 -0
- package/packages/chili-core/src/shape/shapeFactory.ts +58 -0
- package/packages/chili-core/src/shape/shapeType.ts +75 -0
- package/packages/chili-core/src/shape/surface.ts +154 -0
- package/packages/chili-core/src/snapType.ts +32 -0
- package/packages/chili-core/src/ui/button.ts +16 -0
- package/packages/chili-core/src/ui/combobox.ts +27 -0
- package/packages/chili-core/src/ui/dialog.ts +7 -0
- package/packages/chili-core/src/ui/index.ts +8 -0
- package/packages/chili-core/src/ui/ribbon.ts +15 -0
- package/packages/chili-core/src/ui/window.ts +13 -0
- package/packages/chili-core/src/visual/act.ts +59 -0
- package/packages/chili-core/src/visual/cameraController.ts +22 -0
- package/packages/chili-core/src/visual/cursorType.ts +4 -0
- package/packages/chili-core/src/visual/detectedData.ts +14 -0
- package/packages/chili-core/src/visual/eventHandler.ts +15 -0
- package/packages/chili-core/src/visual/highlighter.ts +16 -0
- package/packages/chili-core/src/visual/index.ts +20 -0
- package/packages/chili-core/src/visual/meshExporter.ts +11 -0
- package/packages/chili-core/src/visual/meshUtils.ts +276 -0
- package/packages/chili-core/src/visual/textGenerator.ts +8 -0
- package/packages/chili-core/src/visual/view.ts +80 -0
- package/packages/chili-core/src/visual/viewGizmo.ts +8 -0
- package/packages/chili-core/src/visual/viewport.ts +10 -0
- package/packages/chili-core/src/visual/visual.ts +24 -0
- package/packages/chili-core/src/visual/visualContext.ts +29 -0
- package/packages/chili-core/src/visual/visualFactory.ts +10 -0
- package/packages/chili-core/src/visual/visualObject.ts +25 -0
- package/packages/chili-core/src/visual/visualShape.ts +30 -0
- package/packages/chili-core/test/binding.test.ts +95 -0
- package/packages/chili-core/test/boundingBox.test.ts +60 -0
- package/packages/chili-core/test/collection.test.ts +53 -0
- package/packages/chili-core/test/history.test.ts +42 -0
- package/packages/chili-core/test/line.test.ts +75 -0
- package/packages/chili-core/test/linesegment.test.ts +98 -0
- package/packages/chili-core/test/linkedList.test.ts +82 -0
- package/packages/chili-core/test/math.test.ts +34 -0
- package/packages/chili-core/test/matrix.test.ts +129 -0
- package/packages/chili-core/test/node.test.ts +122 -0
- package/packages/chili-core/test/nodeList.test.ts +247 -0
- package/packages/chili-core/test/observer.test.ts +91 -0
- package/packages/chili-core/test/plane.test.ts +31 -0
- package/packages/chili-core/test/quaternion.test.ts +14 -0
- package/packages/chili-core/test/result.test.ts +24 -0
- package/packages/chili-core/test/serializer.test.ts +58 -0
- package/packages/chili-core/test/snapType.test.ts +10 -0
- package/packages/chili-core/test/task.test.ts +41 -0
- package/packages/chili-core/test/testDocument.ts +70 -0
- package/packages/chili-core/test/transaction.test.ts +42 -0
- package/packages/chili-core/test/visual.test.ts +42 -0
- package/packages/chili-core/test/xyz.test.ts +260 -0
- package/packages/chili-geo/package.json +9 -0
- package/packages/chili-geo/src/index.ts +4 -0
- package/packages/chili-geo/src/utils.ts +113 -0
- package/packages/chili-i18n/package.json +9 -0
- package/packages/chili-i18n/src/en.ts +270 -0
- package/packages/chili-i18n/src/index.ts +8 -0
- package/packages/chili-i18n/src/pt-br.ts +67 -0
- package/packages/chili-i18n/src/zh-cn.ts +269 -0
- package/packages/chili-storage/package.json +9 -0
- package/packages/chili-storage/src/index.ts +4 -0
- package/packages/chili-storage/src/indexedDBStorage.ts +150 -0
- package/packages/chili-three/package.json +13 -0
- package/packages/chili-three/src/cameraController.ts +335 -0
- package/packages/chili-three/src/common.ts +65 -0
- package/packages/chili-three/src/constants.ts +12 -0
- package/packages/chili-three/src/highlightable.ts +13 -0
- package/packages/chili-three/src/index.ts +4 -0
- package/packages/chili-three/src/meshExporter.ts +69 -0
- package/packages/chili-three/src/outlinePass.js +340 -0
- package/packages/chili-three/src/texture_points.jpg +0 -0
- package/packages/chili-three/src/threeGeometry.ts +207 -0
- package/packages/chili-three/src/threeGeometryFactory.ts +120 -0
- package/packages/chili-three/src/threeHelper.ts +174 -0
- package/packages/chili-three/src/threeHighlighter.ts +257 -0
- package/packages/chili-three/src/threeView.module.css +39 -0
- package/packages/chili-three/src/threeView.ts +669 -0
- package/packages/chili-three/src/threeViewEventHandler.ts +193 -0
- package/packages/chili-three/src/threeVisual.ts +92 -0
- package/packages/chili-three/src/threeVisualContext.ts +435 -0
- package/packages/chili-three/src/threeVisualFactory.ts +12 -0
- package/packages/chili-three/src/threeVisualObject.ts +442 -0
- package/packages/chili-three/src/viewGizmo.ts +305 -0
- package/packages/chili-three/test/cameraControls.ts +10 -0
- package/packages/chili-three/test/testDocument.ts +68 -0
- package/packages/chili-three/test/testEdge.ts +171 -0
- package/packages/chili-three/test/testView.ts +78 -0
- package/packages/chili-three/test/three.test.ts +44 -0
- package/packages/chili-three/test/viewGizmo.ts +12 -0
- package/packages/chili-ui/package.json +12 -0
- package/packages/chili-ui/src/cursor/draw.cur +0 -0
- package/packages/chili-ui/src/cursor/index.ts +17 -0
- package/packages/chili-ui/src/dialog.module.css +63 -0
- package/packages/chili-ui/src/dialog.ts +42 -0
- package/packages/chili-ui/src/editor.module.css +83 -0
- package/packages/chili-ui/src/editor.ts +142 -0
- package/packages/chili-ui/src/home/home.module.css +301 -0
- package/packages/chili-ui/src/home/home.ts +243 -0
- package/packages/chili-ui/src/home/index.ts +4 -0
- package/packages/chili-ui/src/home/languageSelector.ts +27 -0
- package/packages/chili-ui/src/home/navigation3DSelector.ts +27 -0
- package/packages/chili-ui/src/home/themeSelector.ts +34 -0
- package/packages/chili-ui/src/index.ts +5 -0
- package/packages/chili-ui/src/mainWindow.module.css +144 -0
- package/packages/chili-ui/src/mainWindow.ts +154 -0
- package/packages/chili-ui/src/okCancel.module.css +54 -0
- package/packages/chili-ui/src/okCancel.ts +58 -0
- package/packages/chili-ui/src/permanent.module.css +44 -0
- package/packages/chili-ui/src/permanent.ts +31 -0
- package/packages/chili-ui/src/project/index.ts +4 -0
- package/packages/chili-ui/src/project/projectView.module.css +37 -0
- package/packages/chili-ui/src/project/projectView.ts +77 -0
- package/packages/chili-ui/src/project/toolBar.module.css +16 -0
- package/packages/chili-ui/src/project/toolBar.ts +73 -0
- package/packages/chili-ui/src/project/tree/index.ts +5 -0
- package/packages/chili-ui/src/project/tree/tree.module.css +16 -0
- package/packages/chili-ui/src/project/tree/tree.ts +265 -0
- package/packages/chili-ui/src/project/tree/treeItem.module.css +21 -0
- package/packages/chili-ui/src/project/tree/treeItem.ts +89 -0
- package/packages/chili-ui/src/project/tree/treeItemGroup.module.css +33 -0
- package/packages/chili-ui/src/project/tree/treeItemGroup.ts +85 -0
- package/packages/chili-ui/src/project/tree/treeModel.module.css +11 -0
- package/packages/chili-ui/src/project/tree/treeModel.ts +20 -0
- package/packages/chili-ui/src/property/check.ts +39 -0
- package/packages/chili-ui/src/property/colorPorperty.module.css +6 -0
- package/packages/chili-ui/src/property/colorProperty.ts +63 -0
- package/packages/chili-ui/src/property/common.module.css +14 -0
- package/packages/chili-ui/src/property/index.ts +4 -0
- package/packages/chili-ui/src/property/input.module.css +19 -0
- package/packages/chili-ui/src/property/input.ts +140 -0
- package/packages/chili-ui/src/property/material/index.ts +5 -0
- package/packages/chili-ui/src/property/material/materialDataContent.ts +44 -0
- package/packages/chili-ui/src/property/material/materialEditor.module.css +98 -0
- package/packages/chili-ui/src/property/material/materialEditor.ts +147 -0
- package/packages/chili-ui/src/property/material/textureEditor.module.css +46 -0
- package/packages/chili-ui/src/property/material/textureEditor.ts +61 -0
- package/packages/chili-ui/src/property/materialProperty.module.css +30 -0
- package/packages/chili-ui/src/property/materialProperty.ts +86 -0
- package/packages/chili-ui/src/property/matrixProperty.ts +147 -0
- package/packages/chili-ui/src/property/propertyBase.module.css +3 -0
- package/packages/chili-ui/src/property/propertyBase.ts +14 -0
- package/packages/chili-ui/src/property/propertyView.module.css +36 -0
- package/packages/chili-ui/src/property/propertyView.ts +115 -0
- package/packages/chili-ui/src/property/utils.ts +48 -0
- package/packages/chili-ui/src/ribbon/commandContext.module.css +73 -0
- package/packages/chili-ui/src/ribbon/commandContext.ts +239 -0
- package/packages/chili-ui/src/ribbon/index.ts +4 -0
- package/packages/chili-ui/src/ribbon/ribbon.module.css +286 -0
- package/packages/chili-ui/src/ribbon/ribbon.ts +288 -0
- package/packages/chili-ui/src/ribbon/ribbonButton.module.css +75 -0
- package/packages/chili-ui/src/ribbon/ribbonButton.ts +88 -0
- package/packages/chili-ui/src/ribbon/ribbonData.ts +66 -0
- package/packages/chili-ui/src/ribbon/ribbonStack.module.css +6 -0
- package/packages/chili-ui/src/ribbon/ribbonStack.ts +13 -0
- package/packages/chili-ui/src/ribbon/ribbonToggleButton.module.css +3 -0
- package/packages/chili-ui/src/ribbon/ribbonToggleButton.ts +6 -0
- package/packages/chili-ui/src/statusbar/index.ts +4 -0
- package/packages/chili-ui/src/statusbar/snapConfig.module.css +25 -0
- package/packages/chili-ui/src/statusbar/snapConfig.ts +92 -0
- package/packages/chili-ui/src/statusbar/statusbar.module.css +28 -0
- package/packages/chili-ui/src/statusbar/statusbar.ts +54 -0
- package/packages/chili-ui/src/toast/index.ts +4 -0
- package/packages/chili-ui/src/toast/toast.module.css +27 -0
- package/packages/chili-ui/src/toast/toast.ts +39 -0
- package/packages/chili-ui/src/viewport/flyout/flyout.module.css +9 -0
- package/packages/chili-ui/src/viewport/flyout/flyout.ts +77 -0
- package/packages/chili-ui/src/viewport/flyout/index.ts +6 -0
- package/packages/chili-ui/src/viewport/flyout/input.module.css +21 -0
- package/packages/chili-ui/src/viewport/flyout/input.ts +89 -0
- package/packages/chili-ui/src/viewport/flyout/tip.module.css +21 -0
- package/packages/chili-ui/src/viewport/flyout/tip.ts +45 -0
- package/packages/chili-ui/src/viewport/index.ts +4 -0
- package/packages/chili-ui/src/viewport/layoutViewport.module.css +21 -0
- package/packages/chili-ui/src/viewport/layoutViewport.ts +76 -0
- package/packages/chili-ui/src/viewport/viewport.module.css +179 -0
- package/packages/chili-ui/src/viewport/viewport.ts +296 -0
- package/packages/chili-vis/package.json +9 -0
- package/packages/chili-vis/src/index.ts +7 -0
- package/packages/chili-vis/src/nodeSelectionEventHandler.ts +122 -0
- package/packages/chili-vis/src/selectionEventHandler.ts +145 -0
- package/packages/chili-vis/src/shapeSelectionEventHandler.ts +176 -0
- package/packages/chili-vis/src/viewUtils.ts +64 -0
- package/packages/chili-wasm/lib/chili-wasm.d.ts +827 -0
- package/packages/chili-wasm/lib/chili-wasm.js +5275 -0
- package/packages/chili-wasm/lib/chili-wasm.wasm +0 -0
- package/packages/chili-wasm/package.json +10 -0
- package/packages/chili-wasm/src/converter.ts +124 -0
- package/packages/chili-wasm/src/curve.ts +589 -0
- package/packages/chili-wasm/src/factory.ts +331 -0
- package/packages/chili-wasm/src/geometry.ts +51 -0
- package/packages/chili-wasm/src/helper.ts +435 -0
- package/packages/chili-wasm/src/index.ts +5 -0
- package/packages/chili-wasm/src/mesher.ts +114 -0
- package/packages/chili-wasm/src/shape.ts +481 -0
- package/packages/chili-wasm/src/surface.ts +510 -0
- package/packages/chili-wasm/src/wasm.ts +13 -0
- package/packages/chili-web/package.json +9 -0
- package/packages/chili-web/src/index.ts +33 -0
- package/packages/chili-web/src/loading.ts +67 -0
- package/packages/global.d.ts +31 -0
- package/public/favicon.svg +10 -0
- package/public/fonts/fzhei.json +46120 -0
- package/public/iconfont.js +1 -0
- package/public/images/wechat.jpg +0 -0
- package/public/index.css +13 -0
- package/public/index.html +24 -0
- package/rspack.config.ts +93 -0
- package/rstest.config.ts +27 -0
- package/screenshots/screenshot.png +0 -0
- package/scripts/add_copyright.mjs +59 -0
- package/scripts/build-npm.mjs +105 -0
- package/scripts/common.mjs +24 -0
- package/scripts/release.mjs +92 -0
- package/scripts/restore-package-json.mjs +27 -0
- package/scripts/setup_wasm_deps.mjs +97 -0
- package/scripts/update-package-json.mjs +27 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
command,
|
|
6
|
+
EditableShapeNode,
|
|
7
|
+
type IApplication,
|
|
8
|
+
type ICommand,
|
|
9
|
+
type IDocument,
|
|
10
|
+
type Material,
|
|
11
|
+
Plane,
|
|
12
|
+
XYZ,
|
|
13
|
+
} from "chili-core";
|
|
14
|
+
|
|
15
|
+
export abstract class PerformanceTestCommand implements ICommand {
|
|
16
|
+
protected size = 10;
|
|
17
|
+
protected gap = 1;
|
|
18
|
+
protected rowCols = 20;
|
|
19
|
+
|
|
20
|
+
async execute(app: IApplication): Promise<void> {
|
|
21
|
+
const document = await app.newDocument("OCC Performace Test");
|
|
22
|
+
|
|
23
|
+
const start = performance.now();
|
|
24
|
+
const distance = this.gap + this.size;
|
|
25
|
+
for (let x = 0; x < this.rowCols; x++) {
|
|
26
|
+
for (let y = 0; y < this.rowCols; y++) {
|
|
27
|
+
for (let z = 0; z < this.rowCols; z++) {
|
|
28
|
+
const position = XYZ.zero
|
|
29
|
+
.add(XYZ.unitX.multiply(x * distance))
|
|
30
|
+
.add(XYZ.unitY.multiply(y * distance))
|
|
31
|
+
.add(XYZ.unitZ.multiply(z * distance));
|
|
32
|
+
this.createShape(document, document.modelManager.materials.at(0)!, position);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
document.visual.update();
|
|
37
|
+
alert(
|
|
38
|
+
`Create ${this.rowCols * this.rowCols * this.rowCols} shapes, Time: ${performance.now() - start} ms`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected abstract createShape(document: IDocument, material: Material, position: XYZ): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@command({
|
|
46
|
+
key: "test.performance",
|
|
47
|
+
icon: "icon-performance",
|
|
48
|
+
})
|
|
49
|
+
export class OccPerformanceTestCommand extends PerformanceTestCommand {
|
|
50
|
+
private index = 1;
|
|
51
|
+
shapes: any[] = [];
|
|
52
|
+
|
|
53
|
+
protected override createShape(document: IDocument, material: Material, position: XYZ): void {
|
|
54
|
+
const plane = Plane.XY.translateTo(position);
|
|
55
|
+
const box = document.application.shapeFactory.box(
|
|
56
|
+
plane,
|
|
57
|
+
this.size * Math.random(),
|
|
58
|
+
this.size * Math.random(),
|
|
59
|
+
this.size * Math.random(),
|
|
60
|
+
).value;
|
|
61
|
+
const node = new EditableShapeNode(document, `box ${this.index++}`, box, material.id);
|
|
62
|
+
document.modelManager.addNode(node);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { command, I18n, type IApplication, type ICommand, PubSub } from "chili-core";
|
|
5
|
+
|
|
6
|
+
@command({
|
|
7
|
+
key: "doc.save",
|
|
8
|
+
icon: "icon-save",
|
|
9
|
+
isApplicationCommand: true,
|
|
10
|
+
})
|
|
11
|
+
export class SaveDocument implements ICommand {
|
|
12
|
+
async execute(app: IApplication): Promise<void> {
|
|
13
|
+
if (!app.activeView?.document) return;
|
|
14
|
+
PubSub.default.pub(
|
|
15
|
+
"showPermanent",
|
|
16
|
+
async () => {
|
|
17
|
+
await app.activeView?.document.save();
|
|
18
|
+
PubSub.default.pub("showToast", "toast.document.saved");
|
|
19
|
+
},
|
|
20
|
+
"toast.excuting{0}",
|
|
21
|
+
I18n.translate("command.doc.save"),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
command,
|
|
6
|
+
DOCUMENT_FILE_EXTENSION,
|
|
7
|
+
download,
|
|
8
|
+
I18n,
|
|
9
|
+
type IApplication,
|
|
10
|
+
type ICommand,
|
|
11
|
+
PubSub,
|
|
12
|
+
} from "chili-core";
|
|
13
|
+
|
|
14
|
+
@command({
|
|
15
|
+
key: "doc.saveToFile",
|
|
16
|
+
icon: "icon-download",
|
|
17
|
+
})
|
|
18
|
+
export class SaveDocumentToFile implements ICommand {
|
|
19
|
+
async execute(app: IApplication): Promise<void> {
|
|
20
|
+
if (!app.activeView?.document) return;
|
|
21
|
+
PubSub.default.pub(
|
|
22
|
+
"showPermanent",
|
|
23
|
+
async () => {
|
|
24
|
+
await new Promise((r) => {
|
|
25
|
+
setTimeout(r, 100);
|
|
26
|
+
});
|
|
27
|
+
const s = app.activeView?.document.serialize();
|
|
28
|
+
PubSub.default.pub("showToast", "toast.downloading");
|
|
29
|
+
download([JSON.stringify(s)], `${app.activeView?.document.name}${DOCUMENT_FILE_EXTENSION}`);
|
|
30
|
+
},
|
|
31
|
+
"toast.excuting{0}",
|
|
32
|
+
I18n.translate("command.doc.saveToFile"),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Binding, Config, command, type IApplication, type ICommand } from "chili-core";
|
|
5
|
+
|
|
6
|
+
@command({
|
|
7
|
+
key: "workingPlane.toggleDynamic",
|
|
8
|
+
toggle: new Binding(Config.instance, "dynamicWorkplane"),
|
|
9
|
+
icon: "icon-dynamicPlane",
|
|
10
|
+
})
|
|
11
|
+
export class ToggleDynamicWorkplaneCommand implements ICommand {
|
|
12
|
+
async execute(_app: IApplication): Promise<void> {
|
|
13
|
+
Config.instance.dynamicWorkplane = !Config.instance.dynamicWorkplane;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { br, div, img, label } from "chili-controls";
|
|
5
|
+
import { command, type IApplication, type ICommand, PubSub } from "chili-core";
|
|
6
|
+
|
|
7
|
+
@command({
|
|
8
|
+
key: "wechat.group",
|
|
9
|
+
icon: "icon-qrcode",
|
|
10
|
+
isApplicationCommand: true,
|
|
11
|
+
})
|
|
12
|
+
export class WeChatGroup implements ICommand {
|
|
13
|
+
async execute(app: IApplication): Promise<void> {
|
|
14
|
+
PubSub.default.pub("showDialog", "command.wechat.group", this.ui());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private ui() {
|
|
18
|
+
return div(
|
|
19
|
+
label(
|
|
20
|
+
{
|
|
21
|
+
style: {
|
|
22
|
+
fontSize: "14px",
|
|
23
|
+
display: "block",
|
|
24
|
+
textAlign: "center",
|
|
25
|
+
marginBottom: "10px",
|
|
26
|
+
opacity: "0.75",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
"群聊人数已超过200人,只可通过邀请进入群聊",
|
|
30
|
+
br(),
|
|
31
|
+
"入群请先添加个人微信:oOxianOo",
|
|
32
|
+
),
|
|
33
|
+
img({
|
|
34
|
+
width: 360,
|
|
35
|
+
src: "images/wechat.jpg",
|
|
36
|
+
style: {
|
|
37
|
+
borderRadius: "10px",
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
command,
|
|
6
|
+
type IShape,
|
|
7
|
+
PubSub,
|
|
8
|
+
type Result,
|
|
9
|
+
ShapeNode,
|
|
10
|
+
ShapeType,
|
|
11
|
+
Transaction,
|
|
12
|
+
VisualState,
|
|
13
|
+
} from "chili-core";
|
|
14
|
+
import { BooleanNode } from "../bodys/boolean";
|
|
15
|
+
import { type IStep, SelectShapeStep } from "../step";
|
|
16
|
+
import { MultistepCommand } from "./multistepCommand";
|
|
17
|
+
|
|
18
|
+
export abstract class BooleanOperate extends MultistepCommand {
|
|
19
|
+
protected override executeMainTask() {
|
|
20
|
+
Transaction.execute(this.document, "boolean", () => {
|
|
21
|
+
const shape1 = this.transformdFirstShape(this.stepDatas[0]);
|
|
22
|
+
const shape2 = this.transformdShapes(this.stepDatas[1]);
|
|
23
|
+
const booleanType = this.getBooleanOperateType();
|
|
24
|
+
|
|
25
|
+
const booleanShape = this.getBooleanShape(booleanType, shape1, shape2);
|
|
26
|
+
if (!booleanShape.isOk) {
|
|
27
|
+
PubSub.default.pub("showToast", "error.default:{0}", "boolean failed");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const node = new BooleanNode(this.document, booleanShape.value);
|
|
31
|
+
this.document.modelManager.rootNode.add(node);
|
|
32
|
+
this.stepDatas.forEach((x) => {
|
|
33
|
+
x.nodes?.forEach((n) => n.parent?.remove(n));
|
|
34
|
+
});
|
|
35
|
+
this.document.visual.update();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private getBooleanShape(
|
|
40
|
+
type: "common" | "cut" | "fuse",
|
|
41
|
+
shape1: IShape,
|
|
42
|
+
tools: IShape[],
|
|
43
|
+
): Result<IShape> {
|
|
44
|
+
switch (type) {
|
|
45
|
+
case "common":
|
|
46
|
+
return this.application.shapeFactory.booleanCommon([shape1], tools);
|
|
47
|
+
case "cut":
|
|
48
|
+
return this.application.shapeFactory.booleanCut([shape1], tools);
|
|
49
|
+
default:
|
|
50
|
+
return this.application.shapeFactory.booleanFuse([shape1], tools);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected abstract getBooleanOperateType(): "common" | "cut" | "fuse";
|
|
55
|
+
|
|
56
|
+
protected override getSteps(): IStep[] {
|
|
57
|
+
return [
|
|
58
|
+
new SelectShapeStep(ShapeType.Shape, "prompt.select.shape", {
|
|
59
|
+
nodeFilter: { allow: (node) => node instanceof ShapeNode },
|
|
60
|
+
}),
|
|
61
|
+
new SelectShapeStep(ShapeType.Shape, "prompt.select.shape", {
|
|
62
|
+
nodeFilter: {
|
|
63
|
+
allow: (node) => {
|
|
64
|
+
if (!(node instanceof ShapeNode)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return !this.stepDatas[0].nodes
|
|
69
|
+
?.map((x) => (x as ShapeNode).shape.value)
|
|
70
|
+
.includes(node.shape.value);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
multiple: true,
|
|
74
|
+
keepSelection: true,
|
|
75
|
+
selectedState: VisualState.faceTransparent,
|
|
76
|
+
}),
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@command({
|
|
82
|
+
key: "boolean.common",
|
|
83
|
+
icon: "icon-booleanCommon",
|
|
84
|
+
})
|
|
85
|
+
export class BooleanCommon extends BooleanOperate {
|
|
86
|
+
protected override getBooleanOperateType(): "common" | "cut" | "fuse" {
|
|
87
|
+
return "common";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@command({
|
|
92
|
+
key: "boolean.cut",
|
|
93
|
+
icon: "icon-booleanCut",
|
|
94
|
+
})
|
|
95
|
+
export class BooleanCut extends BooleanOperate {
|
|
96
|
+
protected override getBooleanOperateType(): "common" | "cut" | "fuse" {
|
|
97
|
+
return "cut";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@command({
|
|
102
|
+
key: "boolean.join",
|
|
103
|
+
icon: "icon-booleanFuse",
|
|
104
|
+
})
|
|
105
|
+
export class BooleanFuse extends BooleanOperate {
|
|
106
|
+
protected override getBooleanOperateType(): "common" | "cut" | "fuse" {
|
|
107
|
+
return "fuse";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
command,
|
|
6
|
+
type GeometryNode,
|
|
7
|
+
Plane,
|
|
8
|
+
PlaneAngle,
|
|
9
|
+
Precision,
|
|
10
|
+
type ShapeMeshData,
|
|
11
|
+
type XYZ,
|
|
12
|
+
} from "chili-core";
|
|
13
|
+
import { ArcNode } from "../../bodys/arc";
|
|
14
|
+
import { Dimension, type SnapLengthAtPlaneData } from "../../snap";
|
|
15
|
+
import { AngleStep, type IStep, LengthAtPlaneStep, PointStep } from "../../step";
|
|
16
|
+
import { CreateCommand } from "../createCommand";
|
|
17
|
+
|
|
18
|
+
@command({
|
|
19
|
+
key: "create.arc",
|
|
20
|
+
icon: "icon-arc",
|
|
21
|
+
})
|
|
22
|
+
export class Arc extends CreateCommand {
|
|
23
|
+
private _planeAngle: PlaneAngle | undefined;
|
|
24
|
+
|
|
25
|
+
getSteps(): IStep[] {
|
|
26
|
+
return [
|
|
27
|
+
new PointStep("prompt.pickCircleCenter"),
|
|
28
|
+
new LengthAtPlaneStep("prompt.pickRadius", this.getRadiusData),
|
|
29
|
+
new AngleStep(
|
|
30
|
+
"prompt.pickNextPoint",
|
|
31
|
+
() => this.stepDatas[0].point!,
|
|
32
|
+
() => this.stepDatas[1].point!,
|
|
33
|
+
this.getAngleData,
|
|
34
|
+
),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private readonly getRadiusData = (): SnapLengthAtPlaneData => {
|
|
39
|
+
const { point, view } = this.stepDatas[0];
|
|
40
|
+
return {
|
|
41
|
+
point: () => point!,
|
|
42
|
+
preview: this.circlePreview,
|
|
43
|
+
plane: (p: XYZ | undefined) => this.findPlane(view, point!, p),
|
|
44
|
+
validator: (p: XYZ) => {
|
|
45
|
+
if (p.distanceTo(point!) < Precision.Distance) return false;
|
|
46
|
+
return p.sub(point!).isParallelTo(this.stepDatas[0].view.workplane.normal) === false;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
private readonly getAngleData = () => {
|
|
52
|
+
const [center, p1] = [this.stepDatas[0].point!, this.stepDatas[1].point!];
|
|
53
|
+
const plane = this.stepDatas[1].plane ?? this.findPlane(this.stepDatas[1].view, center, p1);
|
|
54
|
+
const points: ShapeMeshData[] = [this.meshPoint(center), this.meshPoint(p1)];
|
|
55
|
+
this._planeAngle = new PlaneAngle(new Plane(center, plane.normal, p1.sub(center)));
|
|
56
|
+
return {
|
|
57
|
+
dimension: Dimension.D1D2,
|
|
58
|
+
preview: (point: XYZ | undefined) => this.anglePreview(point, center, p1, points),
|
|
59
|
+
plane: () => plane,
|
|
60
|
+
validators: [this.angleValidator(center, plane)],
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
private anglePreview(
|
|
65
|
+
point: XYZ | undefined,
|
|
66
|
+
center: XYZ,
|
|
67
|
+
p1: XYZ,
|
|
68
|
+
points: ShapeMeshData[],
|
|
69
|
+
): ShapeMeshData[] {
|
|
70
|
+
point = point ?? p1;
|
|
71
|
+
this._planeAngle!.movePoint(point);
|
|
72
|
+
const result = [...points];
|
|
73
|
+
if (Math.abs(this._planeAngle!.angle) > Precision.Angle) {
|
|
74
|
+
result.push(
|
|
75
|
+
this.meshCreatedShape(
|
|
76
|
+
"arc",
|
|
77
|
+
this._planeAngle!.plane.normal,
|
|
78
|
+
center,
|
|
79
|
+
p1,
|
|
80
|
+
this._planeAngle!.angle,
|
|
81
|
+
),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private angleValidator(center: XYZ, plane: Plane) {
|
|
88
|
+
return (p: XYZ) =>
|
|
89
|
+
p.distanceTo(center) >= Precision.Distance && !p.sub(center).isParallelTo(plane.normal);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected override geometryNode(): GeometryNode {
|
|
93
|
+
const [p0, p1] = [this.stepDatas[0].point!, this.stepDatas[1].point!];
|
|
94
|
+
const plane = this.stepDatas[1].plane ?? this.findPlane(this.stepDatas[1].view, p0, p1);
|
|
95
|
+
this._planeAngle?.movePoint(this.stepDatas[2].point!);
|
|
96
|
+
return new ArcNode(this.document, plane.normal, p0, p1, this._planeAngle!.angle);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private readonly circlePreview = (end: XYZ | undefined) => {
|
|
100
|
+
const visualCenter = this.meshPoint(this.stepDatas[0].point!);
|
|
101
|
+
if (!end) return [visualCenter];
|
|
102
|
+
const { point, view } = this.stepDatas[0];
|
|
103
|
+
const plane = this.findPlane(view, point!, end);
|
|
104
|
+
return [
|
|
105
|
+
visualCenter,
|
|
106
|
+
this.meshLine(this.stepDatas[0].point!, end),
|
|
107
|
+
this.meshCreatedShape("circle", plane.normal, point!, plane.projectDistance(point!, end)),
|
|
108
|
+
];
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AsyncController,
|
|
6
|
+
command,
|
|
7
|
+
EdgeMeshData,
|
|
8
|
+
EditableShapeNode,
|
|
9
|
+
type GeometryNode,
|
|
10
|
+
I18n,
|
|
11
|
+
LineType,
|
|
12
|
+
Precision,
|
|
13
|
+
type ShapeMeshData,
|
|
14
|
+
VisualConfig,
|
|
15
|
+
type XYZ,
|
|
16
|
+
} from "chili-core";
|
|
17
|
+
import { Dimension, type PointSnapData, type SnapResult } from "../../snap";
|
|
18
|
+
import { type IStep, PointStep } from "../../step";
|
|
19
|
+
import { CreateCommand } from "../createCommand";
|
|
20
|
+
|
|
21
|
+
@command({
|
|
22
|
+
key: "create.bezier",
|
|
23
|
+
icon: "icon-bezier",
|
|
24
|
+
})
|
|
25
|
+
export class BezierCommand extends CreateCommand {
|
|
26
|
+
protected override geometryNode(): GeometryNode {
|
|
27
|
+
const bezier = this.application.shapeFactory.bezier(this.stepDatas.map((x) => x.point!));
|
|
28
|
+
return new EditableShapeNode(this.document, I18n.translate("command.create.bezier"), bezier.value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected override async executeSteps() {
|
|
32
|
+
const steps = this.getSteps();
|
|
33
|
+
let firstStep = true;
|
|
34
|
+
while (true) {
|
|
35
|
+
const step = firstStep ? steps[0] : steps[1];
|
|
36
|
+
if (firstStep) firstStep = false;
|
|
37
|
+
this.controller = new AsyncController();
|
|
38
|
+
const data = await step.execute(this.document, this.controller);
|
|
39
|
+
if (data === undefined) {
|
|
40
|
+
return this.controller.result?.status === "success";
|
|
41
|
+
}
|
|
42
|
+
this.stepDatas.push(data);
|
|
43
|
+
if (this.isClose(data)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private isClose(data: SnapResult) {
|
|
50
|
+
console.log(this.stepDatas[0].point!.distanceTo(data.point!));
|
|
51
|
+
return (
|
|
52
|
+
this.stepDatas.length > 1 &&
|
|
53
|
+
this.stepDatas[0].point!.distanceTo(data.point!) <= Precision.Distance
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected override getSteps(): IStep[] {
|
|
58
|
+
const firstStep = new PointStep("prompt.pickFistPoint");
|
|
59
|
+
const secondStep = new PointStep("prompt.pickNextPoint", this.getNextData);
|
|
60
|
+
return [firstStep, secondStep];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private readonly getNextData = (): PointSnapData => {
|
|
64
|
+
return {
|
|
65
|
+
refPoint: () => this.stepDatas.at(-1)!.point!,
|
|
66
|
+
dimension: Dimension.D1D2D3,
|
|
67
|
+
validator: this.validator,
|
|
68
|
+
preview: this.preview,
|
|
69
|
+
featurePoints: [
|
|
70
|
+
{
|
|
71
|
+
point: this.stepDatas.at(0)!.point!,
|
|
72
|
+
prompt: I18n.translate("prompt.polygon.close"),
|
|
73
|
+
when: () => this.stepDatas.length > 2,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
private readonly preview = (point: XYZ | undefined): ShapeMeshData[] => {
|
|
80
|
+
const ps: ShapeMeshData[] = this.stepDatas.map((data) => this.meshPoint(data.point!));
|
|
81
|
+
const points = this.stepDatas.map((data) => data.point) as XYZ[];
|
|
82
|
+
if (point) {
|
|
83
|
+
points.push(point);
|
|
84
|
+
}
|
|
85
|
+
if (points.length > 1) {
|
|
86
|
+
ps.push(...this.previewLines(points));
|
|
87
|
+
ps.push(this.meshCreatedShape("bezier", points));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return ps;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
private readonly previewLines = (points: XYZ[]): ShapeMeshData[] => {
|
|
94
|
+
if (points.length < 2) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const res: ShapeMeshData[] = [];
|
|
98
|
+
for (let i = 1; i < points.length; i++) {
|
|
99
|
+
res.push(this.meshHandle(points[i - 1], points[i]));
|
|
100
|
+
}
|
|
101
|
+
return res;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
protected meshHandle(start: XYZ, end: XYZ) {
|
|
105
|
+
return EdgeMeshData.from(start, end, VisualConfig.temporaryEdgeColor, LineType.Dash);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private readonly validator = (point: XYZ): boolean => {
|
|
109
|
+
for (const data of this.stepDatas) {
|
|
110
|
+
if (point.distanceTo(data.point!) < 0.001) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { command, type GeometryNode, type Plane, Precision, type XYZ } from "chili-core";
|
|
5
|
+
import { BoxNode } from "../../bodys";
|
|
6
|
+
import type { LengthAtAxisSnapData } from "../../snap";
|
|
7
|
+
import { type IStep, LengthAtAxisStep } from "../../step";
|
|
8
|
+
import { RectCommandBase } from "./rect";
|
|
9
|
+
|
|
10
|
+
@command({
|
|
11
|
+
key: "create.box",
|
|
12
|
+
icon: "icon-box",
|
|
13
|
+
})
|
|
14
|
+
export class Box extends RectCommandBase {
|
|
15
|
+
protected override getSteps(): IStep[] {
|
|
16
|
+
const steps = super.getSteps();
|
|
17
|
+
const third = new LengthAtAxisStep("prompt.pickNextPoint", this.getHeightStepData);
|
|
18
|
+
return [...steps, third];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private readonly getHeightStepData = (): LengthAtAxisSnapData => {
|
|
22
|
+
const plane = this.stepDatas[1].plane;
|
|
23
|
+
if (plane === undefined) {
|
|
24
|
+
throw new Error("plane is undefined, please report bug");
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
point: this.stepDatas[1].point!,
|
|
28
|
+
direction: plane.normal,
|
|
29
|
+
preview: this.previewBox,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
private readonly previewBox = (end: XYZ | undefined) => {
|
|
34
|
+
if (!end) {
|
|
35
|
+
return this.previewRect(this.stepDatas[1].point);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { plane, dx, dy } = this.rectDataFromTwoSteps();
|
|
39
|
+
return [
|
|
40
|
+
this.meshPoint(this.stepDatas[0].point!),
|
|
41
|
+
this.meshPoint(this.stepDatas[1].point!),
|
|
42
|
+
this.meshCreatedShape("box", plane, dx, dy, this.getHeight(plane, end)),
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
protected override geometryNode(): GeometryNode {
|
|
47
|
+
const rect = this.rectDataFromTwoSteps();
|
|
48
|
+
const dz = this.getHeight(rect.plane, this.stepDatas[2].point!);
|
|
49
|
+
return new BoxNode(this.document, rect.plane, rect.dx, rect.dy, dz);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private getHeight(plane: Plane, point: XYZ): number {
|
|
53
|
+
const h = point.sub(this.stepDatas[1].point!).dot(plane.normal);
|
|
54
|
+
if (Math.abs(h) < Precision.Distance) {
|
|
55
|
+
return h < 0 ? -0.00001 : 0.00001;
|
|
56
|
+
}
|
|
57
|
+
return h;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Part of the Chili3d Project, under the AGPL-3.0 License.
|
|
2
|
+
// See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { command, type GeometryNode, Precision, type XYZ } from "chili-core";
|
|
5
|
+
import { CircleNode } from "../../bodys";
|
|
6
|
+
import type { SnapLengthAtPlaneData } from "../../snap";
|
|
7
|
+
import { type IStep, LengthAtPlaneStep, PointStep } from "../../step";
|
|
8
|
+
import { CreateFaceableCommand } from "../createCommand";
|
|
9
|
+
|
|
10
|
+
@command({
|
|
11
|
+
key: "create.circle",
|
|
12
|
+
icon: "icon-circle",
|
|
13
|
+
})
|
|
14
|
+
export class Circle extends CreateFaceableCommand {
|
|
15
|
+
getSteps(): IStep[] {
|
|
16
|
+
const centerStep = new PointStep("prompt.pickCircleCenter");
|
|
17
|
+
const radiusStep = new LengthAtPlaneStep("prompt.pickRadius", this.getRadiusData);
|
|
18
|
+
return [centerStep, radiusStep];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private readonly getRadiusData = (): SnapLengthAtPlaneData => {
|
|
22
|
+
const { point, view } = this.stepDatas[0];
|
|
23
|
+
return {
|
|
24
|
+
point: () => point!,
|
|
25
|
+
preview: this.circlePreview,
|
|
26
|
+
plane: (tmp: XYZ | undefined) => this.findPlane(view, point!, tmp),
|
|
27
|
+
validator: (p: XYZ) => {
|
|
28
|
+
if (p.distanceTo(point!) < Precision.Distance) return false;
|
|
29
|
+
const plane = this.findPlane(view, point!, p);
|
|
30
|
+
return p.sub(point!).isParallelTo(plane.normal) === false;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
protected override geometryNode(): GeometryNode {
|
|
36
|
+
const [p1, p2] = [this.stepDatas[0].point!, this.stepDatas[1].point!];
|
|
37
|
+
const plane = this.stepDatas[1].plane ?? this.findPlane(this.stepDatas[1].view, p1, p2);
|
|
38
|
+
const body = new CircleNode(this.document, plane.normal, p1, plane.projectDistance(p1, p2));
|
|
39
|
+
body.isFace = this.isFace;
|
|
40
|
+
return body;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private readonly circlePreview = (end: XYZ | undefined) => {
|
|
44
|
+
if (!end) return [this.meshPoint(this.stepDatas[0].point!)];
|
|
45
|
+
|
|
46
|
+
const { point, view } = this.stepDatas[0];
|
|
47
|
+
const plane = this.findPlane(view, point!, end);
|
|
48
|
+
return [
|
|
49
|
+
this.meshPoint(this.stepDatas[0].point!),
|
|
50
|
+
this.meshLine(point!, end),
|
|
51
|
+
this.meshCreatedShape("circle", plane.normal, point!, plane.projectDistance(point!, end)),
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
}
|