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,1063 @@
|
|
|
1
|
+
import { FloatingWindow } from '../FloatingWindow.js';
|
|
2
|
+
|
|
3
|
+
const PANEL_CONTROLLER = Symbol('MetadataPanelController');
|
|
4
|
+
|
|
5
|
+
class MetadataPanelController {
|
|
6
|
+
constructor(viewer) {
|
|
7
|
+
this.viewer = viewer;
|
|
8
|
+
this.open = false;
|
|
9
|
+
this.window = null;
|
|
10
|
+
this.root = null;
|
|
11
|
+
this.content = null;
|
|
12
|
+
this.sortColumn = 'key';
|
|
13
|
+
this.sortDir = 'asc';
|
|
14
|
+
this.filterText = '';
|
|
15
|
+
this.selectedKeys = new Set();
|
|
16
|
+
this.measureCtx = null;
|
|
17
|
+
this.currentTarget = null;
|
|
18
|
+
this._cachedInputHeightPx = null;
|
|
19
|
+
if (viewer) {
|
|
20
|
+
viewer.__metadataPanelController = this;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toggle() {
|
|
25
|
+
if (this.open) this.close();
|
|
26
|
+
else this.openPanel();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
openPanel() {
|
|
30
|
+
this._ensurePanel();
|
|
31
|
+
if (this.open) {
|
|
32
|
+
this.root.style.display = 'flex';
|
|
33
|
+
if (this.currentTarget) this._render();
|
|
34
|
+
else this._setPlaceholder('Click an object in the scene to view or edit its metadata.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.open = true;
|
|
38
|
+
this.sortColumn = 'key';
|
|
39
|
+
this.sortDir = 'asc';
|
|
40
|
+
this.filterText = '';
|
|
41
|
+
this.selectedKeys.clear();
|
|
42
|
+
this.root.style.display = 'flex';
|
|
43
|
+
if (this.currentTarget) this._render();
|
|
44
|
+
else this._setPlaceholder('Click an object in the scene to view or edit its metadata.');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
close() {
|
|
48
|
+
if (!this.open) return;
|
|
49
|
+
this.open = false;
|
|
50
|
+
if (this.root) {
|
|
51
|
+
try { this.root.style.display = 'none'; } catch {}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
handleSelection(target) {
|
|
56
|
+
this.currentTarget = target || null;
|
|
57
|
+
if (this.currentTarget) {
|
|
58
|
+
try {
|
|
59
|
+
const solid = this._findParentSolid(this.currentTarget);
|
|
60
|
+
const name = this.currentTarget.name || this.currentTarget.userData?.faceName || null;
|
|
61
|
+
const meta = (solid && name && typeof solid.getFaceMetadata === 'function')
|
|
62
|
+
? solid.getFaceMetadata(name)
|
|
63
|
+
: null;
|
|
64
|
+
console.log('[MetadataPanel] Selected object', {
|
|
65
|
+
name,
|
|
66
|
+
type: this.currentTarget.type,
|
|
67
|
+
faceName: this.currentTarget.userData?.faceName || null,
|
|
68
|
+
sheetMetalFaceType: this.currentTarget.userData?.sheetMetalFaceType || null,
|
|
69
|
+
sheetMetalEdgeType: this.currentTarget.userData?.sheetMetalEdgeType || null,
|
|
70
|
+
parentSolid: solid?.name || null,
|
|
71
|
+
metadata: meta || null,
|
|
72
|
+
});
|
|
73
|
+
console.log("Actual object:", this.currentTarget);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
try { console.warn('[MetadataPanel] Selection log failed:', e); } catch { }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!this.open) return;
|
|
79
|
+
this._render();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_ensurePanel() {
|
|
83
|
+
if (this.root) return;
|
|
84
|
+
const height = Math.max(240, Math.floor((window?.innerHeight || 800) * 0.45));
|
|
85
|
+
const fw = new FloatingWindow({
|
|
86
|
+
title: 'Metadata',
|
|
87
|
+
width: 500,
|
|
88
|
+
height: 600,
|
|
89
|
+
bottom: 12,
|
|
90
|
+
shaded: false,
|
|
91
|
+
onClose: () => this.close(),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const btnClear = document.createElement('button');
|
|
95
|
+
btnClear.className = 'fw-btn';
|
|
96
|
+
btnClear.textContent = 'Clear';
|
|
97
|
+
btnClear.addEventListener('click', () => this._clearMetadataForCurrentTarget());
|
|
98
|
+
|
|
99
|
+
fw.addHeaderAction(btnClear);
|
|
100
|
+
|
|
101
|
+
const content = document.createElement('div');
|
|
102
|
+
content.style.display = 'flex';
|
|
103
|
+
content.style.flexDirection = 'column';
|
|
104
|
+
content.style.gap = '8px';
|
|
105
|
+
content.style.padding = '8px';
|
|
106
|
+
content.style.width = '100%';
|
|
107
|
+
content.style.height = '100%';
|
|
108
|
+
content.style.boxSizing = 'border-box';
|
|
109
|
+
content.style.overflowX = 'hidden';
|
|
110
|
+
content.style.overflowY = 'auto';
|
|
111
|
+
fw.content.appendChild(content);
|
|
112
|
+
|
|
113
|
+
this.window = fw;
|
|
114
|
+
this.root = fw.root;
|
|
115
|
+
this.content = content;
|
|
116
|
+
try { this.root.style.display = 'none'; } catch {}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_setPlaceholder(msg) {
|
|
120
|
+
this._ensurePanel();
|
|
121
|
+
if (!this.content) return;
|
|
122
|
+
this.content.innerHTML = '';
|
|
123
|
+
const p = document.createElement('div');
|
|
124
|
+
p.textContent = msg || '';
|
|
125
|
+
p.style.color = '#9aa4b2';
|
|
126
|
+
p.style.font = '12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
127
|
+
p.style.opacity = '0.9';
|
|
128
|
+
this.content.appendChild(p);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_clearMetadataForCurrentTarget() {
|
|
132
|
+
const target = this.currentTarget;
|
|
133
|
+
const manager = this._getManager();
|
|
134
|
+
if (!target || !target.name || !manager) return;
|
|
135
|
+
let ok = true;
|
|
136
|
+
try {
|
|
137
|
+
ok = window.confirm ? window.confirm(`Remove all metadata for "${target.name}"?`) : true;
|
|
138
|
+
} catch { ok = true; }
|
|
139
|
+
if (!ok) return;
|
|
140
|
+
try { manager.clearMetadata(target.name); } catch {}
|
|
141
|
+
this._refreshMetadataColors();
|
|
142
|
+
this.selectedKeys.clear();
|
|
143
|
+
if (this.open) this._render();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_bulkDeleteSelectedMetadata() {
|
|
147
|
+
const target = this.currentTarget;
|
|
148
|
+
const manager = this._getManager();
|
|
149
|
+
if (!target || !target.name || !manager) return;
|
|
150
|
+
if (this.selectedKeys.size === 0) return;
|
|
151
|
+
const count = this.selectedKeys.size;
|
|
152
|
+
let ok = true;
|
|
153
|
+
try {
|
|
154
|
+
ok = window.confirm ? window.confirm(`Delete ${count} selected metadata entr${count === 1 ? 'y' : 'ies'}?`) : true;
|
|
155
|
+
} catch { ok = true; }
|
|
156
|
+
if (!ok) return;
|
|
157
|
+
for (const key of Array.from(this.selectedKeys)) {
|
|
158
|
+
manager.deleteMetadataKey(target.name, key);
|
|
159
|
+
}
|
|
160
|
+
this._refreshMetadataColors();
|
|
161
|
+
this.selectedKeys.clear();
|
|
162
|
+
if (this.open) this._render();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_refreshMetadataColors() {
|
|
166
|
+
try {
|
|
167
|
+
if (this.viewer && typeof this.viewer.applyMetadataColors === 'function') {
|
|
168
|
+
this.viewer.applyMetadataColors();
|
|
169
|
+
}
|
|
170
|
+
} catch { }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_render() {
|
|
174
|
+
if (!this.open) return;
|
|
175
|
+
this._ensurePanel();
|
|
176
|
+
const manager = this._getManager();
|
|
177
|
+
const target = this.currentTarget;
|
|
178
|
+
if (!target) {
|
|
179
|
+
this.selectedKeys.clear();
|
|
180
|
+
this._setPlaceholder('Nothing selected.');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (!target.name) {
|
|
184
|
+
this.selectedKeys.clear();
|
|
185
|
+
this._setPlaceholder('Selected object has no name. Assign a unique name to edit metadata.');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!manager) {
|
|
189
|
+
this.selectedKeys.clear();
|
|
190
|
+
this._setPlaceholder('Metadata manager not available.');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const name = target.name;
|
|
195
|
+
const own = manager.getOwnMetadata(name);
|
|
196
|
+
const effective = manager.getMetadata(name);
|
|
197
|
+
const faceMetadata = this._getFaceMetadataForTarget(target);
|
|
198
|
+
const edgeMetadata = this._getEdgeMetadataForTarget(target);
|
|
199
|
+
|
|
200
|
+
// Merge edge metadata into the displayed entries so edge attributes are visible
|
|
201
|
+
if (edgeMetadata && typeof edgeMetadata.metadata === 'object') {
|
|
202
|
+
for (const [k, v] of Object.entries(edgeMetadata.metadata)) {
|
|
203
|
+
own[k] = v;
|
|
204
|
+
effective[k] = v;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const entries = Object.entries(own).map(([key, value]) => ({
|
|
209
|
+
key,
|
|
210
|
+
value,
|
|
211
|
+
valueString: this._stringifyMetadataValue(value)
|
|
212
|
+
}));
|
|
213
|
+
|
|
214
|
+
const requiredColorKey = this._getDefaultColorKey(target);
|
|
215
|
+
if (requiredColorKey && !entries.some((entry) => entry.key === requiredColorKey)) {
|
|
216
|
+
entries.push({ key: requiredColorKey, value: '', valueString: '' });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const filter = (this.filterText || '').trim().toLowerCase();
|
|
220
|
+
const filtered = filter
|
|
221
|
+
? entries.filter(({ key, valueString }) => key.toLowerCase().includes(filter) || valueString.toLowerCase().includes(filter))
|
|
222
|
+
: entries.slice();
|
|
223
|
+
|
|
224
|
+
const dir = this.sortDir === 'desc' ? -1 : 1;
|
|
225
|
+
const sortColumn = this.sortColumn === 'value' ? 'valueString' : 'key';
|
|
226
|
+
filtered.sort((a, b) => {
|
|
227
|
+
const av = a[sortColumn] || '';
|
|
228
|
+
const bv = b[sortColumn] || '';
|
|
229
|
+
return av.localeCompare(bv, undefined, { numeric: true, sensitivity: 'base' }) * dir;
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const existingKeys = new Set(entries.map(e => e.key));
|
|
233
|
+
for (const key of Array.from(this.selectedKeys)) {
|
|
234
|
+
if (!existingKeys.has(key)) this.selectedKeys.delete(key);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let keyColumnWidth = 120;
|
|
238
|
+
for (const { key } of entries) {
|
|
239
|
+
keyColumnWidth = Math.max(keyColumnWidth, this._measureKeyWidth(key) + 24);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const baseInputHeight = this._inputHeightPx();
|
|
243
|
+
|
|
244
|
+
this.content.innerHTML = '';
|
|
245
|
+
|
|
246
|
+
const header = document.createElement('div');
|
|
247
|
+
header.style.font = '13px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
248
|
+
header.style.fontWeight = '600';
|
|
249
|
+
header.style.whiteSpace = 'nowrap';
|
|
250
|
+
header.style.textOverflow = 'ellipsis';
|
|
251
|
+
header.textContent = `Object: ${name}`;
|
|
252
|
+
this.content.appendChild(header);
|
|
253
|
+
|
|
254
|
+
const controls = document.createElement('div');
|
|
255
|
+
controls.style.display = 'flex';
|
|
256
|
+
controls.style.alignItems = 'center';
|
|
257
|
+
controls.style.gap = '8px';
|
|
258
|
+
controls.style.flexWrap = 'wrap';
|
|
259
|
+
controls.style.font = '12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
260
|
+
|
|
261
|
+
const filterLabel = document.createElement('label');
|
|
262
|
+
filterLabel.textContent = 'Filter';
|
|
263
|
+
const filterInput = document.createElement('input');
|
|
264
|
+
filterInput.type = 'search';
|
|
265
|
+
filterInput.value = this.filterText;
|
|
266
|
+
filterInput.placeholder = 'key or value';
|
|
267
|
+
filterInput.style.flex = '1 1 160px';
|
|
268
|
+
filterInput.style.minWidth = '140px';
|
|
269
|
+
filterInput.style.font = '12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
270
|
+
filterInput.style.padding = '4px 6px';
|
|
271
|
+
filterInput.style.border = '1px solid #1f2937';
|
|
272
|
+
filterInput.style.background = '#0f172a';
|
|
273
|
+
filterInput.style.color = '#e2e8f0';
|
|
274
|
+
filterInput.addEventListener('input', () => {
|
|
275
|
+
this.filterText = filterInput.value;
|
|
276
|
+
this._render();
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
const clearFilterBtn = document.createElement('button');
|
|
280
|
+
clearFilterBtn.className = 'fw-btn';
|
|
281
|
+
clearFilterBtn.textContent = 'Clear filter';
|
|
282
|
+
clearFilterBtn.disabled = !(this.filterText || '').length;
|
|
283
|
+
clearFilterBtn.addEventListener('click', () => {
|
|
284
|
+
this.filterText = '';
|
|
285
|
+
this._render();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
controls.appendChild(filterLabel);
|
|
289
|
+
controls.appendChild(filterInput);
|
|
290
|
+
controls.appendChild(clearFilterBtn);
|
|
291
|
+
this.content.appendChild(controls);
|
|
292
|
+
|
|
293
|
+
const table = document.createElement('table');
|
|
294
|
+
table.style.width = '100%';
|
|
295
|
+
table.style.borderCollapse = 'collapse';
|
|
296
|
+
table.style.tableLayout = 'auto';
|
|
297
|
+
table.style.font = '12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
298
|
+
|
|
299
|
+
const thead = document.createElement('thead');
|
|
300
|
+
const headRow = document.createElement('tr');
|
|
301
|
+
const headers = [
|
|
302
|
+
{ text: 'Select', column: null, widthPx: 10 },
|
|
303
|
+
{ text: 'Attribute', column: 'key', widthPx: keyColumnWidth },
|
|
304
|
+
{ text: 'Value', column: 'value' },
|
|
305
|
+
{ text: 'Actions', column: null }
|
|
306
|
+
];
|
|
307
|
+
|
|
308
|
+
for (const { text, column, widthPx } of headers) {
|
|
309
|
+
const th = document.createElement('th');
|
|
310
|
+
th.textContent = text;
|
|
311
|
+
th.style.textAlign = column === 'value' ? 'left' : 'center';
|
|
312
|
+
if (column === 'key') th.style.textAlign = 'left';
|
|
313
|
+
th.style.padding = '6px';
|
|
314
|
+
th.style.borderBottom = '1px solid #1f2937';
|
|
315
|
+
th.style.fontWeight = '600';
|
|
316
|
+
th.style.position = 'relative';
|
|
317
|
+
th.style.whiteSpace = 'nowrap';
|
|
318
|
+
if (widthPx) {
|
|
319
|
+
th.style.width = `${widthPx}px`;
|
|
320
|
+
th.style.minWidth = `${widthPx}px`;
|
|
321
|
+
th.style.maxWidth = `${widthPx}px`;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (column === 'key' || column === 'value') {
|
|
325
|
+
th.style.cursor = 'pointer';
|
|
326
|
+
const sortCol = column === 'value' ? 'value' : 'key';
|
|
327
|
+
const arrow = document.createElement('span');
|
|
328
|
+
arrow.style.marginLeft = '6px';
|
|
329
|
+
arrow.style.opacity = this.sortColumn === sortCol ? '1' : '0.3';
|
|
330
|
+
arrow.textContent = this.sortColumn === sortCol
|
|
331
|
+
? (this.sortDir === 'asc' ? '▲' : '▼')
|
|
332
|
+
: '▲';
|
|
333
|
+
th.appendChild(arrow);
|
|
334
|
+
th.addEventListener('click', () => {
|
|
335
|
+
if (this.sortColumn === sortCol) {
|
|
336
|
+
this.sortDir = this.sortDir === 'asc' ? 'desc' : 'asc';
|
|
337
|
+
} else {
|
|
338
|
+
this.sortColumn = sortCol;
|
|
339
|
+
this.sortDir = 'asc';
|
|
340
|
+
}
|
|
341
|
+
this._render();
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (column === null && text === 'Select') {
|
|
346
|
+
const master = document.createElement('input');
|
|
347
|
+
master.type = 'checkbox';
|
|
348
|
+
master.style.margin = '0 auto';
|
|
349
|
+
master.checked = filtered.length > 0 && filtered.every(e => this.selectedKeys.has(e.key));
|
|
350
|
+
master.indeterminate = filtered.some(e => this.selectedKeys.has(e.key)) && !master.checked;
|
|
351
|
+
master.addEventListener('change', () => {
|
|
352
|
+
if (master.checked) {
|
|
353
|
+
for (const { key } of filtered) this.selectedKeys.add(key);
|
|
354
|
+
} else {
|
|
355
|
+
for (const { key } of filtered) this.selectedKeys.delete(key);
|
|
356
|
+
}
|
|
357
|
+
this._render();
|
|
358
|
+
});
|
|
359
|
+
th.textContent = '';
|
|
360
|
+
th.appendChild(master);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
headRow.appendChild(th);
|
|
364
|
+
}
|
|
365
|
+
thead.appendChild(headRow);
|
|
366
|
+
table.appendChild(thead);
|
|
367
|
+
|
|
368
|
+
const tbody = document.createElement('tbody');
|
|
369
|
+
|
|
370
|
+
const addRow = document.createElement('tr');
|
|
371
|
+
addRow.style.borderBottom = '1px solid #1f2937';
|
|
372
|
+
|
|
373
|
+
const addKeyCell = document.createElement('td');
|
|
374
|
+
addKeyCell.style.padding = '4px';
|
|
375
|
+
addKeyCell.style.verticalAlign = 'top';
|
|
376
|
+
addKeyCell.style.width = `${keyColumnWidth}px`;
|
|
377
|
+
addKeyCell.style.minWidth = `${keyColumnWidth}px`;
|
|
378
|
+
const newKeyInput = document.createElement('input');
|
|
379
|
+
newKeyInput.type = 'text';
|
|
380
|
+
newKeyInput.placeholder = 'New attribute name';
|
|
381
|
+
newKeyInput.style.width = '100%';
|
|
382
|
+
newKeyInput.style.boxSizing = 'border-box';
|
|
383
|
+
newKeyInput.style.font = '12px monospace';
|
|
384
|
+
newKeyInput.style.padding = '4px 6px';
|
|
385
|
+
newKeyInput.style.border = '1px solid #1f2937';
|
|
386
|
+
newKeyInput.style.background = '#0f172a';
|
|
387
|
+
newKeyInput.style.color = '#e2e8f0';
|
|
388
|
+
addKeyCell.appendChild(newKeyInput);
|
|
389
|
+
|
|
390
|
+
const addValueCell = document.createElement('td');
|
|
391
|
+
addValueCell.style.padding = '4px';
|
|
392
|
+
addValueCell.style.verticalAlign = 'top';
|
|
393
|
+
const addValueWrap = document.createElement('div');
|
|
394
|
+
addValueWrap.style.display = 'flex';
|
|
395
|
+
addValueWrap.style.alignItems = 'stretch';
|
|
396
|
+
addValueWrap.style.gap = '6px';
|
|
397
|
+
addValueWrap.style.width = '100%';
|
|
398
|
+
|
|
399
|
+
const newValueTextarea = document.createElement('textarea');
|
|
400
|
+
newValueTextarea.placeholder = 'Value (JSON or plain text)';
|
|
401
|
+
newValueTextarea.style.width = '100%';
|
|
402
|
+
newValueTextarea.style.flex = '1 1 auto';
|
|
403
|
+
newValueTextarea.style.font = '12px monospace';
|
|
404
|
+
newValueTextarea.style.padding = '6px';
|
|
405
|
+
newValueTextarea.style.border = '1px solid #1f2937';
|
|
406
|
+
newValueTextarea.style.background = '#0f172a';
|
|
407
|
+
newValueTextarea.style.color = '#e2e8f0';
|
|
408
|
+
newValueTextarea.style.resize = 'vertical';
|
|
409
|
+
newValueTextarea.style.boxSizing = 'border-box';
|
|
410
|
+
newValueTextarea.setAttribute('wrap', 'soft');
|
|
411
|
+
addValueWrap.appendChild(newValueTextarea);
|
|
412
|
+
autoResizeTextarea(newValueTextarea, baseInputHeight);
|
|
413
|
+
|
|
414
|
+
const newColorInput = document.createElement('input');
|
|
415
|
+
newColorInput.type = 'color';
|
|
416
|
+
newColorInput.title = 'Pick a color';
|
|
417
|
+
newColorInput.style.width = '32px';
|
|
418
|
+
newColorInput.style.minWidth = '32px';
|
|
419
|
+
newColorInput.style.height = '28px';
|
|
420
|
+
newColorInput.style.padding = '0';
|
|
421
|
+
newColorInput.style.border = '1px solid #1f2937';
|
|
422
|
+
newColorInput.style.background = '#0f172a';
|
|
423
|
+
newColorInput.style.display = 'none';
|
|
424
|
+
newColorInput.addEventListener('input', () => {
|
|
425
|
+
newValueTextarea.value = newColorInput.value;
|
|
426
|
+
try { newValueTextarea.dispatchEvent(new Event('input')); } catch { }
|
|
427
|
+
});
|
|
428
|
+
addValueWrap.appendChild(newColorInput);
|
|
429
|
+
|
|
430
|
+
const newColorReset = document.createElement('button');
|
|
431
|
+
newColorReset.className = 'fw-btn';
|
|
432
|
+
newColorReset.textContent = 'Reset';
|
|
433
|
+
newColorReset.title = 'Clear color value';
|
|
434
|
+
newColorReset.style.height = '28px';
|
|
435
|
+
newColorReset.style.padding = '2px 6px';
|
|
436
|
+
newColorReset.style.display = 'none';
|
|
437
|
+
newColorReset.addEventListener('click', () => {
|
|
438
|
+
newValueTextarea.value = '';
|
|
439
|
+
newColorInput.value = '#000000';
|
|
440
|
+
try { newValueTextarea.dispatchEvent(new Event('input')); } catch { }
|
|
441
|
+
});
|
|
442
|
+
addValueWrap.appendChild(newColorReset);
|
|
443
|
+
|
|
444
|
+
const refreshNewColorInput = () => {
|
|
445
|
+
const show = this._isColorKey(newKeyInput.value);
|
|
446
|
+
newColorInput.style.display = show ? 'block' : 'none';
|
|
447
|
+
newColorReset.style.display = show ? 'block' : 'none';
|
|
448
|
+
if (!show) return;
|
|
449
|
+
const hex = this._resolveColorHex(newValueTextarea.value);
|
|
450
|
+
if (hex) newColorInput.value = hex;
|
|
451
|
+
};
|
|
452
|
+
newKeyInput.addEventListener('input', refreshNewColorInput);
|
|
453
|
+
newValueTextarea.addEventListener('input', () => {
|
|
454
|
+
if (newColorInput.style.display === 'none') return;
|
|
455
|
+
const hex = this._resolveColorHex(newValueTextarea.value);
|
|
456
|
+
if (hex) newColorInput.value = hex;
|
|
457
|
+
});
|
|
458
|
+
refreshNewColorInput();
|
|
459
|
+
|
|
460
|
+
addValueCell.appendChild(addValueWrap);
|
|
461
|
+
|
|
462
|
+
const addSelectCell = document.createElement('td');
|
|
463
|
+
addSelectCell.style.padding = '4px';
|
|
464
|
+
addSelectCell.style.textAlign = 'center';
|
|
465
|
+
addSelectCell.style.verticalAlign = 'middle';
|
|
466
|
+
addSelectCell.textContent = '-';
|
|
467
|
+
addSelectCell.style.color = '#475569';
|
|
468
|
+
|
|
469
|
+
const addActionCell = document.createElement('td');
|
|
470
|
+
addActionCell.style.padding = '4px';
|
|
471
|
+
addActionCell.style.textAlign = 'center';
|
|
472
|
+
const addBtn = document.createElement('button');
|
|
473
|
+
addBtn.className = 'fw-btn';
|
|
474
|
+
addBtn.textContent = 'Add attribute';
|
|
475
|
+
addBtn.addEventListener('click', () => {
|
|
476
|
+
const key = newKeyInput.value.trim();
|
|
477
|
+
if (!key) {
|
|
478
|
+
newKeyInput.focus();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const data = manager.getOwnMetadata(name);
|
|
482
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
483
|
+
try { alert('Metadata key already exists. Use a unique key.'); } catch {}
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
this._commitMetadataValue(manager, name, key, newValueTextarea.value);
|
|
487
|
+
this._refreshMetadataColors();
|
|
488
|
+
newKeyInput.value = '';
|
|
489
|
+
newValueTextarea.value = '';
|
|
490
|
+
this.selectedKeys.add(key);
|
|
491
|
+
this._render();
|
|
492
|
+
});
|
|
493
|
+
addActionCell.appendChild(addBtn);
|
|
494
|
+
|
|
495
|
+
addRow.appendChild(addSelectCell);
|
|
496
|
+
addRow.appendChild(addKeyCell);
|
|
497
|
+
addRow.appendChild(addValueCell);
|
|
498
|
+
addRow.appendChild(addActionCell);
|
|
499
|
+
tbody.appendChild(addRow);
|
|
500
|
+
|
|
501
|
+
if (filtered.length === 0) {
|
|
502
|
+
const emptyRow = document.createElement('tr');
|
|
503
|
+
const td = document.createElement('td');
|
|
504
|
+
td.colSpan = 4;
|
|
505
|
+
td.textContent = entries.length === 0 ? 'No metadata yet.' : 'No entries match the current filter.';
|
|
506
|
+
td.style.padding = '12px';
|
|
507
|
+
td.style.textAlign = 'center';
|
|
508
|
+
td.style.color = '#94a3b8';
|
|
509
|
+
emptyRow.appendChild(td);
|
|
510
|
+
tbody.appendChild(emptyRow);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
for (const { key, valueString } of filtered) {
|
|
514
|
+
const row = document.createElement('tr');
|
|
515
|
+
row.style.borderBottom = '1px solid #1f2937';
|
|
516
|
+
|
|
517
|
+
const keyCell = document.createElement('td');
|
|
518
|
+
keyCell.style.padding = '4px';
|
|
519
|
+
keyCell.style.verticalAlign = 'top';
|
|
520
|
+
keyCell.style.width = `${keyColumnWidth}px`;
|
|
521
|
+
keyCell.style.minWidth = `${keyColumnWidth}px`;
|
|
522
|
+
const keyInput = document.createElement('input');
|
|
523
|
+
keyInput.type = 'text';
|
|
524
|
+
keyInput.value = key;
|
|
525
|
+
keyInput.title = 'Attribute name';
|
|
526
|
+
keyInput.style.width = '100%';
|
|
527
|
+
keyInput.style.boxSizing = 'border-box';
|
|
528
|
+
keyInput.style.font = '12px monospace';
|
|
529
|
+
keyInput.style.padding = '4px 6px';
|
|
530
|
+
keyInput.style.border = '1px solid #1f2937';
|
|
531
|
+
keyInput.style.background = '#0f172a';
|
|
532
|
+
keyInput.style.color = '#e2e8f0';
|
|
533
|
+
|
|
534
|
+
keyInput.addEventListener('blur', () => {
|
|
535
|
+
const newKey = keyInput.value.trim();
|
|
536
|
+
if (!newKey) {
|
|
537
|
+
keyInput.value = key;
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (newKey === key) return;
|
|
541
|
+
const data = manager.getOwnMetadata(name);
|
|
542
|
+
if (Object.prototype.hasOwnProperty.call(data, newKey)) {
|
|
543
|
+
try { alert('Metadata key already exists. Use a unique key.'); } catch {}
|
|
544
|
+
keyInput.value = key;
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const currentValue = data[key];
|
|
548
|
+
delete data[key];
|
|
549
|
+
data[newKey] = currentValue;
|
|
550
|
+
manager.setMetadataObject(name, data);
|
|
551
|
+
this._refreshMetadataColors();
|
|
552
|
+
if (this.selectedKeys.has(key)) {
|
|
553
|
+
this.selectedKeys.delete(key);
|
|
554
|
+
this.selectedKeys.add(newKey);
|
|
555
|
+
}
|
|
556
|
+
this._render();
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
keyCell.appendChild(keyInput);
|
|
560
|
+
|
|
561
|
+
const valueCell = document.createElement('td');
|
|
562
|
+
valueCell.style.padding = '4px';
|
|
563
|
+
valueCell.style.verticalAlign = 'top';
|
|
564
|
+
valueCell.style.width = 'auto';
|
|
565
|
+
const valueWrap = document.createElement('div');
|
|
566
|
+
valueWrap.style.display = 'flex';
|
|
567
|
+
valueWrap.style.alignItems = 'stretch';
|
|
568
|
+
valueWrap.style.gap = '6px';
|
|
569
|
+
valueWrap.style.width = '100%';
|
|
570
|
+
const valueTextarea = document.createElement('textarea');
|
|
571
|
+
valueTextarea.value = valueString;
|
|
572
|
+
valueTextarea.title = 'Value (JSON accepted)';
|
|
573
|
+
valueTextarea.style.width = '100%';
|
|
574
|
+
valueTextarea.style.flex = '1 1 auto';
|
|
575
|
+
valueTextarea.style.font = '12px monospace';
|
|
576
|
+
valueTextarea.style.padding = '6px';
|
|
577
|
+
valueTextarea.style.border = '1px solid #1f2937';
|
|
578
|
+
valueTextarea.style.background = '#0f172a';
|
|
579
|
+
valueTextarea.style.color = '#e2e8f0';
|
|
580
|
+
valueTextarea.style.resize = 'vertical';
|
|
581
|
+
valueTextarea.style.boxSizing = 'border-box';
|
|
582
|
+
valueTextarea.style.lineHeight = '1.4';
|
|
583
|
+
valueTextarea.setAttribute('wrap', 'soft');
|
|
584
|
+
|
|
585
|
+
const commitValue = () => {
|
|
586
|
+
this._commitMetadataValue(manager, name, key, valueTextarea.value);
|
|
587
|
+
this._refreshMetadataColors();
|
|
588
|
+
this._render();
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
valueTextarea.addEventListener('blur', () => {
|
|
592
|
+
commitValue();
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
valueWrap.appendChild(valueTextarea);
|
|
596
|
+
if (this._isColorKey(key)) {
|
|
597
|
+
const colorInput = document.createElement('input');
|
|
598
|
+
colorInput.type = 'color';
|
|
599
|
+
colorInput.title = 'Pick a color';
|
|
600
|
+
colorInput.style.width = '32px';
|
|
601
|
+
colorInput.style.minWidth = '32px';
|
|
602
|
+
colorInput.style.height = '28px';
|
|
603
|
+
colorInput.style.padding = '0';
|
|
604
|
+
colorInput.style.border = '1px solid #1f2937';
|
|
605
|
+
colorInput.style.background = '#0f172a';
|
|
606
|
+
const hex = this._resolveColorHex(valueTextarea.value);
|
|
607
|
+
if (hex) colorInput.value = hex;
|
|
608
|
+
valueTextarea.addEventListener('input', () => {
|
|
609
|
+
const nextHex = this._resolveColorHex(valueTextarea.value);
|
|
610
|
+
if (nextHex) colorInput.value = nextHex;
|
|
611
|
+
});
|
|
612
|
+
colorInput.addEventListener('input', () => {
|
|
613
|
+
valueTextarea.value = colorInput.value;
|
|
614
|
+
try { valueTextarea.dispatchEvent(new Event('input')); } catch { }
|
|
615
|
+
});
|
|
616
|
+
colorInput.addEventListener('change', () => {
|
|
617
|
+
commitValue();
|
|
618
|
+
});
|
|
619
|
+
valueWrap.appendChild(colorInput);
|
|
620
|
+
|
|
621
|
+
const resetBtn = document.createElement('button');
|
|
622
|
+
resetBtn.className = 'fw-btn';
|
|
623
|
+
resetBtn.textContent = 'Reset';
|
|
624
|
+
resetBtn.title = 'Clear color value';
|
|
625
|
+
resetBtn.style.height = '28px';
|
|
626
|
+
resetBtn.style.padding = '2px 6px';
|
|
627
|
+
resetBtn.addEventListener('click', () => {
|
|
628
|
+
valueTextarea.value = '';
|
|
629
|
+
colorInput.value = '#000000';
|
|
630
|
+
commitValue();
|
|
631
|
+
});
|
|
632
|
+
valueWrap.appendChild(resetBtn);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
valueCell.appendChild(valueWrap);
|
|
636
|
+
autoResizeTextarea(valueTextarea, baseInputHeight);
|
|
637
|
+
|
|
638
|
+
const selectCell = document.createElement('td');
|
|
639
|
+
selectCell.style.padding = '4px';
|
|
640
|
+
selectCell.style.verticalAlign = 'middle';
|
|
641
|
+
selectCell.style.textAlign = 'center';
|
|
642
|
+
const checkbox = document.createElement('input');
|
|
643
|
+
checkbox.type = 'checkbox';
|
|
644
|
+
checkbox.checked = this.selectedKeys.has(key);
|
|
645
|
+
checkbox.addEventListener('change', () => {
|
|
646
|
+
if (checkbox.checked) this.selectedKeys.add(key);
|
|
647
|
+
else this.selectedKeys.delete(key);
|
|
648
|
+
this._render();
|
|
649
|
+
});
|
|
650
|
+
selectCell.appendChild(checkbox);
|
|
651
|
+
|
|
652
|
+
const actionCell = document.createElement('td');
|
|
653
|
+
actionCell.style.padding = '4px';
|
|
654
|
+
actionCell.style.textAlign = 'center';
|
|
655
|
+
const deleteBtn = document.createElement('button');
|
|
656
|
+
deleteBtn.className = 'fw-btn';
|
|
657
|
+
deleteBtn.textContent = '✕';
|
|
658
|
+
deleteBtn.title = 'Delete attribute';
|
|
659
|
+
deleteBtn.addEventListener('click', () => {
|
|
660
|
+
manager.deleteMetadataKey(name, key);
|
|
661
|
+
this._refreshMetadataColors();
|
|
662
|
+
this.selectedKeys.delete(key);
|
|
663
|
+
this._render();
|
|
664
|
+
});
|
|
665
|
+
actionCell.appendChild(deleteBtn);
|
|
666
|
+
|
|
667
|
+
row.appendChild(selectCell);
|
|
668
|
+
row.appendChild(keyCell);
|
|
669
|
+
row.appendChild(valueCell);
|
|
670
|
+
row.appendChild(actionCell);
|
|
671
|
+
tbody.appendChild(row);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
table.appendChild(tbody);
|
|
675
|
+
this.content.appendChild(table);
|
|
676
|
+
|
|
677
|
+
const actionRow = document.createElement('div');
|
|
678
|
+
actionRow.style.display = 'flex';
|
|
679
|
+
actionRow.style.alignItems = 'center';
|
|
680
|
+
actionRow.style.gap = '8px';
|
|
681
|
+
actionRow.style.flexWrap = 'wrap';
|
|
682
|
+
actionRow.style.marginTop = '4px';
|
|
683
|
+
|
|
684
|
+
const bulkDeleteBtn = document.createElement('button');
|
|
685
|
+
bulkDeleteBtn.className = 'fw-btn danger';
|
|
686
|
+
bulkDeleteBtn.textContent = 'Delete selected';
|
|
687
|
+
bulkDeleteBtn.disabled = this.selectedKeys.size === 0;
|
|
688
|
+
bulkDeleteBtn.addEventListener('click', () => this._bulkDeleteSelectedMetadata());
|
|
689
|
+
|
|
690
|
+
actionRow.appendChild(bulkDeleteBtn);
|
|
691
|
+
this.content.appendChild(actionRow);
|
|
692
|
+
|
|
693
|
+
if (faceMetadata) {
|
|
694
|
+
const faceLabel = document.createElement('div');
|
|
695
|
+
faceLabel.style.font = '12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
696
|
+
faceLabel.style.color = '#cbd5e1';
|
|
697
|
+
faceLabel.style.marginTop = '10px';
|
|
698
|
+
faceLabel.textContent = `Face metadata (${faceMetadata.faceName})`;
|
|
699
|
+
this.content.appendChild(faceLabel);
|
|
700
|
+
|
|
701
|
+
const facePre = document.createElement('pre');
|
|
702
|
+
facePre.textContent = JSON.stringify(faceMetadata.metadata, null, 2);
|
|
703
|
+
facePre.style.margin = '0';
|
|
704
|
+
facePre.style.padding = '8px';
|
|
705
|
+
facePre.style.background = '#0f172a';
|
|
706
|
+
facePre.style.color = '#e2e8f0';
|
|
707
|
+
facePre.style.font = '12px monospace';
|
|
708
|
+
facePre.style.border = '1px solid #1f2937';
|
|
709
|
+
facePre.style.borderRadius = '4px';
|
|
710
|
+
facePre.style.maxHeight = '160px';
|
|
711
|
+
facePre.style.overflow = 'auto';
|
|
712
|
+
facePre.style.whiteSpace = 'pre-wrap';
|
|
713
|
+
facePre.style.wordBreak = 'break-word';
|
|
714
|
+
this.content.appendChild(facePre);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const effectiveLabel = document.createElement('div');
|
|
718
|
+
effectiveLabel.style.font = '12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
719
|
+
effectiveLabel.style.color = '#cbd5e1';
|
|
720
|
+
effectiveLabel.style.marginTop = '6px';
|
|
721
|
+
effectiveLabel.textContent = 'Effective metadata (after inheritance)';
|
|
722
|
+
this.content.appendChild(effectiveLabel);
|
|
723
|
+
|
|
724
|
+
const effectivePre = document.createElement('pre');
|
|
725
|
+
effectivePre.textContent = JSON.stringify(effective, null, 2);
|
|
726
|
+
effectivePre.style.margin = '0';
|
|
727
|
+
effectivePre.style.padding = '8px';
|
|
728
|
+
effectivePre.style.background = '#0f172a';
|
|
729
|
+
effectivePre.style.color = '#e2e8f0';
|
|
730
|
+
effectivePre.style.font = '12px monospace';
|
|
731
|
+
effectivePre.style.border = '1px solid #1f2937';
|
|
732
|
+
effectivePre.style.borderRadius = '4px';
|
|
733
|
+
effectivePre.style.maxHeight = '160px';
|
|
734
|
+
effectivePre.style.overflow = 'auto';
|
|
735
|
+
effectivePre.style.whiteSpace = 'pre-wrap';
|
|
736
|
+
effectivePre.style.wordBreak = 'break-word';
|
|
737
|
+
this.content.appendChild(effectivePre);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
_stringifyMetadataValue(value) {
|
|
741
|
+
if (typeof value === 'string') return value;
|
|
742
|
+
if (value === undefined) return '';
|
|
743
|
+
try { return JSON.stringify(value); }
|
|
744
|
+
catch { return String(value); }
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
_parseMetadataValue(text) {
|
|
748
|
+
const raw = String(text ?? '').trim();
|
|
749
|
+
if (!raw) return '';
|
|
750
|
+
try { return JSON.parse(raw); }
|
|
751
|
+
catch { return raw; }
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
_commitMetadataValue(manager, targetName, key, rawValue) {
|
|
755
|
+
if (!manager || !targetName || !key) return;
|
|
756
|
+
const rawString = String(rawValue ?? '');
|
|
757
|
+
const parsed = this._parseMetadataValue(rawValue);
|
|
758
|
+
const isColorKey = this._isColorKey(key);
|
|
759
|
+
const isBlank = rawString.trim() === '' || (isColorKey && parsed === '');
|
|
760
|
+
if (isColorKey && isBlank) {
|
|
761
|
+
manager.deleteMetadataKey(targetName, key);
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
const data = manager.getOwnMetadata(targetName);
|
|
765
|
+
data[key] = parsed;
|
|
766
|
+
manager.setMetadataObject(targetName, data);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
_getDefaultColorKey(target) {
|
|
770
|
+
if (!target) return null;
|
|
771
|
+
const type = target.type;
|
|
772
|
+
if (type === 'SOLID' || type === 'FACE' || type === 'EDGE') return 'color';
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
_isColorKey(key) {
|
|
777
|
+
const raw = String(key ?? '').trim();
|
|
778
|
+
if (!raw) return false;
|
|
779
|
+
return /color/i.test(raw);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
_resolveColorHex(valueString) {
|
|
783
|
+
const parsed = this._parseMetadataValue(valueString);
|
|
784
|
+
return this._coerceColorToHex(parsed) || this._coerceColorToHex(valueString);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
_coerceColorToHex(value) {
|
|
788
|
+
if (value == null) return null;
|
|
789
|
+
if (typeof value === 'string') return this._parseColorStringToHex(value);
|
|
790
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
791
|
+
const n = Math.max(0, Math.min(0xffffff, Math.round(value)));
|
|
792
|
+
return `#${n.toString(16).padStart(6, '0')}`;
|
|
793
|
+
}
|
|
794
|
+
if (Array.isArray(value) && value.length >= 3) {
|
|
795
|
+
const r = Number(value[0]);
|
|
796
|
+
const g = Number(value[1]);
|
|
797
|
+
const b = Number(value[2]);
|
|
798
|
+
if (![r, g, b].every(Number.isFinite)) return null;
|
|
799
|
+
const max = Math.max(r, g, b);
|
|
800
|
+
return max <= 1 ? this._rgbToHex(r * 255, g * 255, b * 255) : this._rgbToHex(r, g, b);
|
|
801
|
+
}
|
|
802
|
+
if (typeof value === 'object') {
|
|
803
|
+
const r = Number(value.r);
|
|
804
|
+
const g = Number(value.g);
|
|
805
|
+
const b = Number(value.b);
|
|
806
|
+
if ([r, g, b].every(Number.isFinite)) {
|
|
807
|
+
const max = Math.max(r, g, b);
|
|
808
|
+
return max <= 1 ? this._rgbToHex(r * 255, g * 255, b * 255) : this._rgbToHex(r, g, b);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return null;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
_parseColorStringToHex(raw) {
|
|
815
|
+
const v = String(raw ?? '').trim();
|
|
816
|
+
if (!v) return null;
|
|
817
|
+
const hexMatch = v.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
818
|
+
if (hexMatch) {
|
|
819
|
+
const h = hexMatch[1];
|
|
820
|
+
if (h.length === 3) {
|
|
821
|
+
return `#${h[0]}${h[0]}${h[1]}${h[1]}${h[2]}${h[2]}`.toLowerCase();
|
|
822
|
+
}
|
|
823
|
+
return `#${h.toLowerCase()}`;
|
|
824
|
+
}
|
|
825
|
+
const hex0xMatch = v.match(/^0x([0-9a-f]{6})$/i);
|
|
826
|
+
if (hex0xMatch) return `#${hex0xMatch[1].toLowerCase()}`;
|
|
827
|
+
|
|
828
|
+
const rgbMatch = v.match(/^rgba?\((.+)\)$/i);
|
|
829
|
+
if (rgbMatch) {
|
|
830
|
+
const inner = rgbMatch[1].replace('/', ' ');
|
|
831
|
+
const parts = inner.split(/[, ]+/).map(p => p.trim()).filter(Boolean);
|
|
832
|
+
if (parts.length < 3) return null;
|
|
833
|
+
const r = this._parseRgbComponent(parts[0]);
|
|
834
|
+
const g = this._parseRgbComponent(parts[1]);
|
|
835
|
+
const b = this._parseRgbComponent(parts[2]);
|
|
836
|
+
if (![r, g, b].every(Number.isFinite)) return null;
|
|
837
|
+
return this._rgbToHex(r, g, b);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
const hslMatch = v.match(/^hsla?\((.+)\)$/i);
|
|
841
|
+
if (hslMatch) {
|
|
842
|
+
const inner = hslMatch[1].replace('/', ' ');
|
|
843
|
+
const parts = inner.split(/[, ]+/).map(p => p.trim()).filter(Boolean);
|
|
844
|
+
if (parts.length < 3) return null;
|
|
845
|
+
const h = this._parseHue(parts[0]);
|
|
846
|
+
const s = this._parsePercent(parts[1]);
|
|
847
|
+
const l = this._parsePercent(parts[2]);
|
|
848
|
+
if (![h, s, l].every(Number.isFinite)) return null;
|
|
849
|
+
const rgb = this._hslToRgb(h, s, l);
|
|
850
|
+
return this._rgbToHex(rgb.r * 255, rgb.g * 255, rgb.b * 255);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return null;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
_parseRgbComponent(text) {
|
|
857
|
+
const s = String(text ?? '').trim();
|
|
858
|
+
if (!s) return NaN;
|
|
859
|
+
if (s.endsWith('%')) {
|
|
860
|
+
const num = parseFloat(s.slice(0, -1));
|
|
861
|
+
if (!Number.isFinite(num)) return NaN;
|
|
862
|
+
return (num / 100) * 255;
|
|
863
|
+
}
|
|
864
|
+
const num = parseFloat(s);
|
|
865
|
+
if (!Number.isFinite(num)) return NaN;
|
|
866
|
+
return num;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
_parseHue(text) {
|
|
870
|
+
const s = String(text ?? '').trim().toLowerCase();
|
|
871
|
+
if (!s) return NaN;
|
|
872
|
+
if (s.endsWith('turn')) {
|
|
873
|
+
const num = parseFloat(s.slice(0, -4));
|
|
874
|
+
if (!Number.isFinite(num)) return NaN;
|
|
875
|
+
return num * 360;
|
|
876
|
+
}
|
|
877
|
+
if (s.endsWith('rad')) {
|
|
878
|
+
const num = parseFloat(s.slice(0, -3));
|
|
879
|
+
if (!Number.isFinite(num)) return NaN;
|
|
880
|
+
return (num * 180) / Math.PI;
|
|
881
|
+
}
|
|
882
|
+
if (s.endsWith('deg')) {
|
|
883
|
+
const num = parseFloat(s.slice(0, -3));
|
|
884
|
+
if (!Number.isFinite(num)) return NaN;
|
|
885
|
+
return num;
|
|
886
|
+
}
|
|
887
|
+
const num = parseFloat(s);
|
|
888
|
+
if (!Number.isFinite(num)) return NaN;
|
|
889
|
+
return num;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
_parsePercent(text) {
|
|
893
|
+
const s = String(text ?? '').trim();
|
|
894
|
+
if (!s) return NaN;
|
|
895
|
+
if (s.endsWith('%')) {
|
|
896
|
+
const num = parseFloat(s.slice(0, -1));
|
|
897
|
+
if (!Number.isFinite(num)) return NaN;
|
|
898
|
+
return num / 100;
|
|
899
|
+
}
|
|
900
|
+
const num = parseFloat(s);
|
|
901
|
+
if (!Number.isFinite(num)) return NaN;
|
|
902
|
+
return num > 1 ? num / 100 : num;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
_hslToRgb(h, s, l) {
|
|
906
|
+
const hue = ((h % 360) + 360) % 360;
|
|
907
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
908
|
+
const x = c * (1 - Math.abs((hue / 60) % 2 - 1));
|
|
909
|
+
const m = l - c / 2;
|
|
910
|
+
let r = 0;
|
|
911
|
+
let g = 0;
|
|
912
|
+
let b = 0;
|
|
913
|
+
if (hue < 60) {
|
|
914
|
+
r = c; g = x; b = 0;
|
|
915
|
+
} else if (hue < 120) {
|
|
916
|
+
r = x; g = c; b = 0;
|
|
917
|
+
} else if (hue < 180) {
|
|
918
|
+
r = 0; g = c; b = x;
|
|
919
|
+
} else if (hue < 240) {
|
|
920
|
+
r = 0; g = x; b = c;
|
|
921
|
+
} else if (hue < 300) {
|
|
922
|
+
r = x; g = 0; b = c;
|
|
923
|
+
} else {
|
|
924
|
+
r = c; g = 0; b = x;
|
|
925
|
+
}
|
|
926
|
+
return { r: r + m, g: g + m, b: b + m };
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
_rgbToHex(r, g, b) {
|
|
930
|
+
const toHex = (v) => {
|
|
931
|
+
const n = Math.max(0, Math.min(255, Math.round(v)));
|
|
932
|
+
return n.toString(16).padStart(2, '0');
|
|
933
|
+
};
|
|
934
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
_measureKeyWidth(text) {
|
|
938
|
+
if (!this.measureCtx) {
|
|
939
|
+
const canvas = document.createElement('canvas');
|
|
940
|
+
this.measureCtx = canvas.getContext('2d');
|
|
941
|
+
}
|
|
942
|
+
const ctx = this.measureCtx;
|
|
943
|
+
try { ctx.font = '12px monospace'; } catch {}
|
|
944
|
+
const metrics = ctx?.measureText ? ctx.measureText(String(text ?? '')) : { width: 0 };
|
|
945
|
+
return Math.ceil((metrics?.width || 0));
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
_inputHeightPx() {
|
|
949
|
+
if (this._cachedInputHeightPx) return this._cachedInputHeightPx;
|
|
950
|
+
const probe = document.createElement('input');
|
|
951
|
+
probe.type = 'text';
|
|
952
|
+
probe.style.visibility = 'hidden';
|
|
953
|
+
probe.style.position = 'absolute';
|
|
954
|
+
probe.style.top = '-10000px';
|
|
955
|
+
probe.style.font = '12px monospace';
|
|
956
|
+
probe.style.padding = '4px 6px';
|
|
957
|
+
probe.style.border = '1px solid #1f2937';
|
|
958
|
+
probe.style.background = '#0f172a';
|
|
959
|
+
probe.style.color = '#e2e8f0';
|
|
960
|
+
probe.style.boxSizing = 'border-box';
|
|
961
|
+
document.body.appendChild(probe);
|
|
962
|
+
const h = probe.offsetHeight || 32;
|
|
963
|
+
document.body.removeChild(probe);
|
|
964
|
+
this._cachedInputHeightPx = h;
|
|
965
|
+
return h;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
_getManager() {
|
|
969
|
+
return this.viewer?.partHistory?.metadataManager || null;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
_getFaceMetadataForTarget(target) {
|
|
973
|
+
if (!target) return null;
|
|
974
|
+
const faceName = target.userData?.faceName || target.name;
|
|
975
|
+
if (!faceName) return null;
|
|
976
|
+
const solid = this._findParentSolid(target);
|
|
977
|
+
if (!solid || typeof solid.getFaceMetadata !== "function") return null;
|
|
978
|
+
const metadata = solid.getFaceMetadata(faceName);
|
|
979
|
+
if (!metadata || typeof metadata !== "object" || Object.keys(metadata).length === 0) return null;
|
|
980
|
+
return { faceName, metadata };
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
_getEdgeMetadataForTarget(target) {
|
|
984
|
+
if (!target || target.type !== "EDGE") return null;
|
|
985
|
+
const edgeName = target.name;
|
|
986
|
+
if (!edgeName) return null;
|
|
987
|
+
const solid = this._findParentSolid(target);
|
|
988
|
+
if (!solid || typeof solid.getEdgeMetadata !== "function") return null;
|
|
989
|
+
const metadata = solid.getEdgeMetadata(edgeName);
|
|
990
|
+
if (!metadata || typeof metadata !== "object" || Object.keys(metadata).length === 0) return null;
|
|
991
|
+
return { edgeName, metadata };
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
_findParentSolid(target) {
|
|
995
|
+
if (!target) return null;
|
|
996
|
+
if (target.parentSolid) return target.parentSolid;
|
|
997
|
+
let current = target.parent;
|
|
998
|
+
while (current) {
|
|
999
|
+
if (current.parentSolid) return current.parentSolid;
|
|
1000
|
+
if (current.type === "SOLID") return current;
|
|
1001
|
+
current = current.parent;
|
|
1002
|
+
}
|
|
1003
|
+
return null;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
export function createMetadataButton(viewer) {
|
|
1008
|
+
if (!viewer) return null;
|
|
1009
|
+
if (!viewer[PANEL_CONTROLLER]) {
|
|
1010
|
+
viewer[PANEL_CONTROLLER] = new MetadataPanelController(viewer);
|
|
1011
|
+
}
|
|
1012
|
+
const controller = viewer[PANEL_CONTROLLER];
|
|
1013
|
+
const onClick = () => {
|
|
1014
|
+
controller.toggle();
|
|
1015
|
+
};
|
|
1016
|
+
return {
|
|
1017
|
+
label: '🏷️',
|
|
1018
|
+
title: 'Toggle Metadata panel',
|
|
1019
|
+
onClick
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Automatically adjusts textarea height as the user types,
|
|
1026
|
+
* ensuring no scrollbars appear.
|
|
1027
|
+
*
|
|
1028
|
+
* @param {HTMLTextAreaElement} textarea - The textarea DOM element.
|
|
1029
|
+
* @param {number} [minHeightPx=0] - Minimum height in pixels the textarea should maintain.
|
|
1030
|
+
*/
|
|
1031
|
+
function autoResizeTextarea(textarea, minHeightPx = 0) {
|
|
1032
|
+
if (!(textarea instanceof HTMLTextAreaElement)) {
|
|
1033
|
+
throw new Error('Argument must be a textarea element');
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
const base = Number(minHeightPx) > 0 ? Number(minHeightPx) : 0;
|
|
1037
|
+
if (base > 0) {
|
|
1038
|
+
textarea.style.minHeight = `${base}px`;
|
|
1039
|
+
}
|
|
1040
|
+
textarea.style.overflowY = 'hidden';
|
|
1041
|
+
|
|
1042
|
+
// Function that resizes based on scrollHeight
|
|
1043
|
+
const resize = () => {
|
|
1044
|
+
textarea.style.height = 'auto'; // Reset to compute true scrollHeight
|
|
1045
|
+
const target = Math.max(base, textarea.scrollHeight);
|
|
1046
|
+
textarea.style.height = `${target}px`;
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
const scheduleResize = () => {
|
|
1050
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
1051
|
+
requestAnimationFrame(resize);
|
|
1052
|
+
} else {
|
|
1053
|
+
resize();
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
// Initial sizing
|
|
1058
|
+
scheduleResize();
|
|
1059
|
+
|
|
1060
|
+
// Listen for input events (fires on every character add/remove)
|
|
1061
|
+
textarea.addEventListener('input', scheduleResize, false);
|
|
1062
|
+
textarea.addEventListener('change', scheduleResize, false);
|
|
1063
|
+
}
|