brep-io-kernel 1.0.0
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/LICENSE.md +32 -0
- package/README.md +144 -0
- package/dist-kernel/brep-kernel.js +74699 -0
- package/dist-kernel/help/CONTRIBUTING.html +248 -0
- package/dist-kernel/help/LICENSE.html +248 -0
- package/dist-kernel/help/MODELING.png +0 -0
- package/dist-kernel/help/PMI.png +0 -0
- package/dist-kernel/help/SKETCH.png +0 -0
- package/dist-kernel/help/assembly-constraints__Coincident_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Angle_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Distance_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Fixed_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Parallel_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Touch_Align_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints__angle-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__coincident-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__distance-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__fixed-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__parallel-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__solver.html +248 -0
- package/dist-kernel/help/assembly-constraints__touch-align-constraint.html +248 -0
- package/dist-kernel/help/brep-api.html +263 -0
- package/dist-kernel/help/brep-kernel.html +258 -0
- package/dist-kernel/help/brep-model.html +248 -0
- package/dist-kernel/help/cylindrical-face-radius-embedding.html +290 -0
- package/dist-kernel/help/dialog-screenshots.html +248 -0
- package/dist-kernel/help/extruded-sketch-radius-embedding.html +336 -0
- package/dist-kernel/help/features__Assembly_Component_dialog.png +0 -0
- package/dist-kernel/help/features__Boolean_dialog.png +0 -0
- package/dist-kernel/help/features__Chamfer_dialog.png +0 -0
- package/dist-kernel/help/features__Datium_dialog.png +0 -0
- package/dist-kernel/help/features__Extrude_dialog.png +0 -0
- package/dist-kernel/help/features__Fillet_dialog.png +0 -0
- package/dist-kernel/help/features__Helix_dialog.png +0 -0
- package/dist-kernel/help/features__Hole_dialog.png +0 -0
- package/dist-kernel/help/features__Image_Heightmap_Solid_dialog.png +0 -0
- package/dist-kernel/help/features__Image_to_Face_dialog.png +0 -0
- package/dist-kernel/help/features__Import_3D_Model_dialog.png +0 -0
- package/dist-kernel/help/features__Loft_dialog.png +0 -0
- package/dist-kernel/help/features__Mirror_dialog.png +0 -0
- package/dist-kernel/help/features__Offset_Shell_dialog.png +0 -0
- package/dist-kernel/help/features__Overlap_Cleanup_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_Linear_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_Radial_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_dialog.png +0 -0
- package/dist-kernel/help/features__Plane_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cone_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cube_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cylinder_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Pyramid_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Sphere_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Torus_dialog.png +0 -0
- package/dist-kernel/help/features__Remesh_dialog.png +0 -0
- package/dist-kernel/help/features__Revolve_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Contour_Flange_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Cutout_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Flange_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Tab_dialog.png +0 -0
- package/dist-kernel/help/features__Sketch_dialog.png +0 -0
- package/dist-kernel/help/features__Spline_dialog.png +0 -0
- package/dist-kernel/help/features__Sweep_dialog.png +0 -0
- package/dist-kernel/help/features__Transform_dialog.png +0 -0
- package/dist-kernel/help/features__Tube_dialog.png +0 -0
- package/dist-kernel/help/features__assembly-component.html +248 -0
- package/dist-kernel/help/features__boolean.html +248 -0
- package/dist-kernel/help/features__chamfer.html +248 -0
- package/dist-kernel/help/features__datium.html +248 -0
- package/dist-kernel/help/features__datum.html +248 -0
- package/dist-kernel/help/features__extrude.html +248 -0
- package/dist-kernel/help/features__fillet.html +248 -0
- package/dist-kernel/help/features__helix.html +248 -0
- package/dist-kernel/help/features__hole.html +248 -0
- package/dist-kernel/help/features__image-heightmap-solid.html +248 -0
- package/dist-kernel/help/features__image-to-face-2D_dialog.png +0 -0
- package/dist-kernel/help/features__image-to-face-3D_dialog.png +0 -0
- package/dist-kernel/help/features__image-to-face.html +248 -0
- package/dist-kernel/help/features__import-3d-model.html +248 -0
- package/dist-kernel/help/features__index.html +248 -0
- package/dist-kernel/help/features__loft.html +248 -0
- package/dist-kernel/help/features__mirror.html +248 -0
- package/dist-kernel/help/features__offset-shell.html +248 -0
- package/dist-kernel/help/features__pattern-linear.html +248 -0
- package/dist-kernel/help/features__pattern-radial.html +248 -0
- package/dist-kernel/help/features__pattern.html +248 -0
- package/dist-kernel/help/features__plane.html +248 -0
- package/dist-kernel/help/features__primitive-cone.html +248 -0
- package/dist-kernel/help/features__primitive-cube.html +248 -0
- package/dist-kernel/help/features__primitive-cylinder.html +248 -0
- package/dist-kernel/help/features__primitive-pyramid.html +248 -0
- package/dist-kernel/help/features__primitive-sphere.html +248 -0
- package/dist-kernel/help/features__primitive-torus.html +248 -0
- package/dist-kernel/help/features__remesh.html +248 -0
- package/dist-kernel/help/features__revolve.html +248 -0
- package/dist-kernel/help/features__sheet-metal-contour-flange.html +248 -0
- package/dist-kernel/help/features__sheet-metal-flange.html +248 -0
- package/dist-kernel/help/features__sheet-metal-tab.html +248 -0
- package/dist-kernel/help/features__sketch.html +248 -0
- package/dist-kernel/help/features__spline.html +248 -0
- package/dist-kernel/help/features__sweep.html +248 -0
- package/dist-kernel/help/features__transform.html +248 -0
- package/dist-kernel/help/features__tube.html +248 -0
- package/dist-kernel/help/file-formats.html +248 -0
- package/dist-kernel/help/getting-started.html +248 -0
- package/dist-kernel/help/highlights.html +248 -0
- package/dist-kernel/help/history-systems.html +248 -0
- package/dist-kernel/help/how-it-works.html +248 -0
- package/dist-kernel/help/index.html +862 -0
- package/dist-kernel/help/input-params-schema.html +363 -0
- package/dist-kernel/help/inspector-improvements.html +248 -0
- package/dist-kernel/help/inspector.html +248 -0
- package/dist-kernel/help/modes__modeling.html +248 -0
- package/dist-kernel/help/modes__pmi.html +248 -0
- package/dist-kernel/help/modes__sketch.html +248 -0
- package/dist-kernel/help/plugins.html +248 -0
- package/dist-kernel/help/pmi-annotations__Angle_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Explode_Body_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Hole_Callout_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Leader_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Linear_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Note_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Radial_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__angle-dimension.html +248 -0
- package/dist-kernel/help/pmi-annotations__explode-body.html +248 -0
- package/dist-kernel/help/pmi-annotations__hole-callout.html +248 -0
- package/dist-kernel/help/pmi-annotations__index.html +248 -0
- package/dist-kernel/help/pmi-annotations__leader.html +248 -0
- package/dist-kernel/help/pmi-annotations__linear-dimension.html +248 -0
- package/dist-kernel/help/pmi-annotations__note.html +248 -0
- package/dist-kernel/help/pmi-annotations__radial-dimension.html +248 -0
- package/dist-kernel/help/search-index.json +464 -0
- package/dist-kernel/help/simplified-radial-dimensions.html +298 -0
- package/dist-kernel/help/solid-methods.html +359 -0
- package/dist-kernel/help/table-of-contents.html +330 -0
- package/dist-kernel/help/ui-overview.html +248 -0
- package/dist-kernel/help/whats-new.html +248 -0
- package/package.json +54 -0
- package/src/BREP/AssemblyComponent.js +42 -0
- package/src/BREP/BREP.js +43 -0
- package/src/BREP/BetterSolid.js +805 -0
- package/src/BREP/Edge.js +103 -0
- package/src/BREP/Extrude.js +403 -0
- package/src/BREP/Face.js +187 -0
- package/src/BREP/MeshRepairer.js +634 -0
- package/src/BREP/OffsetShellSolid.js +614 -0
- package/src/BREP/PointCloudWrap.js +302 -0
- package/src/BREP/Revolve.js +345 -0
- package/src/BREP/SolidMethods/authoring.js +112 -0
- package/src/BREP/SolidMethods/booleanOps.js +230 -0
- package/src/BREP/SolidMethods/chamfer.js +122 -0
- package/src/BREP/SolidMethods/edgeResolution.js +25 -0
- package/src/BREP/SolidMethods/fillet.js +792 -0
- package/src/BREP/SolidMethods/index.js +72 -0
- package/src/BREP/SolidMethods/io.js +105 -0
- package/src/BREP/SolidMethods/lifecycle.js +103 -0
- package/src/BREP/SolidMethods/manifoldOps.js +375 -0
- package/src/BREP/SolidMethods/meshCleanup.js +2512 -0
- package/src/BREP/SolidMethods/meshQueries.js +264 -0
- package/src/BREP/SolidMethods/metadata.js +106 -0
- package/src/BREP/SolidMethods/metrics.js +51 -0
- package/src/BREP/SolidMethods/transforms.js +361 -0
- package/src/BREP/SolidMethods/visualize.js +508 -0
- package/src/BREP/SolidShared.js +26 -0
- package/src/BREP/Sweep.js +1596 -0
- package/src/BREP/Tube.js +857 -0
- package/src/BREP/Vertex.js +43 -0
- package/src/BREP/applyBooleanOperation.js +704 -0
- package/src/BREP/boundsUtils.js +48 -0
- package/src/BREP/chamfer.js +551 -0
- package/src/BREP/edgePolylineUtils.js +85 -0
- package/src/BREP/fillets/common.js +388 -0
- package/src/BREP/fillets/fillet.js +1422 -0
- package/src/BREP/fillets/filletGeometry.js +15 -0
- package/src/BREP/fillets/inset.js +389 -0
- package/src/BREP/fillets/offsetHelper.js +143 -0
- package/src/BREP/fillets/outset.js +88 -0
- package/src/BREP/helix.js +193 -0
- package/src/BREP/meshToBrep.js +234 -0
- package/src/BREP/primitives.js +279 -0
- package/src/BREP/setupManifold.js +71 -0
- package/src/BREP/threadGeometry.js +1120 -0
- package/src/BREP/triangleUtils.js +8 -0
- package/src/BREP/triangulate.js +608 -0
- package/src/FeatureRegistry.js +183 -0
- package/src/PartHistory.js +1132 -0
- package/src/UI/AccordionWidget.js +292 -0
- package/src/UI/CADmaterials.js +850 -0
- package/src/UI/EnvMonacoEditor.js +522 -0
- package/src/UI/FloatingWindow.js +396 -0
- package/src/UI/HistoryWidget.js +457 -0
- package/src/UI/MainToolbar.js +131 -0
- package/src/UI/ModelLibraryView.js +194 -0
- package/src/UI/OrthoCameraIdle.js +206 -0
- package/src/UI/PluginsWidget.js +280 -0
- package/src/UI/SceneListing.js +606 -0
- package/src/UI/SelectionFilter.js +629 -0
- package/src/UI/ViewCube.js +389 -0
- package/src/UI/assembly/AssemblyConstraintCollectionWidget.js +329 -0
- package/src/UI/assembly/AssemblyConstraintControlsWidget.js +282 -0
- package/src/UI/assembly/AssemblyConstraintsWidget.css +292 -0
- package/src/UI/assembly/AssemblyConstraintsWidget.js +1373 -0
- package/src/UI/assembly/constraintFaceUtils.js +115 -0
- package/src/UI/assembly/constraintHighlightUtils.js +70 -0
- package/src/UI/assembly/constraintLabelUtils.js +31 -0
- package/src/UI/assembly/constraintPointUtils.js +64 -0
- package/src/UI/assembly/constraintSelectionUtils.js +185 -0
- package/src/UI/assembly/constraintStatusUtils.js +142 -0
- package/src/UI/componentSelectorModal.js +240 -0
- package/src/UI/controls/CombinedTransformControls.js +386 -0
- package/src/UI/dialogs.js +351 -0
- package/src/UI/expressionsManager.js +100 -0
- package/src/UI/featureDialogWidgets/booleanField.js +25 -0
- package/src/UI/featureDialogWidgets/booleanOperationField.js +97 -0
- package/src/UI/featureDialogWidgets/buttonField.js +45 -0
- package/src/UI/featureDialogWidgets/componentSelectorField.js +102 -0
- package/src/UI/featureDialogWidgets/defaultField.js +23 -0
- package/src/UI/featureDialogWidgets/fileField.js +66 -0
- package/src/UI/featureDialogWidgets/index.js +34 -0
- package/src/UI/featureDialogWidgets/numberField.js +165 -0
- package/src/UI/featureDialogWidgets/optionsField.js +33 -0
- package/src/UI/featureDialogWidgets/referenceSelectionField.js +208 -0
- package/src/UI/featureDialogWidgets/stringField.js +24 -0
- package/src/UI/featureDialogWidgets/textareaField.js +28 -0
- package/src/UI/featureDialogWidgets/threadDesignationField.js +160 -0
- package/src/UI/featureDialogWidgets/transformField.js +252 -0
- package/src/UI/featureDialogWidgets/utils.js +43 -0
- package/src/UI/featureDialogWidgets/vec3Field.js +133 -0
- package/src/UI/featureDialogs.js +1414 -0
- package/src/UI/fileManagerWidget.js +615 -0
- package/src/UI/history/HistoryCollectionWidget.js +1294 -0
- package/src/UI/history/historyCollectionWidget.css.js +257 -0
- package/src/UI/history/historyDisplayInfo.js +133 -0
- package/src/UI/mobile.js +28 -0
- package/src/UI/objectDump.js +442 -0
- package/src/UI/pmi/AnnotationCollectionWidget.js +120 -0
- package/src/UI/pmi/AnnotationHistory.js +353 -0
- package/src/UI/pmi/AnnotationRegistry.js +90 -0
- package/src/UI/pmi/BaseAnnotation.js +269 -0
- package/src/UI/pmi/LabelOverlay.css +102 -0
- package/src/UI/pmi/LabelOverlay.js +191 -0
- package/src/UI/pmi/PMIMode.js +1550 -0
- package/src/UI/pmi/PMIViewsWidget.js +1098 -0
- package/src/UI/pmi/annUtils.js +729 -0
- package/src/UI/pmi/dimensions/AngleDimensionAnnotation.js +647 -0
- package/src/UI/pmi/dimensions/ExplodeBodyAnnotation.js +507 -0
- package/src/UI/pmi/dimensions/HoleCalloutAnnotation.js +462 -0
- package/src/UI/pmi/dimensions/LeaderAnnotation.js +403 -0
- package/src/UI/pmi/dimensions/LinearDimensionAnnotation.js +532 -0
- package/src/UI/pmi/dimensions/NoteAnnotation.js +110 -0
- package/src/UI/pmi/dimensions/RadialDimensionAnnotation.js +659 -0
- package/src/UI/pmi/pmiStyle.js +44 -0
- package/src/UI/sketcher/SketchMode3D.js +4095 -0
- package/src/UI/sketcher/dimensions.js +674 -0
- package/src/UI/sketcher/glyphs.js +236 -0
- package/src/UI/sketcher/highlights.js +60 -0
- package/src/UI/toolbarButtons/aboutButton.js +5 -0
- package/src/UI/toolbarButtons/exportButton.js +609 -0
- package/src/UI/toolbarButtons/flatPatternButton.js +307 -0
- package/src/UI/toolbarButtons/importButton.js +160 -0
- package/src/UI/toolbarButtons/inspectorToggleButton.js +12 -0
- package/src/UI/toolbarButtons/metadataButton.js +1063 -0
- package/src/UI/toolbarButtons/orientToFaceButton.js +114 -0
- package/src/UI/toolbarButtons/registerDefaultButtons.js +46 -0
- package/src/UI/toolbarButtons/saveButton.js +99 -0
- package/src/UI/toolbarButtons/scriptRunnerButton.js +302 -0
- package/src/UI/toolbarButtons/testsButton.js +26 -0
- package/src/UI/toolbarButtons/undoRedoButtons.js +25 -0
- package/src/UI/toolbarButtons/wireframeToggleButton.js +5 -0
- package/src/UI/toolbarButtons/zoomToFitButton.js +5 -0
- package/src/UI/triangleDebuggerWindow.js +945 -0
- package/src/UI/viewer.js +4228 -0
- package/src/assemblyConstraints/AssemblyConstraintHistory.js +1576 -0
- package/src/assemblyConstraints/AssemblyConstraintRegistry.js +120 -0
- package/src/assemblyConstraints/BaseAssemblyConstraint.js +66 -0
- package/src/assemblyConstraints/constraintExpressionUtils.js +35 -0
- package/src/assemblyConstraints/constraintUtils/parallelAlignment.js +676 -0
- package/src/assemblyConstraints/constraints/AngleConstraint.js +485 -0
- package/src/assemblyConstraints/constraints/CoincidentConstraint.js +194 -0
- package/src/assemblyConstraints/constraints/DistanceConstraint.js +616 -0
- package/src/assemblyConstraints/constraints/FixedConstraint.js +78 -0
- package/src/assemblyConstraints/constraints/ParallelConstraint.js +252 -0
- package/src/assemblyConstraints/constraints/TouchAlignConstraint.js +961 -0
- package/src/core/entities/HistoryCollectionBase.js +72 -0
- package/src/core/entities/ListEntityBase.js +109 -0
- package/src/core/entities/schemaProcesser.js +121 -0
- package/src/exporters/sheetMetalFlatPattern.js +659 -0
- package/src/exporters/sheetMetalUnfold.js +862 -0
- package/src/exporters/step.js +1135 -0
- package/src/exporters/threeMF.js +575 -0
- package/src/features/assemblyComponent/AssemblyComponentFeature.js +780 -0
- package/src/features/boolean/BooleanFeature.js +94 -0
- package/src/features/chamfer/ChamferFeature.js +116 -0
- package/src/features/datium/DatiumFeature.js +80 -0
- package/src/features/edgeFeatureUtils.js +41 -0
- package/src/features/extrude/ExtrudeFeature.js +143 -0
- package/src/features/fillet/FilletFeature.js +197 -0
- package/src/features/helix/HelixFeature.js +405 -0
- package/src/features/hole/HoleFeature.js +1050 -0
- package/src/features/hole/screwClearance.js +86 -0
- package/src/features/hole/threadDesignationCatalog.js +149 -0
- package/src/features/imageHeightSolid/ImageHeightmapSolidFeature.js +463 -0
- package/src/features/imageToFace/ImageToFaceFeature.js +727 -0
- package/src/features/imageToFace/imageEditor.js +1270 -0
- package/src/features/imageToFace/traceUtils.js +971 -0
- package/src/features/import3dModel/Import3dModelFeature.js +151 -0
- package/src/features/loft/LoftFeature.js +605 -0
- package/src/features/mirror/MirrorFeature.js +151 -0
- package/src/features/offsetFace/OffsetFaceFeature.js +370 -0
- package/src/features/offsetShell/OffsetShellFeature.js +89 -0
- package/src/features/overlapCleanup/OverlapCleanupFeature.js +85 -0
- package/src/features/pattern/PatternFeature.js +275 -0
- package/src/features/patternLinear/PatternLinearFeature.js +120 -0
- package/src/features/patternRadial/PatternRadialFeature.js +186 -0
- package/src/features/plane/PlaneFeature.js +154 -0
- package/src/features/primitiveCone/primitiveConeFeature.js +99 -0
- package/src/features/primitiveCube/primitiveCubeFeature.js +70 -0
- package/src/features/primitiveCylinder/primitiveCylinderFeature.js +91 -0
- package/src/features/primitivePyramid/primitivePyramidFeature.js +72 -0
- package/src/features/primitiveSphere/primitiveSphereFeature.js +62 -0
- package/src/features/primitiveTorus/primitiveTorusFeature.js +109 -0
- package/src/features/remesh/RemeshFeature.js +97 -0
- package/src/features/revolve/RevolveFeature.js +111 -0
- package/src/features/selectionUtils.js +118 -0
- package/src/features/sheetMetal/SheetMetalContourFlangeFeature.js +1656 -0
- package/src/features/sheetMetal/SheetMetalCutoutFeature.js +1056 -0
- package/src/features/sheetMetal/SheetMetalFlangeFeature.js +1568 -0
- package/src/features/sheetMetal/SheetMetalHemFeature.js +43 -0
- package/src/features/sheetMetal/SheetMetalObject.js +141 -0
- package/src/features/sheetMetal/SheetMetalTabFeature.js +176 -0
- package/src/features/sheetMetal/UNFOLD_NEUTRAL_REQUIREMENTS.md +153 -0
- package/src/features/sheetMetal/contour-flange-rebuild-spec.md +261 -0
- package/src/features/sheetMetal/profileUtils.js +25 -0
- package/src/features/sheetMetal/sheetMetalCleanup.js +9 -0
- package/src/features/sheetMetal/sheetMetalFaceTypes.js +146 -0
- package/src/features/sheetMetal/sheetMetalMetadata.js +165 -0
- package/src/features/sheetMetal/sheetMetalPipeline.js +169 -0
- package/src/features/sheetMetal/sheetMetalProfileUtils.js +216 -0
- package/src/features/sheetMetal/sheetMetalTabUtils.js +29 -0
- package/src/features/sheetMetal/sheetMetalTree.js +210 -0
- package/src/features/sketch/SketchFeature.js +955 -0
- package/src/features/sketch/sketchSolver2D/ConstraintEngine.js +800 -0
- package/src/features/sketch/sketchSolver2D/constraintDefinitions.js +704 -0
- package/src/features/sketch/sketchSolver2D/mathHelpersMod.js +307 -0
- package/src/features/spline/SplineEditorSession.js +988 -0
- package/src/features/spline/SplineFeature.js +1388 -0
- package/src/features/spline/splineUtils.js +218 -0
- package/src/features/sweep/SweepFeature.js +110 -0
- package/src/features/transform/TransformFeature.js +152 -0
- package/src/features/tube/TubeFeature.js +635 -0
- package/src/fs.proxy.js +625 -0
- package/src/idbStorage.js +254 -0
- package/src/index.js +12 -0
- package/src/main.js +15 -0
- package/src/metadataManager.js +64 -0
- package/src/path.proxy.js +277 -0
- package/src/plugins/ghLoader.worker.js +151 -0
- package/src/plugins/pluginManager.js +286 -0
- package/src/pmi/PMIViewsManager.js +134 -0
- package/src/services/componentLibrary.js +198 -0
- package/src/tests/ConsoleCapture.js +189 -0
- package/src/tests/S7-diagnostics-2025-12-23T18-37-23-570Z.json +630 -0
- package/src/tests/browserTests.js +597 -0
- package/src/tests/debugBoolean.js +225 -0
- package/src/tests/partFiles/badBoolean.json +957 -0
- package/src/tests/partFiles/extrudeTest.json +88 -0
- package/src/tests/partFiles/filletFail.json +58 -0
- package/src/tests/partFiles/import_TEst.part.part.json +646 -0
- package/src/tests/partFiles/sheetMetalHem.BREP.json +734 -0
- package/src/tests/test_boolean_subtract.js +27 -0
- package/src/tests/test_chamfer.js +17 -0
- package/src/tests/test_extrudeFace.js +24 -0
- package/src/tests/test_fillet.js +17 -0
- package/src/tests/test_fillet_nonClosed.js +45 -0
- package/src/tests/test_filletsMoreDifficult.js +46 -0
- package/src/tests/test_history_features_basic.js +149 -0
- package/src/tests/test_hole.js +282 -0
- package/src/tests/test_mirror.js +16 -0
- package/src/tests/test_offsetShellGrouping.js +85 -0
- package/src/tests/test_plane.js +4 -0
- package/src/tests/test_primitiveCone.js +11 -0
- package/src/tests/test_primitiveCube.js +7 -0
- package/src/tests/test_primitiveCylinder.js +8 -0
- package/src/tests/test_primitivePyramid.js +9 -0
- package/src/tests/test_primitiveSphere.js +17 -0
- package/src/tests/test_primitiveTorus.js +21 -0
- package/src/tests/test_pushFace.js +126 -0
- package/src/tests/test_sheetMetalContourFlange.js +125 -0
- package/src/tests/test_sheetMetal_features.js +80 -0
- package/src/tests/test_sketch_openLoop.js +45 -0
- package/src/tests/test_solidMetrics.js +58 -0
- package/src/tests/test_stlLoader.js +1889 -0
- package/src/tests/test_sweepFace.js +55 -0
- package/src/tests/test_tube.js +45 -0
- package/src/tests/test_tube_closedLoop.js +67 -0
- package/src/tests/tests.js +493 -0
- package/src/tools/assemblyConstraintDialogCapturePage.js +56 -0
- package/src/tools/dialogCapturePageFactory.js +227 -0
- package/src/tools/featureDialogCapturePage.js +47 -0
- package/src/tools/pmiAnnotationDialogCapturePage.js +60 -0
- package/src/utils/axisHelpers.js +99 -0
- package/src/utils/deepClone.js +69 -0
- package/src/utils/geometryTolerance.js +37 -0
- package/src/utils/normalizeTypeString.js +8 -0
- package/src/utils/xformMath.js +51 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const STYLE_ID = 'model-library-styles';
|
|
2
|
+
|
|
3
|
+
function ensureStyles() {
|
|
4
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
5
|
+
const style = document.createElement('style');
|
|
6
|
+
style.id = STYLE_ID;
|
|
7
|
+
style.textContent = `
|
|
8
|
+
.fm-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-bottom: 1px solid #1f2937; background: transparent; transition: background-color .12s ease; }
|
|
9
|
+
.fm-row:hover { background: #0f172a; }
|
|
10
|
+
.fm-row.header { background: #111827; border-bottom: 1px solid #1f2937; padding-bottom: 8px; margin-bottom: 4px; }
|
|
11
|
+
.fm-row:last-child { border-bottom: 0; }
|
|
12
|
+
.fm-row.is-selected { background: rgba(59,130,246,.18); }
|
|
13
|
+
.fm-grow { flex: 1 1 auto; overflow: hidden; }
|
|
14
|
+
.fm-thumb { flex: 0 0 auto; width: 60px; height: 60px; border-radius: 6px; border: 1px solid #1f2937; background: #0b0e14; object-fit: contain; image-rendering: auto; }
|
|
15
|
+
.fm-name { font-weight: 600; color: #e5e7eb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
|
|
16
|
+
.fm-date { font-size: 11px; color: #9ca3af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
|
|
17
|
+
.fm-btn { background: rgba(255,255,255,.03); color: #f9fafb; border: 1px solid #374151; padding: 2px 6px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12px; line-height: 1; min-width: 26px; height: 24px; display: inline-flex; align-items: center; justify-content: center; transition: border-color .15s ease, background-color .15s ease, transform .05s ease; }
|
|
18
|
+
.fm-btn:hover { border-color: #3b82f6; background: rgba(59,130,246,.12); }
|
|
19
|
+
.fm-btn:active { transform: translateY(1px); }
|
|
20
|
+
.fm-btn.danger { border-color: #7f1d1d; color: #fecaca; }
|
|
21
|
+
.fm-btn.danger:hover { border-color: #ef4444; background: rgba(239,68,68,.15); color: #fff; }
|
|
22
|
+
.fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; padding: 6px; }
|
|
23
|
+
.fm-item { position: relative; display: flex; align-items: center; justify-content: center; padding: 8px; border: 1px solid #1f2937; border-radius: 8px; background: transparent; transition: background-color .12s ease, border-color .12s ease; cursor: pointer; }
|
|
24
|
+
.fm-item:hover { background: #0f172a; border-color: #334155; }
|
|
25
|
+
.fm-item.is-selected { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,.25); }
|
|
26
|
+
.fm-item .fm-thumb { width: 60px; height: 60px; border: 1px solid #1f2937; background: #0b0e14; border-radius: 6px; }
|
|
27
|
+
.fm-item .fm-del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0; line-height: 1; }
|
|
28
|
+
.fm-empty { padding: 12px; color: #94a3b8; text-align: center; font-size: 13px; }
|
|
29
|
+
`;
|
|
30
|
+
document.head.appendChild(style);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class ModelLibraryView {
|
|
34
|
+
constructor({
|
|
35
|
+
container,
|
|
36
|
+
iconsOnly = false,
|
|
37
|
+
allowDelete = false,
|
|
38
|
+
showOpenButton = true,
|
|
39
|
+
openButtonLabel = '📂',
|
|
40
|
+
deleteButtonLabel = '✕',
|
|
41
|
+
onOpen,
|
|
42
|
+
onDelete,
|
|
43
|
+
loadThumbnail,
|
|
44
|
+
emptyMessage = 'No entries.',
|
|
45
|
+
selectedName = null,
|
|
46
|
+
} = {}) {
|
|
47
|
+
if (!container) throw new Error('ModelLibraryView requires a container element.');
|
|
48
|
+
ensureStyles();
|
|
49
|
+
this.container = container;
|
|
50
|
+
this.iconsOnly = !!iconsOnly;
|
|
51
|
+
this.allowDelete = !!allowDelete;
|
|
52
|
+
this.showOpenButton = showOpenButton !== false;
|
|
53
|
+
this.openButtonLabel = openButtonLabel;
|
|
54
|
+
this.deleteButtonLabel = deleteButtonLabel;
|
|
55
|
+
this.onOpen = typeof onOpen === 'function' ? onOpen : () => {};
|
|
56
|
+
this.onDelete = typeof onDelete === 'function' ? onDelete : null;
|
|
57
|
+
this.loadThumbnail = typeof loadThumbnail === 'function' ? loadThumbnail : null;
|
|
58
|
+
this.emptyMessage = emptyMessage;
|
|
59
|
+
this.selectedName = selectedName;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setIconsOnly(flag) {
|
|
63
|
+
this.iconsOnly = !!flag;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setSelected(name) {
|
|
67
|
+
this.selectedName = name || null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setEmptyMessage(message) {
|
|
71
|
+
this.emptyMessage = message;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render(items) {
|
|
75
|
+
const list = Array.isArray(items) ? items : [];
|
|
76
|
+
while (this.container.firstChild) this.container.removeChild(this.container.firstChild);
|
|
77
|
+
if (!list.length) {
|
|
78
|
+
const empty = document.createElement('div');
|
|
79
|
+
empty.className = 'fm-empty';
|
|
80
|
+
empty.textContent = this.emptyMessage;
|
|
81
|
+
this.container.appendChild(empty);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (this.iconsOnly) {
|
|
85
|
+
this._renderIconsView(list);
|
|
86
|
+
} else {
|
|
87
|
+
this._renderListView(list);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
_renderListView(items) {
|
|
92
|
+
for (const entry of items) {
|
|
93
|
+
const row = document.createElement('div');
|
|
94
|
+
row.className = 'fm-row';
|
|
95
|
+
if (this.selectedName && entry.name === this.selectedName) row.classList.add('is-selected');
|
|
96
|
+
|
|
97
|
+
const thumb = document.createElement('img');
|
|
98
|
+
thumb.className = 'fm-thumb';
|
|
99
|
+
thumb.alt = `${entry.name} thumbnail`;
|
|
100
|
+
this._applyThumbnail(entry, thumb);
|
|
101
|
+
thumb.addEventListener('click', () => this.onOpen(entry.name, entry));
|
|
102
|
+
row.appendChild(thumb);
|
|
103
|
+
|
|
104
|
+
const left = document.createElement('div');
|
|
105
|
+
left.className = 'fm-left fm-grow';
|
|
106
|
+
const nameBtn = document.createElement('div');
|
|
107
|
+
nameBtn.className = 'fm-name';
|
|
108
|
+
nameBtn.textContent = entry.name;
|
|
109
|
+
nameBtn.addEventListener('click', () => this.onOpen(entry.name, entry));
|
|
110
|
+
left.appendChild(nameBtn);
|
|
111
|
+
const dateLine = document.createElement('div');
|
|
112
|
+
dateLine.className = 'fm-date';
|
|
113
|
+
const dt = new Date(entry.savedAt);
|
|
114
|
+
dateLine.textContent = isNaN(dt) ? String(entry.savedAt || '') : dt.toLocaleString();
|
|
115
|
+
left.appendChild(dateLine);
|
|
116
|
+
row.appendChild(left);
|
|
117
|
+
|
|
118
|
+
if (this.showOpenButton) {
|
|
119
|
+
const openBtn = document.createElement('button');
|
|
120
|
+
openBtn.type = 'button';
|
|
121
|
+
openBtn.className = 'fm-btn';
|
|
122
|
+
openBtn.textContent = this.openButtonLabel;
|
|
123
|
+
openBtn.addEventListener('click', () => this.onOpen(entry.name, entry));
|
|
124
|
+
row.appendChild(openBtn);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (this.allowDelete && this.onDelete) {
|
|
128
|
+
const delBtn = document.createElement('button');
|
|
129
|
+
delBtn.type = 'button';
|
|
130
|
+
delBtn.className = 'fm-btn danger';
|
|
131
|
+
delBtn.textContent = this.deleteButtonLabel;
|
|
132
|
+
delBtn.addEventListener('click', (ev) => {
|
|
133
|
+
ev.stopPropagation();
|
|
134
|
+
this.onDelete(entry.name, entry);
|
|
135
|
+
});
|
|
136
|
+
row.appendChild(delBtn);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.container.appendChild(row);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
_renderIconsView(items) {
|
|
144
|
+
const grid = document.createElement('div');
|
|
145
|
+
grid.className = 'fm-grid';
|
|
146
|
+
this.container.appendChild(grid);
|
|
147
|
+
|
|
148
|
+
for (const entry of items) {
|
|
149
|
+
const cell = document.createElement('div');
|
|
150
|
+
cell.className = 'fm-item';
|
|
151
|
+
if (this.selectedName && entry.name === this.selectedName) cell.classList.add('is-selected');
|
|
152
|
+
const timestamp = new Date(entry.savedAt);
|
|
153
|
+
const timeLabel = isNaN(timestamp) ? String(entry.savedAt || '') : timestamp.toLocaleString();
|
|
154
|
+
cell.title = `${entry.name}\n${timeLabel}`;
|
|
155
|
+
cell.addEventListener('click', () => this.onOpen(entry.name, entry));
|
|
156
|
+
|
|
157
|
+
const img = document.createElement('img');
|
|
158
|
+
img.className = 'fm-thumb';
|
|
159
|
+
img.alt = `${entry.name} thumbnail`;
|
|
160
|
+
this._applyThumbnail(entry, img);
|
|
161
|
+
cell.appendChild(img);
|
|
162
|
+
|
|
163
|
+
if (this.allowDelete && this.onDelete) {
|
|
164
|
+
const delBtn = document.createElement('button');
|
|
165
|
+
delBtn.type = 'button';
|
|
166
|
+
delBtn.className = 'fm-btn danger fm-del';
|
|
167
|
+
delBtn.textContent = this.deleteButtonLabel;
|
|
168
|
+
delBtn.title = `Delete ${entry.name}`;
|
|
169
|
+
delBtn.addEventListener('click', (ev) => {
|
|
170
|
+
ev.stopPropagation();
|
|
171
|
+
this.onDelete(entry.name, entry);
|
|
172
|
+
});
|
|
173
|
+
cell.appendChild(delBtn);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
grid.appendChild(cell);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
_applyThumbnail(entry, imgEl) {
|
|
181
|
+
if (!this.loadThumbnail || !imgEl) return;
|
|
182
|
+
if (entry?.thumbnail) {
|
|
183
|
+
try { imgEl.src = entry.thumbnail; } catch {}
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const res = this.loadThumbnail(entry, imgEl);
|
|
187
|
+
if (res && typeof res.then === 'function') {
|
|
188
|
+
res.catch(() => {});
|
|
189
|
+
}
|
|
190
|
+
} catch {
|
|
191
|
+
// ignore thumbnail load errors
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// OrthoCameraIdle.js
|
|
2
|
+
// ES6, no frameworks. three >= 0.150
|
|
3
|
+
// Usage example at bottom.
|
|
4
|
+
|
|
5
|
+
import { OrthographicCamera, Matrix4 } from 'three';
|
|
6
|
+
|
|
7
|
+
export class OrthoCameraIdle extends OrthographicCamera {
|
|
8
|
+
constructor(left, right, top, bottom, near = 0.000000001, far = 200000000) {
|
|
9
|
+
super(left, right, top, bottom, near, far);
|
|
10
|
+
|
|
11
|
+
this._idle = {
|
|
12
|
+
onIdle: null,
|
|
13
|
+
onMove: null,
|
|
14
|
+
idleMs: 250,
|
|
15
|
+
matrixEpsilon: 1e-6,
|
|
16
|
+
projEpsilon: 1e-6,
|
|
17
|
+
controls: null,
|
|
18
|
+
prevWorld: new Matrix4(),
|
|
19
|
+
prevProj: new Matrix4(),
|
|
20
|
+
lastChange: performance.now(),
|
|
21
|
+
moving: false,
|
|
22
|
+
raf: 0,
|
|
23
|
+
disposed: true,
|
|
24
|
+
_controlsHandler: this._handleControlsChange.bind(this)
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
this.updateMatrixWorld(true);
|
|
28
|
+
this._idle.prevWorld.copy(this.matrixWorld);
|
|
29
|
+
this._idle.prevProj.copy(this.projectionMatrix);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Start watching for camera idle/move.
|
|
34
|
+
* @param {Object} opts
|
|
35
|
+
* @param {Function} opts.onIdle - required
|
|
36
|
+
* @param {Function} [opts.onMove] - optional
|
|
37
|
+
* @param {number} [opts.idleMs=250]
|
|
38
|
+
* @param {number} [opts.matrixEpsilon=1e-6]
|
|
39
|
+
* @param {number} [opts.projEpsilon=1e-6]
|
|
40
|
+
* @param {Object} [opts.controls] - ArcballControls instance
|
|
41
|
+
*/
|
|
42
|
+
enableIdleCallbacks({
|
|
43
|
+
onIdle,
|
|
44
|
+
onMove = null,
|
|
45
|
+
idleMs = 250,
|
|
46
|
+
matrixEpsilon = 1e-6,
|
|
47
|
+
projEpsilon = 1e-6,
|
|
48
|
+
controls = null
|
|
49
|
+
} = {}) {
|
|
50
|
+
if (typeof onIdle !== 'function') {
|
|
51
|
+
throw new Error('OrthoCameraIdle.enableIdleCallbacks: onIdle(callback) is required.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const s = this._idle;
|
|
55
|
+
this.disableIdleCallbacks(); // reset if already running
|
|
56
|
+
|
|
57
|
+
s.onIdle = onIdle;
|
|
58
|
+
s.onMove = typeof onMove === 'function' ? onMove : null;
|
|
59
|
+
s.idleMs = idleMs;
|
|
60
|
+
s.matrixEpsilon = matrixEpsilon;
|
|
61
|
+
s.projEpsilon = projEpsilon;
|
|
62
|
+
s.controls = controls || null;
|
|
63
|
+
s.lastChange = performance.now();
|
|
64
|
+
s.moving = false;
|
|
65
|
+
s.disposed = false;
|
|
66
|
+
|
|
67
|
+
if (s.controls && typeof s.controls.addEventListener === 'function') {
|
|
68
|
+
s.controls.addEventListener('start', s._controlsHandler);
|
|
69
|
+
s.controls.addEventListener('change', s._controlsHandler);
|
|
70
|
+
s.controls.addEventListener('end', s._controlsHandler);
|
|
71
|
+
s.controls.addEventListener('wheel', s._controlsHandler);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const loop = () => {
|
|
75
|
+
if (s.disposed) return;
|
|
76
|
+
const now = performance.now();
|
|
77
|
+
|
|
78
|
+
// ensure matrices current
|
|
79
|
+
this.updateMatrixWorld(true);
|
|
80
|
+
|
|
81
|
+
// detect any change in world transform OR projection (covers zoom/frustum)
|
|
82
|
+
let changed = this._matrixChanged(this.matrixWorld, s.prevWorld, s.matrixEpsilon);
|
|
83
|
+
if (!changed) {
|
|
84
|
+
changed = this._matrixChanged(this.projectionMatrix, s.prevProj, s.projEpsilon);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (changed) {
|
|
88
|
+
s.prevWorld.copy(this.matrixWorld);
|
|
89
|
+
s.prevProj.copy(this.projectionMatrix);
|
|
90
|
+
s.lastChange = now;
|
|
91
|
+
if (!s.moving) {
|
|
92
|
+
s.moving = true;
|
|
93
|
+
if (s.onMove) s.onMove();
|
|
94
|
+
}
|
|
95
|
+
} else if (s.moving && (now - s.lastChange) >= s.idleMs) {
|
|
96
|
+
s.moving = false;
|
|
97
|
+
s.onIdle();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
s.raf = requestAnimationFrame(loop);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
s.raf = requestAnimationFrame(loop);
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Stop watching and detach any listeners.
|
|
109
|
+
*/
|
|
110
|
+
disableIdleCallbacks() {
|
|
111
|
+
const s = this._idle;
|
|
112
|
+
if (s.disposed) return this;
|
|
113
|
+
s.disposed = true;
|
|
114
|
+
cancelAnimationFrame(s.raf);
|
|
115
|
+
if (s.controls && typeof s.controls.removeEventListener === 'function') {
|
|
116
|
+
s.controls.removeEventListener('start', s._controlsHandler);
|
|
117
|
+
s.controls.removeEventListener('change', s._controlsHandler);
|
|
118
|
+
s.controls.removeEventListener('end', s._controlsHandler);
|
|
119
|
+
s.controls.removeEventListener('wheel', s._controlsHandler);
|
|
120
|
+
}
|
|
121
|
+
s.controls = null;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Swap/attach ArcballControls at runtime (keeps callbacks/settings).
|
|
127
|
+
*/
|
|
128
|
+
attachControls(controls) {
|
|
129
|
+
const s = this._idle;
|
|
130
|
+
s.controls = controls;
|
|
131
|
+
if (!s.disposed) {
|
|
132
|
+
// Rebind listeners cleanly
|
|
133
|
+
this.disableIdleCallbacks();
|
|
134
|
+
this.enableIdleCallbacks({
|
|
135
|
+
onIdle: s.onIdle,
|
|
136
|
+
onMove: s.onMove,
|
|
137
|
+
idleMs: s.idleMs,
|
|
138
|
+
matrixEpsilon: s.matrixEpsilon,
|
|
139
|
+
projEpsilon: s.projEpsilon,
|
|
140
|
+
controls
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
setIdleThreshold(ms) { this._idle.idleMs = ms; return this; }
|
|
147
|
+
setIdleEpsilon({ matrixEpsilon, projEpsilon } = {}) {
|
|
148
|
+
if (typeof matrixEpsilon === 'number') this._idle.matrixEpsilon = matrixEpsilon;
|
|
149
|
+
if (typeof projEpsilon === 'number') this._idle.projEpsilon = projEpsilon;
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
setIdleCallbacks({ onIdle, onMove } = {}) {
|
|
153
|
+
if (typeof onIdle === 'function') this._idle.onIdle = onIdle;
|
|
154
|
+
if (typeof onMove === 'function' || onMove === null) this._idle.onMove = onMove;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// --- internals ---
|
|
159
|
+
_handleControlsChange() {
|
|
160
|
+
const s = this._idle;
|
|
161
|
+
if (s.disposed) return;
|
|
162
|
+
s.lastChange = performance.now();
|
|
163
|
+
if (!s.moving) {
|
|
164
|
+
s.moving = true;
|
|
165
|
+
if (s.onMove) s.onMove();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_matrixChanged(a, b, eps) {
|
|
170
|
+
const ae = a.elements, be = b.elements;
|
|
171
|
+
// Quick translation check (12, 13, 14)
|
|
172
|
+
if (Math.abs(ae[12] - be[12]) > eps) return true;
|
|
173
|
+
if (Math.abs(ae[13] - be[13]) > eps) return true;
|
|
174
|
+
if (Math.abs(ae[14] - be[14]) > eps) return true;
|
|
175
|
+
// Remaining entries
|
|
176
|
+
for (let i = 0; i < 12; i++) {
|
|
177
|
+
if (Math.abs(ae[i] - be[i]) > eps) return true;
|
|
178
|
+
}
|
|
179
|
+
if (Math.abs(ae[15] - be[15]) > eps) return true;
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* ---------- Minimal usage ----------
|
|
185
|
+
import { WebGLRenderer } from 'three';
|
|
186
|
+
import { ArcballControls } from 'three/examples/jsm/controls/ArcballControls.js';
|
|
187
|
+
import { OrthoCameraIdle } from './OrthoCameraIdle.js';
|
|
188
|
+
|
|
189
|
+
const renderer = new WebGLRenderer({ antialias: true });
|
|
190
|
+
document.body.appendChild(renderer.domElement);
|
|
191
|
+
|
|
192
|
+
const cam = new OrthoCameraIdle(-2, 2, 2, -2, 0.1, 1000);
|
|
193
|
+
cam.position.set(5, 5, 5);
|
|
194
|
+
cam.lookAt(0, 0, 0);
|
|
195
|
+
|
|
196
|
+
const controls = new ArcballControls(cam, renderer.domElement);
|
|
197
|
+
controls.update();
|
|
198
|
+
|
|
199
|
+
cam.enableIdleCallbacks({
|
|
200
|
+
controls,
|
|
201
|
+
idleMs: 300,
|
|
202
|
+
onMove: () => console.log('camera moving...'),
|
|
203
|
+
onIdle: () => console.log('camera stopped.')
|
|
204
|
+
});
|
|
205
|
+
------------------------------------*/
|
|
206
|
+
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// PluginsWidget - manage plugin URLs (GitHub repos or generic base/entry URLs)
|
|
2
|
+
import { getSavedPluginUrls, savePluginUrls, loadPlugins, parseGithubUrl, getPluginEnabledMap, savePluginEnabledMap } from '../plugins/pluginManager.js';
|
|
3
|
+
|
|
4
|
+
export class PluginsWidget {
|
|
5
|
+
constructor(viewer) {
|
|
6
|
+
this.viewer = viewer;
|
|
7
|
+
this.uiElement = document.createElement('div');
|
|
8
|
+
this._ensureStyles();
|
|
9
|
+
this._buildUI();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_ensureStyles() {
|
|
13
|
+
if (document.getElementById('plugins-widget-styles')) return;
|
|
14
|
+
const style = document.createElement('style');
|
|
15
|
+
style.id = 'plugins-widget-styles';
|
|
16
|
+
style.textContent = `
|
|
17
|
+
.plg-col { display: flex; flex-direction: column; gap: 6px; }
|
|
18
|
+
.plg-row { display: flex; gap: 6px; align-items: center; }
|
|
19
|
+
.plg-list { width: 100%; min-height: 120px; max-height: 220px; overflow: auto; background: #0b0e14; color: #e5e7eb; border: 1px solid #1f2937; border-radius: 8px; padding: 4px; }
|
|
20
|
+
.plg-item { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: default; }
|
|
21
|
+
.plg-item:hover { background: rgba(255,255,255,.03); }
|
|
22
|
+
.plg-item.selected { outline: 1px solid #374151; background: rgba(59,130,246,.08); }
|
|
23
|
+
.plg-url { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; user-select: text; }
|
|
24
|
+
.plg-btn { background: rgba(255,255,255,.03); color: #f9fafb; border: 1px solid #374151; padding: 4px 8px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12px; line-height: 1; transition: border-color .15s ease, background-color .15s ease, transform .05s ease; }
|
|
25
|
+
.plg-btn:hover { border-color: #3b82f6; background: rgba(59,130,246,.12); }
|
|
26
|
+
.plg-btn:active { transform: translateY(1px); }
|
|
27
|
+
.plg-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
28
|
+
.plg-hint { color: #9aa0aa; font-size: 11px; }
|
|
29
|
+
.plg-status { color: #9ca3af; font-size: 11px; white-space: pre-wrap; }
|
|
30
|
+
|
|
31
|
+
/* Modal styles */
|
|
32
|
+
.plg-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
|
|
33
|
+
.plg-modal { background: #0b0e14; color: #e5e7eb; border: 1px solid #1f2937; border-radius: 10px; padding: 14px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
|
|
34
|
+
.plg-modal h3 { margin: 0 0 8px 0; font-size: 14px; }
|
|
35
|
+
.plg-modal p { margin: 6px 0; color: #9aa0aa; font-size: 12px; }
|
|
36
|
+
.plg-input { width: 100%; border-radius: 8px; padding: 6px 8px; margin-bottom: 20px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; }
|
|
37
|
+
.plg-modal .plg-row { margin-top: 10px; justify-content: flex-end; }
|
|
38
|
+
.plg-err { color: #ef4444; font-size: 12px; min-height: 16px; }
|
|
39
|
+
`;
|
|
40
|
+
document.head.appendChild(style);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_buildUI() {
|
|
44
|
+
const col = document.createElement('div');
|
|
45
|
+
col.className = 'plg-col';
|
|
46
|
+
// internal list state
|
|
47
|
+
this.urls = getSavedPluginUrls();
|
|
48
|
+
this.enabledMap = getPluginEnabledMap();
|
|
49
|
+
this._selectedIndex = -1;
|
|
50
|
+
|
|
51
|
+
// List of plugins as a custom list with checkboxes
|
|
52
|
+
this.listEl = document.createElement('div');
|
|
53
|
+
this.listEl.className = 'plg-list';
|
|
54
|
+
this._refreshList();
|
|
55
|
+
|
|
56
|
+
const actions = document.createElement('div');
|
|
57
|
+
actions.className = 'plg-row';
|
|
58
|
+
const addBtn = document.createElement('button');
|
|
59
|
+
addBtn.className = 'plg-btn';
|
|
60
|
+
addBtn.textContent = 'Add';
|
|
61
|
+
this.delBtn = document.createElement('button');
|
|
62
|
+
this.delBtn.className = 'plg-btn';
|
|
63
|
+
this.delBtn.textContent = 'Delete';
|
|
64
|
+
const loadBtn = document.createElement('button');
|
|
65
|
+
loadBtn.className = 'plg-btn';
|
|
66
|
+
loadBtn.textContent = 'Load Plugins Now';
|
|
67
|
+
this.statusEl = document.createElement('div');
|
|
68
|
+
this.statusEl.className = 'plg-status';
|
|
69
|
+
|
|
70
|
+
addBtn.addEventListener('click', () => this._openAddModal());
|
|
71
|
+
this.delBtn.addEventListener('click', () => this._deleteSelected());
|
|
72
|
+
loadBtn.addEventListener('click', async () => {
|
|
73
|
+
this._setStatus('Loading...');
|
|
74
|
+
const list = Array.isArray(this.urls) ? this.urls : [];
|
|
75
|
+
const enabled = this.enabledMap && typeof this.enabledMap === 'object' ? this.enabledMap : {};
|
|
76
|
+
const toLoad = list.filter(u => enabled[u] !== false);
|
|
77
|
+
const res = await loadPlugins(this.viewer, toLoad || []);
|
|
78
|
+
const lines = res.map(r => `${r.ok ? 'OK' : 'ERR'} ${r.url}${r.ok ? '' : ' ' + (r.error?.message || r.error)}`);
|
|
79
|
+
this._setStatus(lines.join('\n') || 'No plugins listed.');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
actions.appendChild(addBtn);
|
|
83
|
+
actions.appendChild(this.delBtn);
|
|
84
|
+
actions.appendChild(loadBtn);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
col.appendChild(this.listEl);
|
|
88
|
+
col.appendChild(actions);
|
|
89
|
+
col.appendChild(this.statusEl);
|
|
90
|
+
this.uiElement.appendChild(col);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_refreshList() {
|
|
94
|
+
try { this.listEl.innerHTML = ''; } catch { }
|
|
95
|
+
const list = Array.isArray(this.urls) ? this.urls : [];
|
|
96
|
+
const enabled = this.enabledMap && typeof this.enabledMap === 'object' ? this.enabledMap : {};
|
|
97
|
+
if (!list.length) {
|
|
98
|
+
const empty = document.createElement('div');
|
|
99
|
+
empty.className = 'plg-item';
|
|
100
|
+
empty.style.opacity = '0.7';
|
|
101
|
+
empty.textContent = 'No plugins saved';
|
|
102
|
+
this.listEl.appendChild(empty);
|
|
103
|
+
this._selectedIndex = -1;
|
|
104
|
+
} else {
|
|
105
|
+
list.forEach((url, idx) => {
|
|
106
|
+
const row = document.createElement('div');
|
|
107
|
+
row.className = 'plg-item' + (idx === this._selectedIndex ? ' selected' : '');
|
|
108
|
+
|
|
109
|
+
const cb = document.createElement('input');
|
|
110
|
+
cb.type = 'checkbox';
|
|
111
|
+
cb.checked = enabled[url] !== false; // default to true
|
|
112
|
+
cb.title = 'Enable/disable loading this plugin';
|
|
113
|
+
cb.addEventListener('change', () => {
|
|
114
|
+
this.enabledMap[url] = Boolean(cb.checked);
|
|
115
|
+
try { savePluginEnabledMap(this.enabledMap); } catch {}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const label = document.createElement('div');
|
|
119
|
+
label.className = 'plg-url';
|
|
120
|
+
label.textContent = url;
|
|
121
|
+
|
|
122
|
+
const selectRow = (e) => {
|
|
123
|
+
// Avoid toggling selection when clicking checkbox intentionally
|
|
124
|
+
if (e && e.target === cb) return;
|
|
125
|
+
this._selectedIndex = idx;
|
|
126
|
+
Array.from(this.listEl.children).forEach((child, i) => {
|
|
127
|
+
if (!(child instanceof HTMLElement)) return;
|
|
128
|
+
child.classList.toggle('selected', i === idx);
|
|
129
|
+
});
|
|
130
|
+
if (this.delBtn) this.delBtn.disabled = list.length === 0 || this._selectedIndex < 0;
|
|
131
|
+
};
|
|
132
|
+
row.addEventListener('click', selectRow);
|
|
133
|
+
|
|
134
|
+
row.appendChild(cb);
|
|
135
|
+
row.appendChild(label);
|
|
136
|
+
this.listEl.appendChild(row);
|
|
137
|
+
});
|
|
138
|
+
if (this._selectedIndex < 0 && list.length > 0) {
|
|
139
|
+
this._selectedIndex = 0;
|
|
140
|
+
if (this.listEl.firstChild) this.listEl.firstChild.classList.add('selected');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (this.delBtn) this.delBtn.disabled = list.length === 0 || this._selectedIndex < 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_save() { try { savePluginUrls(this.urls || []); } catch { } }
|
|
147
|
+
|
|
148
|
+
_openAddModal() {
|
|
149
|
+
const overlay = document.createElement('div');
|
|
150
|
+
overlay.className = 'plg-modal-overlay';
|
|
151
|
+
const modal = document.createElement('div');
|
|
152
|
+
modal.className = 'plg-modal';
|
|
153
|
+
|
|
154
|
+
const title = document.createElement('h3');
|
|
155
|
+
title.textContent = 'Add third-party plugin';
|
|
156
|
+
const h2 = document.createElement('h2');
|
|
157
|
+
h2.style.color = 'red';
|
|
158
|
+
h2.innerHTML = `Installing third-party plugins can be risky. <br><br>
|
|
159
|
+
These plugins run code that we do not control, and malicious or poorly written plugins could compromise your data, expose sensitive information, or harm the stability and security of your application.
|
|
160
|
+
<br><br>Only proceed if you fully trust the source of the plugin.
|
|
161
|
+
<br><br>Enter either:
|
|
162
|
+
<br>- a GitHub repository URL (e.g., https://github.com/USER/REPO or with /tree/branch)
|
|
163
|
+
<br>- or a base/entry URL where plugin files are served (e.g., http://localhost:8080/ or https://example.com/my-plugin/plugin.js)`;
|
|
164
|
+
|
|
165
|
+
const urlInput = document.createElement('input');
|
|
166
|
+
urlInput.className = 'plg-input';
|
|
167
|
+
urlInput.placeholder = 'GitHub repo or base/entry URL (e.g., https://github.com/USER/REPO or http://localhost:8080/)';
|
|
168
|
+
|
|
169
|
+
const p2 = document.createElement('h2');
|
|
170
|
+
p2.innerHTML = '<br>To proceed, type "yes" below to confirm you understand the risks of third-party plugins.';
|
|
171
|
+
const confirmInput = document.createElement('input');
|
|
172
|
+
confirmInput.className = 'plg-input';
|
|
173
|
+
confirmInput.placeholder = 'type yes to confirm';
|
|
174
|
+
|
|
175
|
+
const err = document.createElement('div');
|
|
176
|
+
err.className = 'plg-err';
|
|
177
|
+
|
|
178
|
+
const buttons = document.createElement('div');
|
|
179
|
+
buttons.className = 'plg-row';
|
|
180
|
+
const cancelBtn = document.createElement('button');
|
|
181
|
+
cancelBtn.className = 'plg-btn';
|
|
182
|
+
cancelBtn.textContent = 'Cancel';
|
|
183
|
+
const okBtn = document.createElement('button');
|
|
184
|
+
okBtn.className = 'plg-btn';
|
|
185
|
+
okBtn.textContent = 'Add Plugin';
|
|
186
|
+
okBtn.disabled = true;
|
|
187
|
+
|
|
188
|
+
const close = () => { try { document.body.removeChild(overlay); } catch { } };
|
|
189
|
+
|
|
190
|
+
const validate = () => {
|
|
191
|
+
const v = String(urlInput.value || '').trim();
|
|
192
|
+
const c = String(confirmInput.value || '').trim().toLowerCase();
|
|
193
|
+
let urlOk = false;
|
|
194
|
+
err.textContent = '';
|
|
195
|
+
if (v) {
|
|
196
|
+
try {
|
|
197
|
+
const u = new URL(v);
|
|
198
|
+
if (u.protocol === 'http:' || u.protocol === 'https:') {
|
|
199
|
+
if (u.hostname === 'github.com') {
|
|
200
|
+
// Enforce GitHub URL shape if it's a GitHub host
|
|
201
|
+
parseGithubUrl(v);
|
|
202
|
+
}
|
|
203
|
+
urlOk = true;
|
|
204
|
+
} else {
|
|
205
|
+
throw new Error('URL must start with http(s)');
|
|
206
|
+
}
|
|
207
|
+
} catch (e) {
|
|
208
|
+
urlOk = false;
|
|
209
|
+
err.textContent = String(e?.message || 'Invalid URL');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const confirmed = c === 'yes';
|
|
213
|
+
okBtn.disabled = !(urlOk && confirmed);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
urlInput.addEventListener('input', validate);
|
|
217
|
+
confirmInput.addEventListener('input', validate);
|
|
218
|
+
cancelBtn.addEventListener('click', close);
|
|
219
|
+
overlay.addEventListener('click', (e) => { if (e.target === overlay) close(); });
|
|
220
|
+
okBtn.addEventListener('click', () => {
|
|
221
|
+
const v = String(urlInput.value || '').trim();
|
|
222
|
+
const c = String(confirmInput.value || '').trim().toLowerCase();
|
|
223
|
+
if (!v || c !== 'yes') return; // safety
|
|
224
|
+
// For GitHub URLs, ensure shape is valid; otherwise accept generic http(s) URL
|
|
225
|
+
try {
|
|
226
|
+
const u = new URL(v);
|
|
227
|
+
if (u.hostname === 'github.com') parseGithubUrl(v);
|
|
228
|
+
} catch { return; }
|
|
229
|
+
// prevent duplicates
|
|
230
|
+
this.urls = Array.isArray(this.urls) ? this.urls : [];
|
|
231
|
+
if (!this.urls.includes(v)) this.urls.push(v);
|
|
232
|
+
this._save();
|
|
233
|
+
// Default to enabled when adding
|
|
234
|
+
try {
|
|
235
|
+
this.enabledMap = this.enabledMap && typeof this.enabledMap === 'object' ? this.enabledMap : {};
|
|
236
|
+
this.enabledMap[v] = true;
|
|
237
|
+
savePluginEnabledMap(this.enabledMap);
|
|
238
|
+
} catch { }
|
|
239
|
+
this._refreshList();
|
|
240
|
+
this._setStatus('Saved.');
|
|
241
|
+
close();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
modal.appendChild(title);
|
|
245
|
+
modal.appendChild(h2);
|
|
246
|
+
modal.appendChild(urlInput);
|
|
247
|
+
modal.appendChild(p2);
|
|
248
|
+
modal.appendChild(confirmInput);
|
|
249
|
+
modal.appendChild(err);
|
|
250
|
+
buttons.appendChild(cancelBtn);
|
|
251
|
+
buttons.appendChild(okBtn);
|
|
252
|
+
modal.appendChild(buttons);
|
|
253
|
+
overlay.appendChild(modal);
|
|
254
|
+
document.body.appendChild(overlay);
|
|
255
|
+
|
|
256
|
+
try { urlInput.focus(); } catch { }
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
_deleteSelected() {
|
|
260
|
+
const idx = this._selectedIndex;
|
|
261
|
+
const list = Array.isArray(this.urls) ? this.urls : [];
|
|
262
|
+
if (idx < 0 || idx >= list.length) return;
|
|
263
|
+
const [removed] = list.splice(idx, 1);
|
|
264
|
+
this.urls = list;
|
|
265
|
+
this._save();
|
|
266
|
+
try {
|
|
267
|
+
if (removed && this.enabledMap && typeof this.enabledMap === 'object') {
|
|
268
|
+
delete this.enabledMap[removed];
|
|
269
|
+
savePluginEnabledMap(this.enabledMap);
|
|
270
|
+
}
|
|
271
|
+
} catch { }
|
|
272
|
+
this._selectedIndex = Math.min(idx, Math.max(0, list.length - 1));
|
|
273
|
+
this._refreshList();
|
|
274
|
+
this._setStatus('Deleted.');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
_setStatus(text) {
|
|
278
|
+
this.statusEl.textContent = String(text || '');
|
|
279
|
+
}
|
|
280
|
+
}
|