diff --git a/package.json b/package.json index e47f910c9..3d7849400 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "testw": "jest --watchAll", "postinstall": "ts-node ./utils/copy_type.ts", "publish": "ts-node ./utils/publish.ts", - "dev:share": "webpack serve -c ./config/webpack.dev.ts --entry ./src/Add-on/ShareView/ShareViewEntry.tsx --port 7776" + "dev:share": "webpack serve -c ./config/webpack.dev.ts --entry-reset ./src/Add-on/ShareView/ShareViewEntry.tsx --port 7776" }, "private": true, "author": "", @@ -91,6 +91,7 @@ "url-loader": "^4.1.1", "wallaby-webpack": "^3.9.16", "webpack": "^5.89.0", + "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.2", "webpack-merge": "^5.10.0", diff --git a/src/Add-on/ShareView/Command_ShareView.ts b/src/Add-on/ShareView/Command_ShareView.ts index bfdfaaf49..2761766c2 100644 --- a/src/Add-on/ShareView/Command_ShareView.ts +++ b/src/Add-on/ShareView/Command_ShareView.ts @@ -40,7 +40,7 @@ export class Command_ShareView implements Command UseSelect: true, Filter: { filterFunction: (obj, ent) => - !(ent instanceof DirectionalLight || ent instanceof EntityRef || ent instanceof EntityFbx || + !(ent instanceof DirectionalLight || (!store.m_Option.IsExportBoard && (ent instanceof Board)) || (!store.m_Option.IsExportHardware && (ent instanceof HardwareCompositeEntity || ent instanceof HardwareTopline)))//避免拷贝太阳光 太阳光只能有一个 }, }); diff --git a/src/Add-on/ShareView/README.md b/src/Add-on/ShareView/README.md new file mode 100644 index 000000000..8989e730f --- /dev/null +++ b/src/Add-on/ShareView/README.md @@ -0,0 +1,8 @@ +```shell +# 调试 +yarn webpack serve -c src/Add-on/ShareView/webpack.dev.ts +# 编译 +yarn webpack build -c src/Add-on/ShareView/webpack.prod.ts +# 查看打包分析 +yarn webpack build -c src/Add-on/ShareView/webpack.prod.ts --analyze +``` diff --git a/src/Add-on/ShareView/ShareViewCameraControl.ts b/src/Add-on/ShareView/ShareViewCameraControl.ts new file mode 100644 index 000000000..3ce531c5e --- /dev/null +++ b/src/Add-on/ShareView/ShareViewCameraControl.ts @@ -0,0 +1,143 @@ +import { Vector3 } from "three"; +import { clamp } from "../../Common/Utils"; +import { CameraControls, CameraControlState } from "../../Editor/CameraControls"; +import { Touch_Event } from "../../Editor/TouchEditor/VirtualMouseEditor"; +import { userConfig } from "../../Editor/UserConfig"; +import { equaln } from "../../Geometry/GeUtils"; +import { CameraType } from "../../GraphicsSystem/CameraUpdate"; +import { Viewer } from "../../GraphicsSystem/Viewer"; +import { ShareViewStore } from "./ShareViewStore"; + +export class ShareViewCameraControl extends CameraControls +{ + private shareViewStore: ShareViewStore = ShareViewStore.GetInstance(); + private minFov: number = 45; + private maxFov: number = 120; + + constructor(Viewer: Viewer) + { + super(Viewer); + } + + private _TouchScaleCenterWCS2 = new Vector3; + private _TouchScaleCenterVCS2 = new Vector3; + + // 重写基类方法,使用targetTouches计算坐标 + // targetTouches仅包含本次事件新增的触摸点,这样不会影响移动端虚拟摇杆的操控 + override onTouchStart = (event: Touch_Event) => + { + this.Viewer.UpdateLockTarget(); + this.StartTouchPoint.set(event.targetTouches[0].pageX, event.targetTouches[0].pageY, 0); + if (event.targetTouches.length < 4) + { + if (event.targetTouches.length == 2) + { + let dx = event.targetTouches[0].pageX - event.targetTouches[1].pageX; + let dy = event.targetTouches[0].pageY - event.targetTouches[1].pageY; + let distance = Math.sqrt(dx * dx + dy * dy); + this.DollyStart = distance; + + let rect = (event.target as HTMLElement).getBoundingClientRect(); + this._TouchScaleCenterVCS2.set((event.targetTouches[0].clientX + event.targetTouches[1].clientX) * 0.5, (event.targetTouches[0].clientY + event.targetTouches[1].clientY) * 0.5, 0); + this._TouchScaleCenterWCS2.set((event.targetTouches[0].clientX + event.targetTouches[1].clientX) * 0.5 - rect.left, (event.targetTouches[0].clientY + event.targetTouches[1].clientY) * 0.5 - rect.top, 0); + this.Viewer.ScreenToWorld(this._TouchScaleCenterWCS2); + } + + this.State_Touch = this.TouchTypeList[event.targetTouches.length - 1]; + + if (!this.EnableTouchControl && event.targetTouches.length === 1)//在单手指模式下 如果有虚拟鼠标 则禁止旋转 + this.State_Touch = CameraControlState.Null; + } + }; + + // 重写基类方法,使用targetTouches计算坐标 + // targetTouches仅包含本次事件新增的触摸点,这样不会影响移动端虚拟摇杆的操控 + override onTouchMove(event: Touch_Event) + { + event.preventDefault(); + event.stopPropagation(); + + this.EndTouchPoint.set(event.targetTouches[0].pageX, event.targetTouches[0].pageY, 0); + + let vec = this.EndTouchPoint.clone().sub(this.StartTouchPoint); + switch (this.State_Touch) + { + case CameraControlState.Pan: + { + this.Viewer.Pan(vec); + break; + } + case CameraControlState.Scale: + { + if (event.touches.length < 2) + break; + + let dx = event.touches[0].pageX - event.touches[1].pageX; + let dy = event.touches[0].pageY - event.touches[1].pageY; + + let distance = Math.sqrt(dx * dx + dy * dy); + if (!equaln(this.DollyStart / distance, 1, 0.05))//轻微防抖 + { + // <-- ShareView缩放逻辑 + const scale = this.DollyStart / distance; + if (this.Viewer.CameraControl.CameraType === CameraType.PerspectiveCamera) + { + // ShareView中用更改FOV的方式替换原有的透视相机缩放逻辑(CameraControl难以重写) + this.Viewer.CameraControl.Fov = clamp(this.Viewer.CameraControl.Fov * scale, this.minFov, this.maxFov); + if (screen.orientation.type.startsWith("portrait")) + { + this.shareViewStore.userFovPortrait = scale; + } + else if (screen.orientation.type.startsWith("landscape")) + { + this.shareViewStore.userFovLandscape = scale; + } + } + else + { + this.Viewer.Zoom(scale, this._TouchScaleCenterWCS2); + } + // --> + + this.DollyStart = distance; + } + + // <-- 透视相机不允许双指平移操作 + if (this.Viewer.CameraControl.CameraType === CameraType.PerspectiveCamera) + break; + // --> + + //move + let nowCenter = new Vector3((event.touches[0].clientX + event.touches[1].clientX) * 0.5, (event.touches[0].clientY + event.targetTouches[1].clientY) * 0.5, 0); + this._TouchScaleCenterVCS2.subVectors(nowCenter, this._TouchScaleCenterVCS2); + this.Viewer.Pan(this._TouchScaleCenterVCS2); + this._TouchScaleCenterVCS2.copy(nowCenter); + + break; + } + case CameraControlState.Rotate: + { + this.Viewer.Rotate(vec.multiplyScalar(2)); + break; + } + } + this.StartTouchPoint.copy(this.EndTouchPoint); + this.Viewer.UpdateRender(); + }; + + override onMouseWheel(event: WheelEvent) + { + event.preventDefault(); + event.stopPropagation(); + if (this.shareViewStore.HouseRoamingMode) // 漫游模式禁用滚轮缩放 + return; + + let pt = new Vector3(event.offsetX, event.offsetY, 0); + + this.Viewer.ScreenToWorld(pt, this.cameraNormal.setFromMatrixColumn(this.Viewer.Camera.matrixWorld, 2)); + if (event.deltaY < 0) + this.Viewer.Zoom(userConfig.viewSize.zoomSpeed, pt); + else if (event.deltaY > 0) + this.Viewer.Zoom(2 - userConfig.viewSize.zoomSpeed, pt); + } +} diff --git a/src/Add-on/ShareView/ShareViewCommandRegister.ts b/src/Add-on/ShareView/ShareViewCommandRegister.ts new file mode 100644 index 000000000..2c79c6e36 --- /dev/null +++ b/src/Add-on/ShareView/ShareViewCommandRegister.ts @@ -0,0 +1,837 @@ +import { Vector3 } from "three"; +import { Command_FlipZMatrix } from "../../Common/CommandFlipZMatrix"; +import { CommandNames } from "../../Common/CommandNames"; +import { Command_SetLineOCS } from "../../Common/CommandSetLineOCS"; +import { IsTest } from "../../Common/Deving"; +import { TemplateArray, TemplateAttach, TemplateAttach2 } from "../../DatabaseServices/Template/TemplateTest"; +import { commandMachine } from "../../Editor/CommandMachine"; +import { Command_GizmoCSSwith, Command_SetGizmoMode } from "../../Editor/TranstrolControl/Command_SetGizmoMode"; +import { TransMode } from "../../Editor/TranstrolControl/TransformServices"; +import { userConfig } from "../../Editor/UserConfig"; +import { RenderType } from "../../GraphicsSystem/RenderType"; +import { Command_HeadCeilingContourManage } from "../../UI/Components/HeadCeiling/HeadCeilingContourManageCommand"; +import { Command_HeadCeilingInfoConfigPanel, Command_HeadCeilingMaterialPanel } from "../../UI/Components/HeadCeiling/HeadCeilingInfoConfigPanelCommand"; +import { EOptionTabId } from "../../UI/Components/Modal/OptionModal/ConfigDialog"; +import { Align } from "../Align"; +import { Command_DrawArcBoard } from "../ArcBoard/DrawArcBoard"; +import { Command_Area } from "../Area"; +import { Command_Array } from "../Array"; +import { AutoHoleFaceSetting } from "../AutoHoleFaceSetting"; +import { BackgroundSwitching } from "../BackgroundSwitching"; +import { FindModeingKnifeRadius } from "../Batch/FindModeingKnifes"; +import { CuttingByFace, CuttingByRectFace } from "../BoardCutting/CuttingByFace"; +import { DeleteRelevance } from "../BoardCutting/DeleteRelevance"; +import { Command_ChangeBoardColorByPBFace } from "../BoardEditor/ChangeBoardColorByPBFace"; +import { Command_ClearBoard2DModeling } from "../BoardEditor/ClearBoard2DModeling"; +import { SetBoardLines, SetComposingFace } from "../BoardEditor/SetBoardLines"; +import { Command_TextModifyTool } from "../BoardEditor/TextModifyTool"; +import { UpdateBoardInfos } from "../BoardEditor/UpdateBoardInfos"; +import { OneClickInspection } from "../BoardInspection/OneClickInspection"; +import { IntersectionOperation, SubsractOperation, UnionOperation } from "../BoolOperation"; +import { Command_Break, Command_BreakAll } from "../Break"; +import { Command_CameraSnapshootRestore, Command_CameraSnapshootSave, Command_CameraSnapshootSaveIndex } from "../CameraSnapshootCMD"; +import { ChangeColorByMaterial } from "../ChangeColorByBoard/ChangeColorByMaterial"; +import { ChangeColorByRoomCabinet } from "../ChangeColorByRoomOrCabinet/ChangeColorByRoomOrCabinet"; +import { CheckHoles } from "../CheckHoles"; +import { CheckModeling } from "../CheckModeling"; +import { Cmd_Freeze, Cmd_UnFreeze } from "../Cmd_Freeze"; +import { Cmd_UnVisibleInRender, Cmd_VisibleInRender } from "../Cmd_VisibleInRender"; +import { CombinatAttributeBrush } from "../CombinatAttributeBrush"; +import { Command_CombineEntity } from "../Command_CombineEntity"; +import { Command_Options } from "../Command_Option"; +import { Command_PickUp2DModelCsgs } from "../Command_PickUp2DModelCsgs"; +import { Command_Purge } from "../Command_Purge"; +import { Command_Conver2Polyline } from "../Conver2Polyline"; +import { Command_Copy } from "../Copy"; +import { CopyClip } from "../CopyClip"; +import { Command_CopyPoint } from "../CopyPoint"; +import { CustomUcs } from "../CostumUCS"; +import { Command_CleanCustomNumber, Command_CustomNumber } from "../CustomNumber/Command_CustomNumber"; +import { DeleteCurve } from "../DeleteCurve"; +import { Command_Dist } from "../Dist"; +import { CMD_Divide } from "../Divide"; +import { DrawArc } from "../DrawArc"; +import { DrawTemplateByImport } from "../DrawBoard/DrawTemplateByImport"; +import { FindMaxOrMinSizeBoard } from "../DrawBoard/FindMaxSizeBoard"; +import { FixIntersectSelfContour } from "../DrawBoard/FixIntersectSelfContour"; +import { ParseHandle } from "../DrawBoard/ParseHandle"; +import { ParseHinge } from "../DrawBoard/ParseHinge"; +import { SetHoleNoneType } from "../DrawBoard/SetHoleType"; +import { DrawCircle } from "../DrawCircle"; +import { DrawCylineder } from "../DrawCylinder"; +import { Command_DimContinue } from "../DrawDim/Command_DimContinue"; +import { Command_DimStyle } from "../DrawDim/Command_DimStyle"; +import { Command_DimArc } from "../DrawDim/DimArc"; +import { Command_Draw2LineAngularDim } from "../DrawDim/Draw2LineAngularDim"; +import { DrawAlignedDimension } from "../DrawDim/DrawAlignedDimension"; +import { DrawDiameterDim } from "../DrawDim/DrawDiameterDim"; +import { DrawLinearDimension } from "../DrawDim/DrawLinearDimension"; +import { DrawRadiusDim } from "../DrawDim/DrawRadiusDim"; +import { Command_HideDim, Command_ShowDim } from "../DrawDim/OneKeyHideOrShowDim"; +import { CheckDrawHole } from "../DrawDrilling/CheckDrawHole"; +import { CheckHasHoleBoard } from "../DrawDrilling/CheckHasHole"; +import { AddAssocDrillLock } from "../DrawDrilling/DrillLock/AddAssocDrillLock"; +import { AddAloneDrillLock } from "../DrawDrilling/DrillLock/AloneDrillLock"; +import { RemoveAssocDrillLock } from "../DrawDrilling/DrillLock/RemoveAssocDrillLock"; +import { RemoveDrillLock } from "../DrawDrilling/DrillLock/RemoveDrillLock"; +import { ShowDrillingTemplate } from "../DrawDrilling/ShowDrillingTemplate"; +import { ToggleDrillingReactor } from "../DrawDrilling/ToggleDrillingReactor"; +import { DrawEllipse } from "../DrawEllipse"; +import { DrawExtrude } from "../DrawExtrude"; +import { DrawGripStretch } from "../DrawGripStretch"; +import { BatchModifyLights } from "../DrawLight/BatchModifyLights"; +import { DrawPointLight } from "../DrawLight/DrawPointLight"; +import { DrawRectAreaLight } from "../DrawLight/DrawRectAreaLight"; +import { DrawSpotLight, DrawSpotLight2 } from "../DrawLight/DrawSpotLight"; +import { Command_DrawXLine, DrawLine } from "../DrawLine"; +import { CMD_DrawPoint } from "../DrawPoint"; +import { DrawPolygon } from "../DrawPolygon"; +import { DrawPolyline } from "../DrawPolyline"; +import { DrawRect } from "../DrawRect"; +import { DrawRegion } from "../DrawRegion"; +import { Command_DrawRevolve } from "../DrawRevolve"; +import { DrawSky } from "../DrawSky"; +import { DrawSphere } from "../DrawSphere"; +import { DrawSpline } from "../DrawSpline"; +import { DrawRegTest } from "../DrawTestReg"; +import { DrawText } from "../DrawText"; +import { Draw2Viewport, Draw3Viewport, Draw4Viewport, DrawViewport } from "../DrawViewport"; +import { Polyline2Winerack } from "../DrawWineRack/Polyline2Winerack"; +import { DrawCircle0 } from "../DrawZeroCircle"; +import { Command_EndTempEditor } from "../EndTempEditor"; +import { Command_EntitytMoveToZ0 } from "../EntityMoveToZ0"; +import { Entsel } from "../Entsel"; +import { Command_Erase } from "../Erase"; +import { Command_EraseLineAndArc } from "../EraseLineAndArc"; +import { Command_EraseNoSelect } from "../EraseNoSelect"; +import { Command_Esc } from "../Esc"; +import { Command_ExportSTL } from "../Exports/ExportSTL"; +import { Command_Extend } from "../Extends"; +import { Command_OpenHistory } from "../File/OpenHistory"; +import { OperLogs } from "../File/OperLog"; +import { CommandFillet } from "../Fillet"; +import { Command_FindBoardModelingKnife } from "../FindBoardModelingKnife"; +import { Command_Fix2DPath } from "../Fix/Fix2DPath"; +import { Command_Group, Command_UnGroup } from "../Group"; +import { Command_HideSelected, Command_HideUnselected, Command_ShowAll, Command_SwitchDoorOrDrawer, SelectAll, ShowHideSelectPanel } from "../HideSelected"; +import { Command_HighlightNode, Command_HighlightNodeAndChilds } from "../HighlightNode"; +import { Command_Insert } from "../Insert"; +import { Command_Join } from "../Join"; +import { EditorLattice } from "../LatticeDrawer/EditorLattice"; +import { Command_Length } from "../Length"; +import { Command_Lisp } from "../Lisp"; +import { Command_MatchProp } from "../MatchProp"; +import { Command_Move } from "../Move"; +import { Command_Cmd_Down } from "../Move/Cmd_Down"; +import { Command_M0, Command_PackageMove } from "../MoveToWCS0"; +import { Command_ExportObj } from "../Obj/Command_ExportObj"; +import { Command_ExportObjAndMtl } from "../Obj/Command_ExportObjMtl"; +import { Command_DynOffset, Command_DynOffsetToolPath, Command_Offset } from "../Offset"; +import { Open } from "../Open"; +import { PasteClip } from "../PasteClip"; +import { Pedit } from "../Pedit"; +import { ReOpen } from "../ReOpen"; +import { CMD_Renderer } from "../Renderer"; +import { Command_ResetCustomCommand } from "../ResetCustomCommand"; +import { Command_RestoreColor } from "../RestoreColor"; +import { Command_Reverse } from "../Reverse"; +import { Command_ParseRoomWall } from "../Room/ParseRoomWall"; +import { Command_Rotate, Command_RotateRefer } from "../Rotate"; +import { New } from "../Save"; +import { Command_Scale } from "../Scale"; +import { SetSmoothEdge } from "../SetSmoothEdge/SetSmoothEdge"; +import { Command_Show2DPathLine } from "../Show2DPathLine/Show2DPathLine"; +import { Command_Show2DPathObject } from "../Show2DPathLine/Show2DPathObject"; +import { SwitchLines } from "../ShowLines"; +import { ShowOpenDirLiens } from "../ShowOpenDirLiens"; +import { Command_ShowProcessingGroupModal } from "../ShowProcessingGroupModal"; +import { Stretch } from "../Stretch"; +import { Command_SuperCopy } from "../SuperCopy"; +import { Sweep } from "../Sweep"; +import { Command_SwitchCamera } from "../SwitchCamera"; +import { ChangeRenderType } from "../SwitchVisualStyles"; +import { DrawTangentLine } from "../Tangent"; +import { BoardReplaceTempate } from "../Template/BoardReplaceTemplate"; +import { DrawVisualSpaceBox } from "../Template/DrawVisualSpaceBox"; +import { ShowFrmae } from "../Template/ShowFrame"; +import { Command_TemplateSearch } from "../TemplateSearch"; +import { Command_TestPointPickParse } from "../TestPointPickParse"; +import { Text2Curve } from "../Text2Curve"; +import { Command_ToggleUI } from "../ToggleUI"; +import { Command_Trim } from "../Trim"; +import { Redo, Undo } from "../Undo"; +import { ViewChange } from "../ViewChange"; +import { Command_FixView } from "../ViewCtrl/FixView"; +import { EditFrame } from "../ViewortConfig/EditFrame"; +import { EditViewport } from "../ViewortConfig/EditViewport"; +import { OneKeyLayout } from "../Viewport/OneKeyLayout"; +import { OneKeyPrint } from "../Viewport/OneKeyPrint"; +import { Command_Wblock } from "../Wblock"; +import { Command_ZoomObject, ZoomE } from "../ZoomE"; +import { Interfere } from "../interfere"; +import { TestFillet } from "../testEntity/TestFilletCode"; +import { Command_Curve2Polyline } from "../twoD2threeD/Command_Curve2Polyline"; +import { Command_Curve2VSBox } from "../twoD2threeD/Command_Curve2VSBox"; +import { Command_ParseBoardName } from "../twoD2threeD/ParseBoardName"; +import { Polyline2Board } from "../twoD2threeD/Polyline2Board"; +import { Rect2Board } from "../twoD2threeD/Rect2Board"; +import { Command_OpenCabinet } from "../OpenCabinet/OpenCabinet"; +import { DrawLeftRight } from "../DrawBoard/DrawLeftRightBoard"; +import { DrawTopBottomBoard } from "../DrawBoard/DrawTopBottomBoard"; +import { DrawBehindBoard } from "../DrawBoard/DrawBehindBoard"; +import { DrawLayerBoard } from "../DrawBoard/DrawLayerBoard"; +import { DrawVerticalBoard } from "../DrawBoard/DrawVerticalBoard"; +import { DrawSingleBoard } from "../DrawBoard/DrawSingleBoard"; +import { DrawClosingStrip } from "../DrawBoard/DrawClosingStrip"; +import { DrawDoor } from "../DrawBoard/DrawDoor"; +import { DrillConfig } from "../DrawDrilling/DrillConfig"; +import { DrawDrilling } from "../DrawDrilling/DrawDrilling"; +import { DrawSpecialShapedBoard } from "../DrawBoard/DrawSpecialShapedBoard"; +import { DrawSpecialShapedBoardByContour } from "../DrawBoard/DrawSpecialShapedBoardByContour"; +import { Command_ApplyModelToBoards } from "../DrawBoard/ApplyModelToBoards"; +import { ApplyModel2ToBoard } from "../DrawBoard/ApplyModel2ToBoard"; +import { LinearCutting, RectLinearCutting } from "../BoardCutting/LinearCutting"; +import { NonAssociativeCutting } from "../BoardCutting/NonAssociativeCutting"; +import { ReferenceCutting } from "../BoardCutting/ReferenceCutting"; +import { AddPtOnBoard, DeletePtOnBoard } from "../AddPtOnBoard"; +import { BoardFindModify } from "../BoardFindModify"; +import { LookOverBoardInfos } from "../LookOverBoardInfos/LookOverBoardInfos"; +import { BoardBatchCurtail } from "../BoardBatchCurtail"; +import { BatchModifyPanel } from "../BatchModifyPanel"; +import { Command_AutoDimBrs } from "../DrawDim/AutoDimBrs"; +import { Command_BoardInfoDimTool } from "../DrawDim/BoardInfoDimTool"; +import { Command_FastDimBrs } from "../DrawDim/FastDim/FastDim"; +import { BreakDim } from "../DrawDim/BreakDim"; +import { DeleteDim, DeleteMinDim } from "../DrawDim/DeleteDim"; +import { RotateLayerBoard } from "../RotateLayerBoard"; +import { DrawDrawrer } from "../DrawBoard/DrawDrawer"; +import { DeleteDrill } from "../DrawDrilling/DeleteDrill"; +import { ReverseDrillFace } from "../DrawDrilling/ReverseDrillFace"; +import { Command_FZWL } from "../FZWL"; +import { EditorBoardTemplate } from "../DrawBoard/EditorBoardTempate"; +import { ActicityLayerBoard } from "../ActivityLayerBoard"; + +export function registerCommand() +{ + commandMachine.RegisterCommand(CommandNames.Puge, new Command_Purge()); + + commandMachine.RegisterCommand("end", new Command_EndTempEditor()); + + //恢复板颜色 + commandMachine.RegisterCommand(CommandNames.RestoreColor, new Command_RestoreColor()); + + //酷家乐 + // commandMachine.RegisterCommand(CommandNames.KJLImport, new Command_KJLImport()); + // commandMachine.RegisterCommand(CommandNames.KJLCongfig, new Command_KJLImportConfig("config")); + // commandMachine.RegisterCommand(CommandNames.KJLMaterialMap, new Command_KJLImportConfig("material")); + // commandMachine.RegisterCommand(CommandNames.KJLExport, new KjlExport()); + // commandMachine.RegisterCommand(CommandNames.Clearkjltoken, new ClearKjlToken()); + + //嘉居 + // commandMachine.RegisterCommand(CommandNames.JiaJuImport, new Command_JiaJuImport()); + + //晨丰导入 + // commandMachine.RegisterCommand(CommandNames.CFImport, new ImportCFData()); + + //编组 + commandMachine.RegisterCommand(CommandNames.Group, new Command_Group()); + commandMachine.RegisterCommand(CommandNames.UnGroup, new Command_UnGroup()); + + //冻结 + commandMachine.RegisterCommand(CommandNames.Freeze, new Cmd_Freeze()); + commandMachine.RegisterCommand(CommandNames.UnFreeze, new Cmd_UnFreeze()); + + //渲染器隐藏/显示实体 + commandMachine.RegisterCommand(CommandNames.VisibleInRender, new Cmd_VisibleInRender()); + commandMachine.RegisterCommand(CommandNames.UnVisibleInRender, new Cmd_UnVisibleInRender()); + + //CAD图纸导入 + // commandMachine.RegisterCommand(CommandNames.DXFImport, new Command_DWGDXFImport()); + // commandMachine.RegisterCommand(CommandNames.DWGImport, new Command_DWGDXFImport()); + // commandMachine.RegisterCommand(CommandNames.FBXImport, new Command_FBXImport()); + + //帮帮我 出错了 + // commandMachine.RegisterCommand("999", new Command_999()); + + // 应用 放样曲线 生成 曲面板材 + commandMachine.RegisterCommand(CommandNames.DrawArcBoard, new Command_DrawArcBoard()); + + // if (IsTest()) + // { + // commandMachine.RegisterCommand("testload", new Command_TestLoadFbx()); + // commandMachine.RegisterCommand("tt", new Test()); + // commandMachine.RegisterCommand("gxl", new Command_UpdateLight()); + // commandMachine.RegisterCommand("testVPath", new Command_TestVPath()); + // + // commandMachine.RegisterCommand("testRegionParse", new Command_TestRegionParse()); + // commandMachine.RegisterCommand("TestBoundaryBox", new Command_TestBoundaryBox()); + // commandMachine.RegisterCommand("TestSweepMaxLength", new Command_TestSweepMaxLength()); + // + // commandMachine.RegisterCommand("isrect", new Command_Test_IsRect()); + // } + + //插入图纸 + commandMachine.RegisterCommand(CommandNames.Insert, new Command_Insert()); + + commandMachine.RegisterCommand(CommandNames.Line, new DrawLine()); + commandMachine.RegisterCommand(CommandNames.XLine, new Command_DrawXLine()); + + commandMachine.RegisterCommand(CommandNames.Undo, new Undo()); + commandMachine.RegisterCommand(CommandNames.Redo, new Redo()); + commandMachine.RegisterCommand(CommandNames.Zoome, new ZoomE()); + commandMachine.RegisterCommand(CommandNames.ZoomObject, new Command_ZoomObject()); + commandMachine.RegisterCommand(CommandNames.RECTANG, new DrawRect()); + commandMachine.RegisterCommand(CommandNames.Polygon, new DrawPolygon()); + commandMachine.RegisterCommand(CommandNames.Circle, new DrawCircle()); + commandMachine.RegisterCommand(CommandNames.Ellipse, new DrawEllipse()); + commandMachine.RegisterCommand(CommandNames.Spline, new DrawSpline()); + commandMachine.RegisterCommand(CommandNames.Polyline, new DrawPolyline()); + commandMachine.RegisterCommand(CommandNames.Scale, new Command_Scale()); + commandMachine.RegisterCommand(CommandNames.Convert2Polyline, new Command_Conver2Polyline()); + + commandMachine.RegisterCommand(CommandNames.Move, new Command_Move()); + + commandMachine.RegisterCommand(CommandNames.FlipZMatrix, new Command_FlipZMatrix()); + commandMachine.RegisterCommand(CommandNames.SetLineOCS, new Command_SetLineOCS()); + + commandMachine.RegisterCommand(CommandNames.Z0, new Command_EntitytMoveToZ0()); + commandMachine.RegisterCommand(CommandNames.M0, new Command_M0()); + commandMachine.RegisterCommand(CommandNames.PackageGroupMove0, new Command_PackageMove()); + commandMachine.RegisterCommand(CommandNames.Rotate, new Command_Rotate()); + commandMachine.RegisterCommand(CommandNames.RotateRefer, new Command_RotateRefer()); + commandMachine.RegisterCommand(CommandNames.Revolve, new Command_DrawRevolve()); + + commandMachine.RegisterCommand(CommandNames.Sphere, new DrawSphere()); + + commandMachine.RegisterCommand(CommandNames.SwitchCamera, new Command_SwitchCamera()); + + commandMachine.RegisterCommand(CommandNames.CameraSnapshootSave, new Command_CameraSnapshootSave()); + //保存和读取相机状态 + for (let i = 1; i <= 9; i++) + { + commandMachine.RegisterCommand(CommandNames.CameraSnapshootSaveIndex + "-" + i, new Command_CameraSnapshootSaveIndex(i)); + commandMachine.RegisterCommand(CommandNames.CameraSnapshootRestore + "-" + i, new Command_CameraSnapshootRestore(i)); + } + + commandMachine.RegisterCommand(CommandNames.Erase, new Command_Erase()); + commandMachine.RegisterCommand(CommandNames.DeleteCurve, new DeleteCurve()); + commandMachine.RegisterCommand(CommandNames.EraseLineArc, new Command_EraseLineAndArc()); + + commandMachine.RegisterCommand("Circle0", new DrawCircle0()); + commandMachine.RegisterCommand(CommandNames.Break, new Command_Break()); + commandMachine.RegisterCommand(CommandNames.CustomNumber, new Command_CustomNumber()); + commandMachine.RegisterCommand(CommandNames.CleanCustomNumber, new Command_CleanCustomNumber()); + commandMachine.RegisterCommand(CommandNames.BreakAll, new Command_BreakAll()); + + if (IsTest()) + commandMachine.RegisterCommand("testPointParse", new Command_TestPointPickParse()); + + commandMachine.RegisterCommand(CommandNames.Stretch, new Stretch()); + commandMachine.RegisterCommand(CommandNames.SelectStretch, new Stretch(true)); + + commandMachine.RegisterCommand(CommandNames.FS, new ViewChange(new Vector3(0, 0, -1))); + commandMachine.RegisterCommand(CommandNames.QS, new ViewChange(new Vector3(0, 1))); + commandMachine.RegisterCommand(CommandNames.YS, new ViewChange(new Vector3(-1))); + commandMachine.RegisterCommand(CommandNames.ZS, new ViewChange(new Vector3(1))); + commandMachine.RegisterCommand(CommandNames.BackView, new ViewChange(new Vector3(0, -1))); + commandMachine.RegisterCommand(CommandNames.Swiso, new ViewChange(new Vector3(1, 1, -1), true)); + commandMachine.RegisterCommand(CommandNames.BottomView, new ViewChange(new Vector3(0, 0, 1))); + commandMachine.RegisterCommand(CommandNames.FixView, new Command_FixView()); + + commandMachine.RegisterCommand("grip", new DrawGripStretch()); + + //暂时关闭这个fbx导入 + // commandMachine.RegisterCommand("fbx", new Fbx()); + + commandMachine.RegisterCommand(CommandNames.HighlightNode, new Command_HighlightNode()); + commandMachine.RegisterCommand(CommandNames.HighlightNodeAndChilds, new Command_HighlightNodeAndChilds()); + + commandMachine.RegisterCommand(CommandNames.HideSelect, new Command_HideSelected()); + commandMachine.RegisterCommand(CommandNames.HideUnSelect, new Command_HideUnselected()); + commandMachine.RegisterCommand(CommandNames.Show, new Command_ShowAll()); + + // commandMachine.RegisterCommand(CommandNames.Save, new Save()); + // commandMachine.RegisterCommand(CommandNames.SaveAs, new SaveAs()); + // commandMachine.RegisterCommand(CommandNames.SaveToLocal, new SaveToLocal()); + // commandMachine.RegisterCommand(CommandNames.SaveToDxf, new SaveToDxf()); + + commandMachine.RegisterCommand(CommandNames.New, new New()); + + commandMachine.RegisterCommand(CommandNames.Open, new Open()); + commandMachine.RegisterCommand(CommandNames.Reopen, new ReOpen()); + commandMachine.RegisterCommand(CommandNames.OpenHistory, new OperLogs(false)); + commandMachine.RegisterCommand(CommandNames.OpenHistory2, new Command_OpenHistory()); + + commandMachine.RegisterCommand(CommandNames.Arc, new DrawArc()); + + commandMachine.RegisterCommand("ent", new Entsel()); + + if (IsTest()) + commandMachine.RegisterCommand("sky", new DrawSky()); + + commandMachine.RegisterCommand(CommandNames.Reg, new DrawRegion()); + + commandMachine.RegisterCommand(CommandNames.CustomUCS, new CustomUcs()); + + commandMachine.RegisterCommand("reg2", new DrawRegTest()); + + commandMachine.RegisterCommand(CommandNames.Copy, new Command_Copy()); + + //超级拷贝 + commandMachine.RegisterCommand(CommandNames.SuperCopy, new Command_SuperCopy()); + + commandMachine.RegisterCommand("Wblock", new Command_Wblock()); + + commandMachine.RegisterCommand("lisp", new Command_Lisp()); + + commandMachine.RegisterCommand(CommandNames.Reverse, new Command_Reverse()); + commandMachine.RegisterCommand(CommandNames.Extend, new Command_Extend()); + + commandMachine.RegisterCommand(CommandNames.Trim, new Command_Trim()); + + commandMachine.RegisterCommand(CommandNames.Fillet, new CommandFillet()); + commandMachine.RegisterCommand("testFilletCode", new TestFillet()); + + commandMachine.RegisterCommand(CommandNames.Offset, new Command_Offset()); + commandMachine.RegisterCommand("OT", new Command_DynOffset()); + commandMachine.RegisterCommand("TO", new Command_DynOffsetToolPath()); + + commandMachine.RegisterCommand(CommandNames.Length, new Command_Length()); + commandMachine.RegisterCommand(CommandNames.Area, new Command_Area()); + + //绘制灯 + commandMachine.RegisterCommand(CommandNames.PointLight, new DrawPointLight()); + commandMachine.RegisterCommand(CommandNames.SpotLight, new DrawSpotLight()); + commandMachine.RegisterCommand(CommandNames.SpotLight2, new DrawSpotLight2()); + commandMachine.RegisterCommand(CommandNames.RectLight, new DrawRectAreaLight()); + commandMachine.RegisterCommand(CommandNames.BatchModifyLights, new BatchModifyLights()); + + commandMachine.RegisterCommand("ptcopy", new Command_CopyPoint()); + + commandMachine.RegisterCommand("tan", new DrawTangentLine()); + + commandMachine.RegisterCommand(CommandNames.Divide, new CMD_Divide()); + commandMachine.RegisterCommand(CommandNames.Point, new CMD_DrawPoint()); + + commandMachine.RegisterCommand(CommandNames.AlignDim, new DrawAlignedDimension()); + commandMachine.RegisterCommand(CommandNames.LinearDim, new DrawLinearDimension()); + commandMachine.RegisterCommand(CommandNames.AngleDim, new Command_Draw2LineAngularDim()); + commandMachine.RegisterCommand(CommandNames.DimContinue, new Command_DimContinue()); + commandMachine.RegisterCommand(CommandNames.RadiusDim, new DrawRadiusDim()); + commandMachine.RegisterCommand(CommandNames.DiaDim, new DrawDiameterDim()); + commandMachine.RegisterCommand(CommandNames.DimArc, new Command_DimArc()); + commandMachine.RegisterCommand(CommandNames.HideDim, new Command_HideDim()); + commandMachine.RegisterCommand(CommandNames.ShowDim, new Command_ShowDim()); + + commandMachine.RegisterCommand(CommandNames.Text, new DrawText()); + commandMachine.RegisterCommand(CommandNames.Intersect, new IntersectionOperation()); + commandMachine.RegisterCommand(CommandNames.Union, new UnionOperation()); + commandMachine.RegisterCommand(CommandNames.Substract, new SubsractOperation()); + commandMachine.RegisterCommand(CommandNames.Pedit, new Pedit()); + commandMachine.RegisterCommand(CommandNames.Join, new Command_Join()); + commandMachine.RegisterCommand(CommandNames.Sweep, new Sweep()); + commandMachine.RegisterCommand(CommandNames.Cylineder, new DrawCylineder()); + + //画板件命令 这一段在ShareView中有依赖,不要移除 + commandMachine.RegisterCommand(CommandNames.LRBoard, new DrawLeftRight()); + commandMachine.RegisterCommand(CommandNames.TBBoard, new DrawTopBottomBoard()); + commandMachine.RegisterCommand(CommandNames.BehindBoard, new DrawBehindBoard()); + commandMachine.RegisterCommand(CommandNames.LayerBoard, new DrawLayerBoard()); + commandMachine.RegisterCommand(CommandNames.VertialBoard, new DrawVerticalBoard()); + commandMachine.RegisterCommand(CommandNames.SingleBoard, new DrawSingleBoard()); + commandMachine.RegisterCommand(CommandNames.CloseStrip, new DrawClosingStrip()); + commandMachine.RegisterCommand(CommandNames.Door, new DrawDoor()); + commandMachine.RegisterCommand(CommandNames.DrillConfig, new DrillConfig()); + commandMachine.RegisterCommand(CommandNames.Hole, new DrawDrilling()); + commandMachine.RegisterCommand(CommandNames.YiXing, new DrawSpecialShapedBoard()); + commandMachine.RegisterCommand(CommandNames.YXLK, new DrawSpecialShapedBoardByContour()); + commandMachine.RegisterCommand(CommandNames.ZXLK, new Command_ApplyModelToBoards()); + commandMachine.RegisterCommand(CommandNames.Model2Contour, new ApplyModel2ToBoard()); + commandMachine.RegisterCommand(CommandNames.LinearCutting, new LinearCutting()); + commandMachine.RegisterCommand(CommandNames.RectLinearCutting, new RectLinearCutting()); + commandMachine.RegisterCommand(CommandNames.NonAssociativeCutting, new NonAssociativeCutting()); + commandMachine.RegisterCommand(CommandNames.ReferenceCutting, new ReferenceCutting()); + commandMachine.RegisterCommand(CommandNames.AddPtOnBoard, new AddPtOnBoard()); + commandMachine.RegisterCommand(CommandNames.DeletePtOnBoard, new DeletePtOnBoard()); + commandMachine.RegisterCommand(CommandNames.BoardFindModify, new BoardFindModify()); + commandMachine.RegisterCommand(CommandNames.LookOverBoardInfos, new LookOverBoardInfos()); + commandMachine.RegisterCommand(CommandNames.BoardBatchCurtail, new BoardBatchCurtail()); + commandMachine.RegisterCommand(CommandNames.BatchModifyPanel, new BatchModifyPanel()); + commandMachine.RegisterCommand(CommandNames.AutoDimBrs, new Command_AutoDimBrs()); + commandMachine.RegisterCommand(CommandNames.BoardInfoDim, new Command_BoardInfoDimTool()); + commandMachine.RegisterCommand(CommandNames.FastDimBrs, new Command_FastDimBrs()); + commandMachine.RegisterCommand(CommandNames.BreakDim, new BreakDim()); + commandMachine.RegisterCommand(CommandNames.DeleteDim, new DeleteDim()); + commandMachine.RegisterCommand(CommandNames.DeleteMinDim, new DeleteMinDim()); + commandMachine.RegisterCommand(CommandNames.DimStyle, new Command_DimStyle()); + + commandMachine.RegisterCommand(CommandNames.RotateLayerBoard, new RotateLayerBoard()); + + commandMachine.RegisterCommand(CommandNames.Drawer, new DrawDrawrer()); + commandMachine.RegisterCommand(CommandNames.DeleteHole, new DeleteDrill()); + commandMachine.RegisterCommand(CommandNames.ReverseDrillFace, new ReverseDrillFace()); + commandMachine.RegisterCommand(CommandNames.FZWL, new Command_FZWL()); + commandMachine.RegisterCommand(CommandNames.EditorboardTemplate, new EditorBoardTemplate()); + + commandMachine.RegisterCommand(CommandNames.ActicityLayerBoard, new ActicityLayerBoard()); + + //改板 + // commandMachine.RegisterCommand(CommandNames.SetBRXAxis, new Command_SetBRXAxis()); + // commandMachine.RegisterCommand(CommandNames.SelectThinBehindBoard, new SelectThinBehindBoard()); + + //修改颜色命令 + // for (let i = 0; i <= 255; i++) commandMachine.RegisterCommand(i.toString(), new ChangeColor(i)); + + // commandMachine.RegisterCommand(CommandNames.TestM, new FeedingCommand()); //模拟走刀 + // commandMachine.RegisterCommand(CommandNames.TestFb, new TestFb()); //模拟封边 + + // commandMachine.RegisterCommand(CommandNames.Mirror, new MirrorCommand()); + // + // commandMachine.RegisterCommand(CommandNames.Topline, new ShowTopLine()); + + //酒格 + // commandMachine.RegisterCommand(CommandNames.Winerack, new ConfigureWineRack()); + // commandMachine.RegisterCommand(CommandNames.Drawwinerack, new DrawWineRack()); + // commandMachine.RegisterCommand(CommandNames.Editorwinerack, new EditorWineRack()); + // + // commandMachine.RegisterCommand(CommandNames.Explode, new Command_Explode()); + // commandMachine.RegisterCommand(CommandNames.Explosion, new Command_ExplosionMap()); + commandMachine.RegisterCommand(CommandNames.OpenCabinet, new Command_OpenCabinet()); + // + // commandMachine.RegisterCommand(CommandNames.Lattice, new DrawLattice()); + /*******test ↓↓↓*********/ + // if (IsTest()) + // { + // commandMachine.RegisterCommand("pltest", new Command_PLTest()); + // commandMachine.RegisterCommand("tt2", new Command_INsTest()); + // commandMachine.RegisterCommand("outcur", new TestTargeOnCurve()); + // commandMachine.RegisterCommand("close", new Command_ClosePt()); + // + // //多段线变碎点多段线 + // commandMachine.RegisterCommand("TestPolyline2PointsPolyline", new Command_TestPolyline2PointsPolyline()); + // commandMachine.RegisterCommand("TestParseEdgeSealDir", new Command_TestParseEdgeSealDir()); + // + // commandMachine.RegisterCommand("oo", new OffsetX()); + // commandMachine.RegisterCommand("testw", new Command_TestTape()); + // //测试csg + // commandMachine.RegisterCommand("TestDrawEdgeGeometry", new Command_TestDrawEdgeGeometry()); + // } + // commandMachine.RegisterCommand(CommandNames.SimplifyPolyline, new Command_SimplifyPolyline()); + // commandMachine.RegisterCommand("RemovePolylineRepeatPos", new Command_RemovePolylineRepeatPos()); + + //用于测试包围盒 + // if (IsTest()) + // { + // commandMachine.RegisterCommand("box", new Command_TestBox()); + // commandMachine.RegisterCommand("TestIntersect", new TestIntersect()); + // commandMachine.RegisterCommand("collison", new TestCollision()); + // } + + //阵列 + commandMachine.RegisterCommand(CommandNames.Array, new Command_Array()); + + commandMachine.RegisterCommand(CommandNames.CopyClip, new CopyClip()); + commandMachine.RegisterCommand(CommandNames.CopyBase, new CopyClip(true)); + commandMachine.RegisterCommand(CommandNames.PasteClip, new PasteClip()); + + //UI命令 + // commandMachine.RegisterCommand(CommandNames.Comanp, new Command_CommandPanel()); + // commandMachine.RegisterCommand(CommandNames.PropertiesBar, new Command_PropertiesBar()); + // commandMachine.RegisterCommand(CommandNames.ModuleBar, new Command_ModuleBar()); + // commandMachine.RegisterCommand(CommandNames.ChangeLayout, new Command_ChangeLayout()); + + // for (const key in RightTabCommandMap) + // { + // commandMachine.RegisterCommand(RightTabCommandMap[key], new Command_RightPanel(key)); + // } + // commandMachine.RegisterCommand(CommandNames.SwitchServers, new Comman_SwitchServers()); + //选项 + commandMachine.RegisterCommand(CommandNames.Config, new Command_Options(EOptionTabId.Show)); + commandMachine.RegisterCommand(CommandNames.DimStyle, new Command_DimStyle()); + commandMachine.RegisterCommand(CommandNames.TextStyle, new Command_Options(EOptionTabId.TextStyle)); + + commandMachine.RegisterCommand("esc", new Command_Esc()); + commandMachine.RegisterCommand(CommandNames.EraseNoSelect, new Command_EraseNoSelect()); + + // commandMachine.RegisterCommand("st", new SaveTarget()) + // commandMachine.RegisterCommand("rt", new RevTarget()) + + //视觉样式 + commandMachine.RegisterCommand(CommandNames.Wireframe, new ChangeRenderType(RenderType.Wireframe)); + commandMachine.RegisterCommand(CommandNames.Conceptual, new ChangeRenderType(RenderType.Conceptual)); + commandMachine.RegisterCommand(CommandNames.ConceptualTransparent, new ChangeRenderType(RenderType.Conceptual, 0.5)); + commandMachine.RegisterCommand(CommandNames.Physical, new ChangeRenderType(RenderType.Physical)); + commandMachine.RegisterCommand(CommandNames.Physical2, new ChangeRenderType(RenderType.Physical2)); + commandMachine.RegisterCommand(CommandNames.PrintType, new ChangeRenderType(RenderType.Print)); + commandMachine.RegisterCommand(CommandNames.CheckEdge, new ChangeRenderType(RenderType.Edge)); + commandMachine.RegisterCommand(CommandNames.CheckPlaceFace, new ChangeRenderType(RenderType.PlaceFace)); + commandMachine.RegisterCommand(CommandNames.BigHoleFace, new ChangeRenderType(RenderType.BigHoleFace)); + commandMachine.RegisterCommand(CommandNames.VisualStyle_CustomNumber, new ChangeRenderType(RenderType.CustomNumber, 0.2)); + commandMachine.RegisterCommand(CommandNames.ModelGroove, new ChangeRenderType(RenderType.ModelGroove, 0.2)); + commandMachine.RegisterCommand(CommandNames.BackgroundSwitching, new BackgroundSwitching()); + commandMachine.RegisterCommand(CommandNames.Renderer, new CMD_Renderer()); + + //导入导出配置 + // commandMachine.RegisterCommand(CommandNames.DownloadConfig, new DownLoadDConfig()); + // commandMachine.RegisterCommand(CommandNames.UploadConfig, new UpLoadConfig()); + // commandMachine.RegisterCommand(CommandNames.DownloadHoleOption, new DownloadHoleOption()); + // commandMachine.RegisterCommand(CommandNames.UploadHoleConfig, new UploadHoleOption()); + + // MES + // commandMachine.RegisterCommand(CommandNames.ChaiDan, new ChaiDan()); + // commandMachine.RegisterCommand(CommandNames.ChaiDanJB, new ChaiDanJB()); + // commandMachine.RegisterCommand(CommandNames.ShowYouhua, new ShoWYouHua()); + // commandMachine.RegisterCommand(CommandNames.Decompose, new Decompose()); + // commandMachine.RegisterCommand(CommandNames.ChaiDanExport, new ChaiDanExport()); + + // shareview + // commandMachine.RegisterCommand(CommandNames.ShareView, new Command_ShareView()); + + //批量修改封边排钻 + // commandMachine.RegisterCommand(CommandNames.BatchModify, new BatchModify()); + // commandMachine.RegisterCommand(CommandNames.EditDrilEdgeData, new Command_EditBoardDrilEdgeData()); + // commandMachine.RegisterCommand(CommandNames.EditSealEdgeData, new Command_EditBoardSealEdgeData()); + + //自动设置孔面 + commandMachine.RegisterCommand(CommandNames.AutoHoleFaceSetting, new AutoHoleFaceSetting()); + + //绘制复合实体 + commandMachine.RegisterCommand(CommandNames.Combine, new Command_CombineEntity()); + + //Template + // commandMachine.RegisterCommand(CommandNames.Template, new ShowTemplate("Administration")); + // commandMachine.RegisterCommand(CommandNames.TemplateCollection, new ShowTemplate("Collection")); + // commandMachine.RegisterCommand(CommandNames.TemplateDesign, new ShowTemplateDesign()); + // commandMachine.RegisterCommand(CommandNames.Modeling, new Command_Modeling()); + // commandMachine.RegisterCommand(CommandNames.templateDelete, new Command_DeleteTemplate()); + // commandMachine.RegisterCommand(CommandNames.TemplateCheck, new Command_TemplateSearch(true)); + // commandMachine.RegisterCommand(CommandNames.TemplateGroup, new Command_TemplateGroup()); + // commandMachine.RegisterCommand(CommandNames.SpliteTemplate, new Command_SplitTemplate()); + // commandMachine.RegisterCommand("SplitTemplateX", new Command_SplitTemplateByDir(0)); + // commandMachine.RegisterCommand(CommandNames.SplitTemplateY, new Command_SplitTemplateByDir(1)); + // commandMachine.RegisterCommand("SplitTemplateZ", new Command_SplitTemplateByDir(2)); + // commandMachine.RegisterCommand(CommandNames.RotateTemplateSpace, new Command_RotateTemplateSpace()); + // commandMachine.RegisterCommand(CommandNames.RenderModulesState, new Command_RenderModulesState()); + + //优化算法 + // if (IsTest()) + // { + // commandMachine.RegisterCommand("DebugTemplateAssocCount", new Command_DebugTemplateAssocCount()); + // + // commandMachine.RegisterCommand("testlir", new Command_TestLIR()); + // + // + // commandMachine.RegisterCommand("testNFP", new Command_TestNFP()); + // commandMachine.RegisterCommand("testSimply", new Command_TestSimply()); + // commandMachine.RegisterCommand("testSimply2", new Command_TestPolylin2Points()); + // commandMachine.RegisterCommand("testPlace", new Command_TestPlace()); + // commandMachine.RegisterCommand("testYH", new Command_TestYHWorker()); + // commandMachine.RegisterCommand("testYH2", new Command_TestYH2()); + // commandMachine.RegisterCommand("testYHSingle", new Command_TestYHSingle()); + // commandMachine.RegisterCommand("testYHDraw", new Command_TestDrawYHData()); + // commandMachine.RegisterCommand("testYHDraw2", new Command_TestDrawYHData2()); + // commandMachine.RegisterCommand("testYHSave", new Command_TestSaveYHData()); + // commandMachine.RegisterCommand("testSum", new Command_TestSum()); + // commandMachine.RegisterCommand("TestSimplyOddments", new Command_TestSimplyOddments()); + // commandMachine.RegisterCommand("TestParseOddments", new Command_TestParseOddments()); //分析余料 + // commandMachine.RegisterCommand("TestContainer", new Command_TestContainer()); //绘制Container + // } + + commandMachine.RegisterCommand(CommandNames.EditorLattice, new EditorLattice()); + + // commandMachine.RegisterCommand(CommandNames.Print, new Print()); + commandMachine.RegisterCommand(CommandNames.Extrude, new DrawExtrude()); + + commandMachine.RegisterCommand(CommandNames.HoleTemplate, new ShowDrillingTemplate()); + commandMachine.RegisterCommand(CommandNames.CheckModeling, new CheckModeling()); + + //导出数据 + // commandMachine.RegisterCommand(CommandNames.ExportData, new Command_ExportData()); + // commandMachine.RegisterCommand(CommandNames.ExportView, new Command_ExportView()); + + // commandMachine.RegisterCommand(CommandNames.EnableSyncData, new Command_EnableSyncData()); + // commandMachine.RegisterCommand(CommandNames.DisableSyncData, new Command_DisableSyncData()); + // commandMachine.RegisterCommand(CommandNames.ToggleSyncData, new Command_ToggleSyncData()); + // commandMachine.RegisterCommand(CommandNames.ToggleViewFollow, new Command_ToggleViewFollow()); + + //加工组 + commandMachine.RegisterCommand(CommandNames.ShowProcessingGroupModal, new Command_ShowProcessingGroupModal()); + //对纹组 + // if (IsTest()) + // commandMachine.RegisterCommand(CommandNames.AlignLineGroup, new Command_AlignLineGroup()); + + commandMachine.RegisterCommand(CommandNames.Text2Curve, new Text2Curve()); + + commandMachine.RegisterCommand(CommandNames.DrawVSBOX, new DrawVisualSpaceBox()); + commandMachine.RegisterCommand(CommandNames.Align, new Align()); + + // commandMachine.RegisterCommand(CommandNames.BuyMaterial, new BuyMaterial()); + commandMachine.RegisterCommand(CommandNames.Interfere, new Interfere()); + + // commandMachine.RegisterCommand(CommandNames.Knife, new ShowKinfeManageModal()); + commandMachine.RegisterCommand(CommandNames.PickUp2DModelCsgs, new Command_PickUp2DModelCsgs()); + + // commandMachine.RegisterCommand(CommandNames.ModifyGroovesKnife, new Command_GroovesModify()); + commandMachine.RegisterCommand(CommandNames.ShowDoor, new Command_SwitchDoorOrDrawer(true, true)); + commandMachine.RegisterCommand(CommandNames.HideDoor, new Command_SwitchDoorOrDrawer(false, true)); + commandMachine.RegisterCommand(CommandNames.ShowDrawer, new Command_SwitchDoorOrDrawer(true, false)); + commandMachine.RegisterCommand(CommandNames.HideDrawer, new Command_SwitchDoorOrDrawer(false, false)); + + commandMachine.RegisterCommand(CommandNames.Show2DPathLine, new Command_Show2DPathLine(true)); + commandMachine.RegisterCommand(CommandNames.Hide2DPathLine, new Command_Show2DPathLine(false)); + + commandMachine.RegisterCommand(CommandNames.Show2DPathObject, new Command_Show2DPathObject(true)); + commandMachine.RegisterCommand(CommandNames.Hide2DPathObject, new Command_Show2DPathObject(false)); + + //线条变矩形 + commandMachine.RegisterCommand(CommandNames.Curve2Rect, new Command_Curve2Polyline()); + commandMachine.RegisterCommand(CommandNames.R2b, new Polyline2Board()); + commandMachine.RegisterCommand(CommandNames.Curve2VSBox, new Command_Curve2VSBox()); + + commandMachine.RegisterCommand(CommandNames.SetSmoothEdge, new SetSmoothEdge()); + commandMachine.RegisterCommand(CommandNames.ClearRef, new DeleteRelevance()); + commandMachine.RegisterCommand(CommandNames.Clear2DModeling, new Command_ClearBoard2DModeling()); + commandMachine.RegisterCommand(CommandNames.ExportobjMtl, new Command_ExportObjAndMtl()); + commandMachine.RegisterCommand(CommandNames.ExportObj, new Command_ExportObj()); + commandMachine.RegisterCommand(CommandNames.ExportSTL, new Command_ExportSTL()); + + commandMachine.RegisterCommand(CommandNames.UpdateBoardInfos, new UpdateBoardInfos()); + + commandMachine.RegisterCommand(CommandNames.ToggleUI, new Command_ToggleUI()); + + commandMachine.RegisterCommand(CommandNames.BoardReplaceTempate, new BoardReplaceTempate()); + + commandMachine.RegisterCommand(CommandNames.ResetCustomCommand, new Command_ResetCustomCommand()); + + commandMachine.RegisterCommand(CommandNames.Dist, new Command_Dist()); + + // commandMachine.RegisterCommand(CommandNames.RecyleBin, new ShowRecycleBin()); + + commandMachine.RegisterCommand(CommandNames.ChangeColorByMaterial, new ChangeColorByMaterial()); + commandMachine.RegisterCommand(CommandNames.ChangeColorByRoomOrCabinet, new ChangeColorByRoomCabinet()); + commandMachine.RegisterCommand(CommandNames.ChangeBoardColorByPBFace, new Command_ChangeBoardColorByPBFace()); + commandMachine.RegisterCommand(CommandNames.TextModifyTool, new Command_TextModifyTool()); + + commandMachine.RegisterCommand(CommandNames.SelectAll, new SelectAll()); + + commandMachine.RegisterCommand(CommandNames.CheckHoles, new CheckHoles()); + commandMachine.RegisterCommand(CommandNames.CombinatAttributeBrush, new CombinatAttributeBrush()); + commandMachine.RegisterCommand(CommandNames.MatchProp, new Command_MatchProp()); + + + commandMachine.RegisterCommand(CommandNames.Rect2Winerack, new Polyline2Winerack()); + + commandMachine.RegisterCommand(CommandNames.EditFrame, new EditFrame()); + commandMachine.RegisterCommand(CommandNames.EditView, new EditViewport()); + commandMachine.RegisterCommand(CommandNames.MView, new DrawViewport()); + commandMachine.RegisterCommand(CommandNames.MView4, new Draw4Viewport()); + commandMachine.RegisterCommand(CommandNames.ShowFrame, new ShowFrmae()); + commandMachine.RegisterCommand(CommandNames.OneKeyLayout, new OneKeyLayout()); + + commandMachine.RegisterCommand(CommandNames.SwitchLines, new SwitchLines()); + commandMachine.RegisterCommand(CommandNames.SwitchOpenDirLines, new ShowOpenDirLiens()); + commandMachine.RegisterCommand(CommandNames.MView2, new Draw2Viewport()); + commandMachine.RegisterCommand(CommandNames.MView3, new Draw3Viewport()); + commandMachine.RegisterCommand(CommandNames.OneKeyPrint, new OneKeyPrint()); + + commandMachine.RegisterCommand(CommandNames.SetHoleNoneType, new SetHoleNoneType()); + commandMachine.RegisterCommand(CommandNames.FindMaxSizeBoard, new FindMaxOrMinSizeBoard()); + commandMachine.RegisterCommand(CommandNames.FindMinSizeBoard, new FindMaxOrMinSizeBoard(false)); + commandMachine.RegisterCommand(CommandNames.FindBoardModelingKnife, new Command_FindBoardModelingKnife()); + commandMachine.RegisterCommand(CommandNames.CheckNoHoleBoard, new CheckHasHoleBoard()); + commandMachine.RegisterCommand(CommandNames.CheckDrawHole, new CheckDrawHole()); + commandMachine.RegisterCommand(CommandNames.FindModelKnifeRadius, new FindModeingKnifeRadius()); + // commandMachine.RegisterCommand(CommandNames.EditorBBS, new ShowEditorBBS()); + commandMachine.RegisterCommand(CommandNames.ToggleDrillingReactor, new ToggleDrillingReactor()); + commandMachine.RegisterCommand(CommandNames.OneClickInspection, new OneClickInspection()); + + commandMachine.RegisterCommand(CommandNames.AddAloneDrillLock, new AddAloneDrillLock(true)); + commandMachine.RegisterCommand(CommandNames.RemoveAloneDrillLock, new AddAloneDrillLock(false)); + commandMachine.RegisterCommand(CommandNames.AddAssocDrillLock, new AddAssocDrillLock()); + commandMachine.RegisterCommand(CommandNames.RemoveAssocDrillLock, new RemoveAssocDrillLock()); + commandMachine.RegisterCommand(CommandNames.RemoveDrillLock, new RemoveDrillLock()); + + commandMachine.RegisterCommand(CommandNames.CuttingFace, new CuttingByFace()); + commandMachine.RegisterCommand(CommandNames.CuttingRectFace, new CuttingByRectFace()); + + commandMachine.RegisterCommand(CommandNames.DrawTempByImport, new DrawTemplateByImport()); + + commandMachine.RegisterCommand(CommandNames.R2B2, new Rect2Board()); + + commandMachine.RegisterCommand(CommandNames.FixIntSelfContour, new FixIntersectSelfContour()); + commandMachine.RegisterCommand("fix2dpath", new Command_Fix2DPath()); + + commandMachine.RegisterCommand(CommandNames.ParseHinge, new ParseHinge()); + commandMachine.RegisterCommand(CommandNames.ParseHandle, new ParseHandle()); + commandMachine.RegisterCommand(CommandNames.ZhengWen, new SetBoardLines(0)); + commandMachine.RegisterCommand(CommandNames.FanWen, new SetBoardLines(1)); + commandMachine.RegisterCommand(CommandNames.KeFanZuan, new SetBoardLines(2)); + commandMachine.RegisterCommand(CommandNames.ZhengMian, new SetComposingFace(0)); + commandMachine.RegisterCommand(CommandNames.FanMian, new SetComposingFace(1)); + commandMachine.RegisterCommand(CommandNames.SuiYiMian, new SetComposingFace(2)); + + commandMachine.RegisterCommand(CommandNames.ShowHSPanel, new ShowHideSelectPanel()); + commandMachine.RegisterCommand(CommandNames.ParseBoardName, new Command_ParseBoardName()); + + commandMachine.RegisterCommand(CommandNames.Down, new Command_Cmd_Down()); + //Gizmo + commandMachine.RegisterCommand(CommandNames.AxesDisable, new Command_SetGizmoMode(TransMode.OCS)); + commandMachine.RegisterCommand(CommandNames.AxesTranslate, new Command_SetGizmoMode(TransMode.Move)); + commandMachine.RegisterCommand(CommandNames.AxesRotate, new Command_SetGizmoMode(TransMode.Rotate)); + commandMachine.RegisterCommand(CommandNames.AxesScale, new Command_SetGizmoMode(TransMode.Scale)); + commandMachine.RegisterCommand(CommandNames.GizmoCSSwith, new Command_GizmoCSSwith()); + + //Room + // commandMachine.RegisterCommand(CommandNames.DrawWall, new Command_DrawWall()); + // commandMachine.RegisterCommand(CommandNames.DrawWallInside, new Command_DrawWallInside()); + // commandMachine.RegisterCommand(CommandNames.Curve2Wall, new Command_Curve2Wall()); + // commandMachine.RegisterCommand(CommandNames.SetWallThick, new Command_SetWallThick()); + // commandMachine.RegisterCommand(CommandNames.DrawRectWall, new Command_DrawRectWall()); + // + // commandMachine.RegisterCommand(CommandNames.DrawIHole, new Command_DrawHole(DrawHoleType.I, IHoleType.Window)); + // commandMachine.RegisterCommand(CommandNames.DrawDoorHole, new Command_DrawHole(DrawHoleType.I, IHoleType.Door)); + // commandMachine.RegisterCommand(CommandNames.DrawLHole, new Command_DrawHole(DrawHoleType.L)); + // commandMachine.RegisterCommand(CommandNames.DrawUHole, new Command_DrawHole(DrawHoleType.U)); + + // commandMachine.RegisterCommand(CommandNames.DrawIWindow, new Command_DrawRoomWindow(DrawHoleType.I, IHoleType.Window)); + // commandMachine.RegisterCommand(CommandNames.DrawLWindow, new Command_DrawRoomWindow(DrawHoleType.L, IHoleType.Window)); + // commandMachine.RegisterCommand(CommandNames.DrawUWindow, new Command_DrawRoomWindow(DrawHoleType.U, IHoleType.Window)); + // commandMachine.RegisterCommand(CommandNames.DrawIDoor, new Command_DrawRoomDoor()); //门 + + // commandMachine.RegisterCommand(CommandNames.YZC, new Command_OneKeyDrawYZCWindow(DrawHoleType.I, IHoleType.Window, true)); //一字窗 + // commandMachine.RegisterCommand(CommandNames.LDC, new Command_OneKeyDrawLDCWindow(DrawHoleType.I, IHoleType.Window, true)); //落地窗 + // commandMachine.RegisterCommand(CommandNames.PC, new Command_OneKeyDrawPCWindow(DrawHoleType.I, IHoleType.Window, true)); //飘窗 + // commandMachine.RegisterCommand(CommandNames.ZJC, new Command_OneKeyDrawZJCWindow(DrawHoleType.L, IHoleType.Window, true)); //转角窗 + // commandMachine.RegisterCommand(CommandNames.ZJPC, new Command_OneKeyDrawZJPCWindow(DrawHoleType.L, IHoleType.Window, true)); //转角飘窗 + // + // commandMachine.RegisterCommand(CommandNames.YJHM, new Command_OneKeyDrawYJHMWindow(true)); //一键画门 + + commandMachine.RegisterCommand(CommandNames.HeadCeilingContour, new Command_HeadCeilingContourManage()); //吊顶轮廓材质面板 + commandMachine.RegisterCommand(CommandNames.HeadCeilingMaterialPanel, new Command_HeadCeilingMaterialPanel()); //吊顶轮廓材质面板 + commandMachine.RegisterCommand(CommandNames.HeadCeilingInfoConfigPanel, new Command_HeadCeilingInfoConfigPanel()); //吊顶轮廓材质面板 + + //SelectEntity + // commandMachine.RegisterCommand(CommandNames.SelectBoard, new Command_SelectEntity(Board, "请选择板:")); + // commandMachine.RegisterCommand(CommandNames.SelectCurve, new Command_SelectEntity(Curve, "请选择曲线:")); + // commandMachine.RegisterCommand(CommandNames.SelectDim, new Command_SelectEntity(Dimension, "请选择尺寸:")); + // commandMachine.RegisterCommand(CommandNames.SelectText, new Command_SelectEntity(DbText, "请选择文字:")); + + if (IsTest()) + commandMachine.RegisterCommand("ParseWall", new Command_ParseRoomWall()); + //画廊命令 + // commandMachine.RegisterCommand(CommandNames.Gallery, new Command_Gallery()); + + //在线售后 + // commandMachine.RegisterCommand(CommandNames.SendCADFileToKF, new Command_SendCADFileOnKf()); + + //修改注册位置 + commandMachine.RegisterCommand(CommandNames.Attach, new TemplateAttach()); + commandMachine.RegisterCommand(CommandNames.Attach2, new TemplateAttach2()); + commandMachine.RegisterCommand(CommandNames.TemplateArray, new TemplateArray()); +} + +export async function LimitCommand() +{ + if (userConfig.showShareModule) + commandMachine.RegisterCommand(CommandNames.TemplateSearch, new Command_TemplateSearch()); +} diff --git a/src/Add-on/ShareView/ShareViewEntry.tsx b/src/Add-on/ShareView/ShareViewEntry.tsx index 6a95b2318..a9dc4756e 100644 --- a/src/Add-on/ShareView/ShareViewEntry.tsx +++ b/src/Add-on/ShareView/ShareViewEntry.tsx @@ -278,7 +278,7 @@ async function LoadData(): Promise<{ cadFile: CADFiler; urlSearch: URLSearchPara const data = JSON.parse(await res.text()); if (data.err_code === RequestStatus.Ok) { - // userConfig.uese = data.fileInfo.uese; + userConfig.uese = data.fileInfo.uese; const file = JSON.parse(inflateBase64(data.fileInfo.file)); document.title = data.fileInfo.name; if (data.fileInfo.props && Object.prototype.toString.call(data.fileInfo.props) === '[object Object]') diff --git a/src/Add-on/ShareView/ShareViewLayout.tsx b/src/Add-on/ShareView/ShareViewLayout.tsx index efae4c8fe..1564331eb 100644 --- a/src/Add-on/ShareView/ShareViewLayout.tsx +++ b/src/Add-on/ShareView/ShareViewLayout.tsx @@ -10,13 +10,13 @@ import { isHasTouch } from '../../Common/Utils'; import { ZINDEX } from '../../Common/ZIndex'; import { Entity } from '../../DatabaseServices/Entity/Entity'; import { commandMachine } from '../../Editor/CommandMachine'; -import { registerCommand } from '../../Editor/CommandRegister'; import { MouseUI } from '../../Editor/TouchEditor/MouseUIComp'; import { VirtualKeys } from '../../Editor/TouchEditor/VirtualKeysComp'; import { CameraControlBtn } from '../../UI/Components/CameraControlButton/CameraControlBtn'; import { ShowLinesToaster, __AppToasterShowEntityMsg } from '../../UI/Components/Toaster'; -import ShareViewUI from './components/ShareViewUI'; +import { registerCommand } from './ShareViewCommandRegister'; import { ShareViewService } from './ShareViewService'; +import ShareViewUI from './components/ShareViewUI'; // export let appUi: ShareViewLayout; diff --git a/src/Add-on/ShareView/ShareViewRules.ts b/src/Add-on/ShareView/ShareViewRules.ts index 42e6b8a4b..8ccd09453 100644 --- a/src/Add-on/ShareView/ShareViewRules.ts +++ b/src/Add-on/ShareView/ShareViewRules.ts @@ -42,6 +42,29 @@ export const ViewAngleTypes = [ ]; //仅在分享图纸shareView使用 + +export function getViewStyleTypes(mode: string) +{ + if (mode == "HouseRoaming") + { + return [ + { + title: "概念", + renderType: RenderType.Conceptual, + }, + { + title: "真实", + renderType: RenderType.Physical, + }, + { + title: "真实带线框", + renderType: RenderType.Physical2, + }, + ]; + } + return ViewStyleTypes; +} + export const ViewStyleTypes = [ { title: "二维线框", diff --git a/src/Add-on/ShareView/ShareViewService.ts b/src/Add-on/ShareView/ShareViewService.ts index ded63c51f..a05038c07 100644 --- a/src/Add-on/ShareView/ShareViewService.ts +++ b/src/Add-on/ShareView/ShareViewService.ts @@ -4,6 +4,7 @@ import { begin, end } from "xaop"; import { ApplicationService, app } from "../../ApplicationServices/Application"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { EBoardKeyList } from "../../Common/BoardKeyList"; +import { MouseKey } from "../../Common/KeyEnum"; import { DuplicateRecordCloning } from "../../Common/Status"; import { Hole } from "../../DatabaseServices/3DSolid/Hole"; import { BoardLinesReactor } from "../../DatabaseServices/BoardLinesReactor"; @@ -11,6 +12,7 @@ import { CADFiler } from "../../DatabaseServices/CADFiler"; import { Database } from "../../DatabaseServices/Database"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Entity } from "../../DatabaseServices/Entity/Entity"; +import { EntityRef } from "../../DatabaseServices/Entity/EntityRef"; import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity"; import { HardwareTopline } from "../../DatabaseServices/Hardware/HardwareTopline"; import { IdMaping } from "../../DatabaseServices/IdMaping"; @@ -21,6 +23,7 @@ import { WblockCloneFiler2 } from "../../DatabaseServices/WblockCloneFiler"; import { AutoSaveServer } from "../../Editor/AutoSave"; import { BoardMoveTool } from "../../Editor/BoardMoveTool"; import { CameraControls } from "../../Editor/CameraControls"; +import { CommandState } from "../../Editor/CommandState"; import { ContextMenuServices } from "../../Editor/ContextMenu"; import { DbClickManager } from "../../Editor/DbClick/DbClick"; import { Editor } from "../../Editor/Editor"; @@ -44,8 +47,10 @@ import { DownPanelStore } from "../../UI/Store/DownPanelStore"; import { HardwareCuttingReactor } from "../BoardCutting/HardwareCuttingReactor"; import { DrillingReactor } from "../DrawDrilling/DrillingReactor"; import { Purge } from "../Purge"; -import { ShareViewStore } from "./ShareViewStore"; +import { ShareViewCameraControl } from "./ShareViewCameraControl"; +import { RoamingSwitches, ShareViewStore } from "./ShareViewStore"; import { MaterialDetailScrollTo } from "./ShareViewUtil"; +import { ShareViewViewer } from "./ShareViewViewer"; import { SimpleBoard } from "./SimpleBoard"; import { SetSelectedBoardChange } from "./StoreEvent"; export let shareViewApp: ShareViewService; @@ -55,6 +60,9 @@ export class ShareViewService extends ApplicationService // WebSocket: WebSocketClientServer = null; BoxCtrl: ShareService; + override Viewer: Viewer; + override CameraControls: CameraControls; + constructor() { super(); @@ -101,6 +109,14 @@ export class ShareViewService extends ApplicationService ShareViewStore.GetInstance().SelectedBoard = null; } }); + + // 假装执行命令以屏蔽右键菜单,可能会有副作用 + document.addEventListener('pointerdown', e => + { + if (e.button === MouseKey.Right || e.pointerType === 'touch') // 右键,或是按住触屏时 + CommandState.CommandIng = true; + }); + SetSelectedBoardChange(null, () => { originUpdateSelectEvent.call(this.Editor.SelectCtrl); // 单选显示标注 @@ -132,7 +148,7 @@ export class ShareViewService extends ApplicationService let container = document.getElementById("Webgl"); //渲染器 - this.Viewer = new Viewer(container); + this.Viewer = new ShareViewViewer(container); this.Viewer.RenderDatabase(this.Database); @@ -177,9 +193,11 @@ export class ShareViewService extends ApplicationService }); //性能测试 - // new RenderPerformanceStatus(this.Viewer); + // const rps = new RenderPerformanceStatus(this.Viewer); + // rps.m_Stats.dom.style.top = '8vh'; + //相机控制 - this.CameraControls = new CameraControls(this.Viewer); + this.CameraControls = new ShareViewCameraControl(this.Viewer); this.Editor = new Editor(this); this.Gesture = new Gesture(this.Editor); @@ -273,12 +291,12 @@ export class ShareViewService extends ApplicationService this.MoveTool = new BoardMoveTool(); this.LayoutTool = new LayoutTool(); - new CameraUpdateForIos(this.Viewer.CameraControl); + new CameraUpdateForIos(this.Viewer.CameraControl); //-> 会导致摄像机位置受限 } override CreateDocument(name?: string): void { } - override SendCameraPosToRenderer: () => void; + override SendCameraPosToRenderer() { } // 新增方法 async LoadFile(f: CADFiler) @@ -384,6 +402,107 @@ export class ShareViewService extends ApplicationService } } } + + // private materialEnvMap: Record; + /** + * 重置页面 + */ + ResetViewState: () => Promise; + CheckHouseRoamingSwitches(switches: RoamingSwitches) + { + const shareViewStore = ShareViewStore.GetInstance(); + return (shareViewStore.HouseRoamingSwitches & switches) > 0; + } + + ApplyHouseRoamingSwitches(changeSwitches?: RoamingSwitches, needUpdate: boolean = false) + { + + const shareViewStore = ShareViewStore.GetInstance(); + + if (changeSwitches) + { + shareViewStore.HouseRoamingSwitches ^= changeSwitches; + } + + // 初始化 + // if (!this.materialEnvMap) + // { + // this.materialEnvMap = {}; + // for (const [key, value] of this.Database.MaterialTable.Materials) + // { + // this.materialEnvMap[key] = value.Material.envMap; + // } + // } + + // 切换柜体显示 + if (this.CheckHouseRoamingSwitches(RoamingSwitches.Decoration)) + { + for (let e of this.Database.ModelSpace.Entitys) + { + if (e instanceof EntityRef) + { + e.Visible = true; + } + } + } else + { + for (let e of this.Database.ModelSpace.Entitys) + { + if (e instanceof EntityRef) + { + e.Visible = false; + } + } + } + + // for (const [key, value] of this.Database.MaterialTable.Materials) + // { + // if (value.type === "金属" && value.Material.metalness > 0.9) + // { + // value.type = "玻璃"; + // // value.color = "#ffffff"; + // value.Update(); + // // value.Material.color = new Color(255, 255, 255); + // } + // // 使用ue材质的 + // if (value.ref?.length > 0) + // { + // if (value.ref.indexOf('/玻璃/') == 0 && value.type != "玻璃") + // { + // value.type = "玻璃"; + // value.Update(); + // } + // // console.log('material-ref', value); + // } + // } + if (this.CheckHouseRoamingSwitches(RoamingSwitches.EnvMap)) + { + this.Database.AmbientLight.Intensity = 0.7; + this.Database.HemisphereLight.Intensity = 0.7; + for (const [key, value] of this.Database.MaterialTable.Materials) + { + // value.Material.envMap = this.materialEnvMap[key]; + value.Material.envMapIntensity = 1; + } + } else + { + // intensity 0 1.7 1.7 + this.Database.AmbientLight.Intensity = 1.5; + this.Database.HemisphereLight.Intensity = 1.5; + + for (const [key, value] of this.Database.MaterialTable.Materials) + { + // 禁用环境贴图 + // value.Material.envMap = null; + value.Material.envMapIntensity = 0.4; + } + } + + if (needUpdate) + { + this.Editor.UpdateScreen(); + } + } } class IgnoreAutoSave extends AutoSaveServer { diff --git a/src/Add-on/ShareView/ShareViewStore.ts b/src/Add-on/ShareView/ShareViewStore.ts index 02e6087c7..49aa50d24 100644 --- a/src/Add-on/ShareView/ShareViewStore.ts +++ b/src/Add-on/ShareView/ShareViewStore.ts @@ -4,6 +4,8 @@ import { Singleton } from "../../Common/Singleton"; import { safeEval } from "../../Common/eval"; import { Board } from "../../DatabaseServices/Entity/Board"; import { DefaultShareBoardInfConfigurationOption } from "../../Editor/DefaultConfig"; +import { CameraType } from "../../GraphicsSystem/CameraUpdate"; +import { RenderType } from "../../GraphicsSystem/RenderType"; import { IConfigOption } from "../../UI/Components/Board/UserConfigComponent"; import { IConfigStore } from '../../UI/Store/BoardStore'; import { ShareBoardInfConfigurationOption } from "../../UI/Store/OptionInterface/IOptionInterface"; @@ -14,6 +16,7 @@ interface IProps showBom?: boolean | null; } + interface IOperations { showDoor: boolean; @@ -25,6 +28,21 @@ interface IOperations showCylinderHole: boolean; } +/** + * 漫游功能开关,二进制 + */ +export enum RoamingSwitches +{ + + Default = 0, + /** + * 摆件显示 + */ + Decoration = 1 << 0, + // 环境贴图 + EnvMap = 2 << 1, +} + export class ShareViewStore extends Singleton implements IConfigStore { //当前选中柜子的索引列表 @@ -36,14 +54,35 @@ export class ShareViewStore extends Singleton implements IConfigStore @observable ViewIDErrorMsg: string = ''; + /** 相机类型 */ + @observable CameraType: CameraType = CameraType.OrthographicCamera; + // 主题 画布颜色 @observable Theme: 'light' | 'dark' | string = 'light'; // 纪录上一次 @observable ThemeLog: 'light' | 'dark' | string = ''; + /** 是否处于户型漫游模式 */ + @observable HouseRoamingMode: boolean = false; + /** + * 漫游功能开关 + */ + @observable HouseRoamingSwitches: RoamingSwitches = RoamingSwitches.Default; + /** + * 漫游模式渲染模式 + */ + @observable HouseRoamingRenderType: RenderType = RenderType.Physical2; + + /** 用户调整的横屏视野 */ + @observable userFovLandscape: number = 90; + + /** 用户调整的竖屏视野 */ + @observable userFovPortrait: number = 60; + // 后台配置数据 @observable Props: IProps = {}; + @observable m_Option: ShareBoardInfConfigurationOption = DefaultShareBoardInfConfigurationOption; @observable viewUploadProps: ShareBoardInfConfigurationOption = DefaultShareBoardInfConfigurationOption; diff --git a/src/Add-on/ShareView/ShareViewStyle.less b/src/Add-on/ShareView/ShareViewStyle.less index 9ba6c2897..22a573a7d 100644 --- a/src/Add-on/ShareView/ShareViewStyle.less +++ b/src/Add-on/ShareView/ShareViewStyle.less @@ -76,6 +76,10 @@ canvas { // bottom: calc(50px + constant(safe-area-inset-bottom)); // bottom: calc(50px + env(safe-area-inset-bottom)); top: 4px; + display: flex; + flex-direction: column; + max-height: 80vh; + flex-wrap: wrap-reverse; >div, .sp-view-angle-icon, @@ -102,12 +106,12 @@ canvas { .sp-qrcode-icon, .sp-view-angle-icon { - margin-top: 8px; + margin: 4px; } .sp-board-hide-icon { color: #1890ff; - margin-top: 12px; + margin: 4px; } } @@ -617,6 +621,115 @@ canvas { } } +// 防止长按复制 +body { + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.sp-mobile-control { + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + pointer-events: none; // 仅作父级,防止遮挡 + + // nipple js 用 + // 摇杆判定区 + .sp-mobile-control-joystick { + position: absolute; + display: flex; + + // 区分横竖屏 + @media (orientation: landscape) { + width: 50%; + height: 100%; + left: 0; + top: 0; + } + + @media (orientation: portrait) { + width: 100%; + height: 35vh; + left: 0; + bottom: calc(44px + env(safe-area-inset-bottom)); // 防止遮挡底部按钮 + } + } + + // 移动端方向键 + .sp-mobile-control-joystick-simple { + position: absolute; + width: 140px; + height: 140px; + + background-color: rgba(0, 0, 0, 0.2); + border-radius: 50%; + left: 6%; + bottom: 5vh; + + pointer-events: fill; + + .sp-m-joystick { + position: absolute; + height: 55px; + width: 55px; + cursor: pointer; + } + + .sp-m-joystick-left { + .sp-m-joystick(); + transform: translate(0, -50%); + left: 0; + top: 50%; + } + + .sp-m-joystick-right { + .sp-m-joystick(); + transform: translate(0, -50%); + right: 0; + top: 50%; + } + + .sp-m-joystick-forward { + .sp-m-joystick(); + transform: translate(-50%, 0); + left: 50%; + top: 0; + } + + .sp-m-joystick-back { + .sp-m-joystick(); + transform: translate(-50%, 0); + left: 50%; + bottom: 0; + } + } + + // 镜头升降按钮 + .sp-mobile-control-btns { + position: absolute; + right: 12%; + bottom: 10vh; + display: flex; + background-color: rgba(0, 0, 0, 0.2); + border-radius: 16px; + + button { + padding: 0; + margin: 5px; + border: none; + background: transparent; + width: 50px; + height: 50px; + pointer-events: auto; + } + } +} + @media screen and (min-width: 768px) { .sp-select-ul li:hover, diff --git a/src/Add-on/ShareView/ShareViewUtil.ts b/src/Add-on/ShareView/ShareViewUtil.ts index 34d861099..9faa8f54e 100644 --- a/src/Add-on/ShareView/ShareViewUtil.ts +++ b/src/Add-on/ShareView/ShareViewUtil.ts @@ -461,6 +461,10 @@ export function GetBlockNo(index) { return shareViewApp.BoxCtrl.BlockNoDict[index]?.blockNo ?? ''; } +export function GetCustomBlockNo(idx) +{ + return shareViewApp +} //获取板颜色 export function GetBlockColor(item) { diff --git a/src/Add-on/ShareView/ShareViewViewer.ts b/src/Add-on/ShareView/ShareViewViewer.ts new file mode 100644 index 000000000..21ae9577b --- /dev/null +++ b/src/Add-on/ShareView/ShareViewViewer.ts @@ -0,0 +1,65 @@ +import hotkeys from "hotkeys-js-ext"; +import { CalcSunShadowCameraExtents } from "../../Common/LightUtils"; +import { Database } from "../../DatabaseServices/Database"; +import { RoomFlatBase } from "../../DatabaseServices/Room/Entity/Flat/RoomFlatBase"; +import { RoomHoleBase } from "../../DatabaseServices/Room/Entity/Wall/Hole/RoomHoleBase"; +import { RoomWallBase } from "../../DatabaseServices/Room/Entity/Wall/RoomWallBase"; +import { IsPhysical, RenderType } from "../../GraphicsSystem/RenderType"; +import { Viewer } from "../../GraphicsSystem/Viewer"; +import { shareViewApp } from "./ShareViewService"; + +export class ShareViewViewer extends Viewer +{ + constructor(canvasContainer: HTMLElement) + { + super(canvasContainer); + this.RegisterKeyEvent(); + } + + // TODO: Error: hotkeys-js-ext的事件监听似乎有问题,可能是被Webpack优化了 + RegisterKeyEvent = () => + { + document.addEventListener('keydown', function (e) + { + hotkeys.dispatch(e); + }); + window.addEventListener('focus', hotkeys.clearDownKeys); // hack 在丢失焦点的时候也清理快捷键 + + window.addEventListener('blur', hotkeys.clearDownKeys); + document.addEventListener('keyup', function (e) + { + hotkeys.dispatch(e); + hotkeys.clearModifier(e); + }); + }; + + Update = () => + { + this.StartRender(); + }; + + async UpdateRenderType(db: Database, type: RenderType) + { + + for (let index = 0; index < db.ModelSpace.Entitys.length; index++) + { + let en = db.ModelSpace.Entitys[index]; + if (en.Visible) + { + if (type == RenderType.Physical2 && (en instanceof RoomWallBase || en instanceof RoomFlatBase || en instanceof RoomHoleBase)) + { + en.UpdateRenderType(RenderType.Physical); + } else + { + en.UpdateRenderType(type); + } + + } + } + + if (IsPhysical(type)) + CalcSunShadowCameraExtents(shareViewApp.Database.SunLight); + + this.UpdateRender(); + } +} diff --git a/src/Add-on/ShareView/components/CameraSwitchButton.tsx b/src/Add-on/ShareView/components/CameraSwitchButton.tsx new file mode 100644 index 000000000..eecf3bb21 --- /dev/null +++ b/src/Add-on/ShareView/components/CameraSwitchButton.tsx @@ -0,0 +1,25 @@ +import React from "react"; +import { shareViewApp } from "../ShareViewService"; +import { ShareViewStore } from "../ShareViewStore"; +function CameraSwitchButton() +{ + const SwitchCamera = () => { + shareViewApp.Viewer.CameraControl.SwitchCamera(); + ShareViewStore.GetInstance().CameraType = shareViewApp.Viewer.CameraControl.CameraType; + // shareViewApp.Viewer.UpdateRender(); + } + return ( +
{ + + + + + + + + }
+ ) +} + +export default CameraSwitchButton; diff --git a/src/Add-on/ShareView/components/HouseRoamingButton.tsx b/src/Add-on/ShareView/components/HouseRoamingButton.tsx new file mode 100644 index 000000000..e07dff6c9 --- /dev/null +++ b/src/Add-on/ShareView/components/HouseRoamingButton.tsx @@ -0,0 +1,159 @@ +import React, { useEffect, useState } from "react"; +import { end } from "xaop"; +import { app } from "../../../ApplicationServices/Application"; +import { CommandNames } from "../../../Common/CommandNames"; +import { Entity } from "../../../DatabaseServices/Entity/Entity"; +import { EntityRef } from "../../../DatabaseServices/Entity/EntityRef"; +import { Light } from "../../../DatabaseServices/Lights/Light"; +import { RoomFlatBase } from "../../../DatabaseServices/Room/Entity/Flat/RoomFlatBase"; +import { RoomRegion } from "../../../DatabaseServices/Room/Entity/Region/RoomRegion"; +import { RoomWallBase } from "../../../DatabaseServices/Room/Entity/Wall/RoomWallBase"; +import { commandMachine } from "../../../Editor/CommandMachine"; +import { VisualSpaceBox } from "../../../Editor/VisualSpaceBox"; +import { CameraType } from "../../../GraphicsSystem/CameraUpdate"; +import { shareViewApp } from "../ShareViewService"; +import { ShareViewStore } from "../ShareViewStore"; +import { resetBoxView } from "../ShareViewUtil"; + +const defaultFovLandscape = 60; +const defaultFovPortrait = 100; + +// TBD: 漫游切换逻辑可以提取到相机控制类 +function HouseRoamingButton() +{ + let [roaming, SetRoaming] = useState(false); + const shareViewStore = ShareViewStore.GetInstance(); + + useEffect(() => + { + shareViewStore.HouseRoamingMode = roaming; + }, [roaming]); + + const lazyLoadEntities: Entity[] = []; + const roomEntities: Entity[] = []; + for (let e of app.Database.ModelSpace.Entitys) + { + if (e.IsErase) continue; + if (e instanceof EntityRef) continue; + if (e instanceof RoomRegion) continue; + if (e instanceof VisualSpaceBox) continue; + if (e instanceof RoomWallBase || e instanceof RoomFlatBase) + { + roomEntities.push(e); + } else + { + lazyLoadEntities.push(e); + } + } + + /** + * 进入户型漫游模式 + */ + async function EnterHouseRoamingMode() + { + await shareViewApp.ResetViewState(); + SetRoaming(true); + + // 禁用左键选择 + end(shareViewApp.Editor.SelectCtrl, shareViewApp.Editor.SelectCtrl.LeftClick, () => shareViewApp.Editor.SelectCtrl.Cancel()); + + // 切换为透视相机 + shareViewApp.Viewer.CameraControl.CameraType = CameraType.PerspectiveCamera; + shareViewStore.CameraType = CameraType.PerspectiveCamera; + + // 设置摄像机视野 + shareViewStore.userFovPortrait = defaultFovPortrait; + shareViewStore.userFovLandscape = defaultFovLandscape; + function initFov() + { + if (screen.orientation.type.startsWith("portrait")) + shareViewApp.Viewer.CameraCtrl.Fov = shareViewStore.userFovPortrait; + else if (screen.orientation.type.startsWith("landscape")) + shareViewApp.Viewer.CameraCtrl.Fov = shareViewStore.userFovLandscape; + } + window.addEventListener('orientationchange', () => initFov()); + initFov(); + + for (const e of app.Database.Lights.Entitys) + { + if (e instanceof Light) + { + e.ShowHelper = false; + } + } + + // 隐藏其他实体 + for (let e of lazyLoadEntities) + { + e.Visible = false; + } + // 加载户型 + for (let e of roomEntities) + { + e.Visible = true; + } + + shareViewApp.ApplyHouseRoamingSwitches(); // 切换基础显示 + + // 重置视图 + resetBoxView(); + // 初始化完成,耗时操作在下面处理 + // 加载其他模型 + for (let e of lazyLoadEntities) + { + e.Visible = true; + } + setTimeout(() => + { + shareViewApp.Viewer.UpdateRenderType(shareViewApp.Database, shareViewStore.HouseRoamingRenderType); + }, 300); + // shareViewApp.ApplyHouseRoamingSwitches(RoamingSwitches.EnvMap, true); + } + + function LeaveHouseRoamingMode() + { + shareViewStore.HouseRoamingMode = false; + // 重置场景物体 + for (let e of app.Database.ModelSpace.Entitys) + if (!e.IsErase) + e.Visible = false; + shareViewStore.CurSelectCabinetIndexs.forEach(el => + { + shareViewApp.BoxCtrl.SetCabinetVisible(el, true); + }); + + + // 重置相机位置 + resetBoxView(); + + // 还原为概念渲染 + commandMachine.ExecCommand(CommandNames.Conceptual); + + // 切换为正交相机 + shareViewApp.Viewer.CameraControl.CameraType = CameraType.OrthographicCamera; + shareViewStore.CameraType = CameraType.OrthographicCamera; + + // 切换视角 + commandMachine.ExecCommand(CommandNames.Swiso); + + SetRoaming(false); + + // 更新渲染 + shareViewApp.Editor.UpdateScreen(); + } + if (roomEntities.length == 0) return null; // 没有户型不显示户型漫游 + + return ( + roaming ? ( +
+ entrance_line +
+ ) : ( +
+ +
+ ) + ); +} + +export default HouseRoamingButton; diff --git a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx index a90aa0c68..6ed631a36 100644 --- a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx +++ b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx @@ -206,6 +206,7 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) => 名称 {!view_id && 板编号} + 自定义板号 高度 宽度 厚度 @@ -224,6 +225,7 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) => { const size = SPGetSpiteSize(item); const blockNo = GetBlockNo(item.Id.Index); + const customBlockNo = item.CustomNumber ?? ''; const color = GetBlockColor(item); return ( = forwardRef((props, ref) => {i + 1} {item.Name} {!view_id && {blockNo}} + {customBlockNo} {size.height} {size.width} {size.thickness} diff --git a/src/Add-on/ShareView/components/MobileRoamingControl.tsx b/src/Add-on/ShareView/components/MobileRoamingControl.tsx new file mode 100644 index 000000000..0e7bc631e --- /dev/null +++ b/src/Add-on/ShareView/components/MobileRoamingControl.tsx @@ -0,0 +1,265 @@ +import React, { useRef } from "react"; +import { Clock, Vector3 } from "three"; +import { clamp } from "../../../Common/Utils"; +import { Viewer } from "../../../GraphicsSystem/Viewer"; +import { shareViewApp } from "../ShareViewService"; + +function translateCamera(viewer: Viewer, movement: Vector3) +{ + viewer.UpdateRender(); + viewer.Camera.position.add(movement); + viewer.CameraControl.Target.add(movement); + viewer.CameraControl.UpdateCameraMatrix(); +} + +const forwardIcon = + + + + + + +; + +const backIcon = + + + + + + +; + +const leftIcon = + + + + + + +; + +const upIcon = + + + + + +; + +const downIcon = + + + + + +; + + +const rightIcon = + + + + + + +; + +let accelerate = false; + +function cameraHeightControl() +{ + let moveSpeed: number = 1000; + let movement: number; + let canMove = false; + + const viewer = shareViewApp.Viewer; + const clock = new Clock(); + + const wrapper = useRef(); + + const update = () => + { // viewer.Pan会覆盖原位置 + requestAnimationFrame(update); + let deltaTime = clock.getDelta(); + if (canMove) + { + translateCamera(viewer, new Vector3(0, 0, movement * deltaTime)); + // console.log(movement); + } + }; + update(); + + + function SetMovement(value: number) + { + movement = value; + canMove = true; + } + + function stopMove() + { + canMove = false; + } + + return ( +
+ + + +
+ ); +} + +/* NippleJs +function virtualJoystick() { + const viewer = shareViewApp.Viewer; + const clock = new Clock(); + + const zoneRef = React.useRef(); + const moveSpeed = 100; + + let movement: { x: number, y: number } = { x: 0, y: 0 }; + let canMove = false; + + useEffect(() => { + const options: nipplejs.JoystickManagerOptions = { + zone: zoneRef.current, + color: "#0c0c0c", + mode: "semi", + catchDistance: 100, + // position: { left: '20%', top: '25%' }, + }; + const manager = nipplejs.create(options); + manager.on("start", () => { + canMove = true; + }); + manager.on("move", (e, data) => { + movement = data.vector; + }); + manager.on("end", () => { + canMove = false; + }); + }, []); + + + const update = () => { + requestAnimationFrame(update); + if (canMove) { + const deltaTime = 1; + const move = new Vector3(movement.x * deltaTime * moveSpeed, 0, -movement.y * deltaTime * moveSpeed); + move.applyQuaternion(viewer.Camera.quaternion); + translateCamera(viewer, move); + // console.log(move); + } + } + update(); + + return ( +
+ ); +} +*/ + + +function virtualJoystickSimple() +{ + const viewer = shareViewApp.Viewer; + const clock = new Clock(); + const moveSpeed = 1000; + let movement = { x: 0, y: 0 }; + let canMove = false; + const divWrapper = useRef(); + let root: HTMLElement; + + + const update = () => + { + requestAnimationFrame(update); + let deltaTime = clock.getDelta(); + if (canMove) + { + const move = new Vector3(movement.x, 0, -movement.y).normalize().multiplyScalar(deltaTime * moveSpeed); + move.applyQuaternion(viewer.Camera.quaternion); + translateCamera(viewer, move); + } + }; + + update(); + + const stop = () => + { + canMove = false; + }; + + // 0-1 + function setMovement(x: number, y: number) + { + movement = { x: clamp(x, -1, 1), y: clamp(y, -1, 1) }; + canMove = true; + } + + function move(e: React.TouchEvent) + { + const radius = divWrapper.current.offsetWidth / 2; + const originX = divWrapper.current.offsetLeft + radius; + const originY = divWrapper.current.offsetTop + radius; + + const touch = e.targetTouches[0]; + // calculate offset + const offsetX = touch.pageX - originX; + // offsetTop与PageY相反 + const offsetY = originY - touch.pageY; + + const x = offsetX / radius; + const y = offsetY / radius; + + // console.log(x,y); + setMovement(x, y); + } + + return ( +
+
+ {leftIcon} +
+
+ {rightIcon} +
+
+ {forwardIcon} +
+
+ {backIcon} +
+
+ ); +} + +export default () => +{ + return ( +
+ {virtualJoystickSimple()} + {cameraHeightControl()} +
); +}; diff --git a/src/Add-on/ShareView/components/ResetBoxViewButton.tsx b/src/Add-on/ShareView/components/ResetBoxViewButton.tsx new file mode 100644 index 000000000..b63740a0d --- /dev/null +++ b/src/Add-on/ShareView/components/ResetBoxViewButton.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import { resetBoxView } from "../ShareViewUtil"; +import { Icon } from "@blueprintjs/core"; +import { shareViewApp } from "../ShareViewService"; +import { app } from "../../../ApplicationServices/Application"; + +function ResetView() { + resetBoxView(); + shareViewApp.Editor.UpdateScreen(); +} + +function ResetBoxViewButton() { + return ( +
+ +
+ ) +} + +export default ResetBoxViewButton \ No newline at end of file diff --git a/src/Add-on/ShareView/components/ShareViewUI.tsx b/src/Add-on/ShareView/components/ShareViewUI.tsx index d6da16946..6e9b6dc01 100644 --- a/src/Add-on/ShareView/components/ShareViewUI.tsx +++ b/src/Add-on/ShareView/components/ShareViewUI.tsx @@ -3,17 +3,19 @@ import React, { useEffect, useRef, useState } from "react"; import { CommandNames } from "../../../Common/CommandNames"; import { commandMachine } from "../../../Editor/CommandMachine"; import { userConfig } from "../../../Editor/UserConfig"; +import { CameraType } from "../../../GraphicsSystem/CameraUpdate"; import { RenderType } from "../../../GraphicsSystem/RenderType"; import { IsDoor, IsDrawer } from "../../HideSelect/HideSelectUtils"; import { ViewStyleTypes } from "../ShareViewRules"; import { shareViewApp } from "../ShareViewService"; -import { ShareViewStore } from "../ShareViewStore"; +import { RoamingSwitches, ShareViewStore } from "../ShareViewStore"; import "../ShareViewStyle.less"; import { ChangeCylinderHoleVisible, ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ExplosionView, ForbiddenToaster, resetBoxView, show2DPathLine, SwitchDoorOrDrawer } from "../ShareViewUtil"; import BoardMessageWidget from "./BoardMessageWidget"; import CabinetBottomSheet from "./CabinetBottomSheet"; import HideComponentsMenu from "./HideComponentsMenu"; import MaterialBottomSheet from "./MaterialBottomSheet"; +import MobileRoamingControl from "./MobileRoamingControl"; import SideBar from "./SideBar"; import { SPToaster } from "./SPToater"; import ViewAngle from "./ViewAngle"; @@ -349,96 +351,135 @@ function ShareViewUI() await show2DPathLine(i); shareViewApp.Editor.UpdateScreen(); }; - + shareViewApp.ResetViewState = resetAll; return ( - - -
-
-
- { - cabinetBottomSheetRef.current.show(); - }} - >选择柜体
- - {() => ( - <> - {shareViewStore.Props.showBom == false ? null : ( -
- { - materialBottomSheetRef.current.show(); - }} - >物料明细{shareViewStore.Props.showBom}
- )} -
- {shareViewStore.operations.isDoorOpen ? '关门' : '开门'}
- - )} -
- -
还原
-
- {/* 侧边栏 */} - - {/* 选中的板信息 */} - - {/* 顶部栏 */} -
- - - { - await closeDoor(); - await resetExplosionView(); - shareViewStore.operations.showCustomNumber = renderType == RenderType.CustomNumber; - shareViewStore.viewUploadProps.VisualStyle = renderType; - }} - currentRenderType={shareViewStore.viewUploadProps.VisualStyle} - /> - - {() => ( - <> -
标注
-
板号
- - )} -
-
- - { - if (shareViewStore.operations.showDimension) - { - await DeleteBoxDim(); - shareViewStore.operations.showDimension = false; - } - await closeDoor(); - await resetExplosionView(); - await showDoor(); - await showDrawer(); - }} - ref={cabinetBottomSheetRef} - /> - -
+ + { + () => ( + + +
+ + { + /* 底部按钮组 */ + shareViewStore.HouseRoamingMode == true ? null : ( +
+
+ { + cabinetBottomSheetRef.current.show(); + }} + >选择柜体
+ + {shareViewStore.Props.showBom == false ? null : ( +
+ { + materialBottomSheetRef.current.show(); + }} + >物料明细{shareViewStore.Props.showBom}
+ )} +
+ {shareViewStore.operations.isDoorOpen ? '关门' : '开门'}
+ + +
还原
+
+ ) + } + + {/* 侧边栏 */} + + {/* 选中的板信息 */} + +
+ { + /* 顶部栏 */ + shareViewStore.HouseRoamingMode ? ( + <> +
shareViewApp.ApplyHouseRoamingSwitches(RoamingSwitches.Decoration, true)} + >摆件[{shareViewApp.CheckHouseRoamingSwitches(RoamingSwitches.Decoration) ? '有' : '无'}] +
+ + { + shareViewStore.HouseRoamingRenderType = renderType; + }} + currentRenderType={shareViewStore.HouseRoamingRenderType} + /> + + ) : ( + <> + + + { + await closeDoor(); + await resetExplosionView(); + shareViewStore.operations.showCustomNumber = renderType == RenderType.CustomNumber; + shareViewStore.viewUploadProps.VisualStyle = renderType; + }} + currentRenderType={shareViewStore.viewUploadProps.VisualStyle} + /> + +
标注
+
板号
+ ) + } +
+ + + { + if (shareViewStore.operations.showDimension) + { + await DeleteBoxDim(); + shareViewStore.operations.showDimension = false; + } + await closeDoor(); + await resetExplosionView(); + await showDoor(); + await showDrawer(); + }} + ref={cabinetBottomSheetRef} + /> + + + {/* 移动端的虚拟按键和摇杆 */} + { + () => ( + // 只有在设备有触摸点且相机为透视视角时开启虚拟摇杆 + navigator.maxTouchPoints > 0 && + shareViewStore.CameraType === CameraType.PerspectiveCamera ? + : + <> + ) + } + + +
+ ) + } +
); } diff --git a/src/Add-on/ShareView/components/SideBar.tsx b/src/Add-on/ShareView/components/SideBar.tsx index 95d46e68e..7c3426ff9 100644 --- a/src/Add-on/ShareView/components/SideBar.tsx +++ b/src/Add-on/ShareView/components/SideBar.tsx @@ -1,13 +1,17 @@ +import { Observer } from "mobx-react"; import React from 'react'; import { CommandNames } from '../../../Common/CommandNames'; import { commandMachine } from '../../../Editor/CommandMachine'; import { shareViewApp } from '../ShareViewService'; -import { resetBoxView } from '../ShareViewUtil'; +import { ShareViewStore } from "../ShareViewStore"; import BoardHideIcon from './BoardHideIcon'; +import HouseRoamingButton from './HouseRoamingButton'; +import ResetBoxViewButton from "./ResetBoxViewButton"; import ShareWidget from './ShareWidget'; import ThemeButton from './ThemeButton'; const search = new URLSearchParams(location.search); const view_id = search.get('view_id'); +const shareviewStore = ShareViewStore.GetInstance(); const SideBar = () => { return ( @@ -42,7 +46,6 @@ const SideBar = () => { commandMachine.ExecCommand(item.command); shareViewApp.Viewer.UpdateRender(); - resetBoxView(); }} > {item.name} @@ -50,6 +53,12 @@ const SideBar = () => ); }) } + + { + () => shareviewStore.HouseRoamingMode ? : <> + } + + ); diff --git a/src/Add-on/ShareView/components/ViewStyle.tsx b/src/Add-on/ShareView/components/ViewStyle.tsx index fddb82ad1..ee797b1cf 100644 --- a/src/Add-on/ShareView/components/ViewStyle.tsx +++ b/src/Add-on/ShareView/components/ViewStyle.tsx @@ -2,17 +2,20 @@ import React, { forwardRef, useEffect, useRef, useState } from "react"; import { CommandNames } from "../../../Common/CommandNames"; import { commandMachine } from "../../../Editor/CommandMachine"; import { RenderType } from "../../../GraphicsSystem/RenderType"; -import { ViewStyleTypes } from "../ShareViewRules"; +import { getViewStyleTypes } from "../ShareViewRules"; +import { shareViewApp } from "../ShareViewService"; import { ForbiddenToaster } from "../ShareViewUtil"; interface IProps { reset: (renderType: RenderType) => Promise; currentRenderType: RenderType; + mode: string; } const ViewStyle: React.FC = forwardRef((props) => { + const styleTypes = getViewStyleTypes(props.mode); const [visible, setVisible] = useState(false); const [selected, setSelected] = useState('概念'); const selectDivRef = useRef(); @@ -27,7 +30,7 @@ const ViewStyle: React.FC = forwardRef((props) => function checkRenderType(renderType: RenderType): number { - const viewStyleIndex = ViewStyleTypes.findIndex(v => v.renderType === renderType); + const viewStyleIndex = styleTypes.findIndex(v => v.renderType === renderType); if (viewStyleIndex > -1) return viewStyleIndex; return 0; } @@ -49,7 +52,7 @@ const ViewStyle: React.FC = forwardRef((props) => useEffect(() => { if (props.currentRenderType) - setSelected(ViewStyleTypes[checkRenderType(props.currentRenderType)].title); + setSelected(styleTypes[checkRenderType(props.currentRenderType)].title); return () => { setSelected(""); }; }, [props.currentRenderType]); @@ -72,7 +75,7 @@ const ViewStyle: React.FC = forwardRef((props) => onMouseDown={stopPropagation} onClick={stopPropagation} > - {ViewStyleTypes.map((item) => + {styleTypes.map((item) => { return (
  • = forwardRef((props) => e.stopPropagation(); ForbiddenToaster(async () => { - await commandMachine.ExecCommand(item.cmd); + if (item.cmd) + { + await commandMachine.ExecCommand(item.cmd); + } else + { + await shareViewApp.Viewer.UpdateRenderType(shareViewApp.Database, item.renderType); + } }); setSelected(item.title); }} >{item.title}
  • ); })} -
  • - { - e.stopPropagation(); - ForbiddenToaster(async () => - { - await commandMachine.ExecCommand(CommandNames.SwitchLines); - setSelectLines(!selectLines); - }); - }} - >纹路
  • + { + () => props.mode == "HouseRoaming" ? <> : +
  • + { + e.stopPropagation(); + ForbiddenToaster(async () => + { + await commandMachine.ExecCommand(CommandNames.SwitchLines); + setSelectLines(!selectLines); + }); + }} + >纹路
  • + } + ); diff --git a/src/Add-on/ShareView/index.html b/src/Add-on/ShareView/index.html new file mode 100644 index 000000000..69aa5cfc7 --- /dev/null +++ b/src/Add-on/ShareView/index.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + WebCAD + + + + +
    +
    +
    +
    +
    正在加载中,请稍候...
    +
    + + + diff --git a/src/Add-on/ShareView/webpack.common.ts b/src/Add-on/ShareView/webpack.common.ts new file mode 100644 index 000000000..c40268c39 --- /dev/null +++ b/src/Add-on/ShareView/webpack.common.ts @@ -0,0 +1,222 @@ +import AddAssetHtmlPlugin from "add-asset-html-webpack-plugin"; +import CleanTerminalPlugin from "clean-terminal-webpack-plugin"; +import { CleanWebpackPlugin } from "clean-webpack-plugin"; +import HtmlWebPackPlugin from "html-webpack-plugin"; +import * as path from 'path'; +import * as webpack from 'webpack'; +import WebpackBar from 'webpackbar'; + + +export const buildVersion = new Date().toLocaleString(); + +function resolve(fileName: string) +{ + return path.resolve(__dirname, fileName); +} + +const DIST_DIR = resolve('../../../dist/shareview'); + +const TS_LOADER = [ + { loader: 'cache-loader', options: { cacheDirectory: "node_modules/.shareview_cache" } }, + { + loader: 'ts-loader', + options: { + transpileOnly: true, + experimentalWatchApi: true, + }, + } +]; + +export default { + cache: { + type: 'filesystem', + }, + entry: { + main: resolve("ShareViewEntry"), + }, + output: { + filename: "[contenthash].[name].js", + path: resolve(DIST_DIR),//虽然不需要提供 但是如果不提供CleanWebpackPlugin就坏了 + publicPath: "", + globalObject: "this" + }, + resolve: { + // alias: { + // "dat.gui": resolve('../node_modules/dat.gui/build/dat.gui.js'), + // }, + extensions: [".ts", ".tsx", ".js", "json"] + }, + module: { + rules: [ + { + test: /\.worker\.ts$/, + exclude: /node_modules/, + use: [ + { loader: 'worker-loader', }, + ...TS_LOADER + ] + }, + { + test: /\.tsx?$/, + exclude: /node_modules/, + use: TS_LOADER, + }, + { + test: /\.[(png)|(obj)|(json)]$/, + loader: "file-loader" + }, + //样式加载 css + { + test: /\.css$/, + use: ['style-loader', 'css-loader'] + }, + //样式加载 less + { + test: /\.less$/, + use: [ + { loader: "style-loader" }, + { loader: 'css-loader', options: { sourceMap: false } }, + { + loader: "less-loader", + options: { + lessOptions: { + strictMath: true, + noIeCompat: true + } + } + } + ] + }, + //字体加载 blueprint + { + test: /\.(ttf|eot|svg|FBX)$/, + use: { + loader: 'file-loader', + options: { name: 'fonts/[contenthash].[ext]' } + } + }, + //字体加载 blueprint + { + test: /\.(woff|woff2|jpg|png)$/, + use: { + loader: 'url-loader', + options: { + name: 'fonts/[contenthash].[ext]', + limit: 5000, + mimetype: 'application/font-woff' + } + } + }, + { + test: /\.(glsl|vs|fs)$/, + loader: 'shader-loader' + } + ] + }, + externals: [ + function ({ context, request }, callback) + { + if (/\/Components\/MainContent/.test(request)) + { + callback(null, '{}'); + return; + } + if (/Editor\/CommandRegister/.test(request)) + { + callback(null, '{}'); + return; + } + if (/\/Add-on\/KJL/.test(request)) + { + callback(null, '{}'); + return; + } + if (/@epicgames-ps/.test(request)) + { + callback(null, '{}'); + return; + } + if (/dwg2dxf/.test(request)) + { + callback(null, '{}'); + return; + } + + // if (/@blueprintjs\/icons/.test(request)) + // { + // callback(null, '{}'); + // return; + // } + + callback(); + } + ], + optimization: { + splitChunks: { + chunks: 'async', + minSize: 20000, + minRemainingSize: 0, + minChunks: 1, + maxAsyncRequests: 30, + maxInitialRequests: 30, + enforceSizeThreshold: 50000, + cacheGroups: { + defaultVendors: { + test: /[\\/]node_modules[\\/]/, + name: 'vendor', + priority: -10, + reuseExistingChunk: true, + chunks: 'initial', + }, + default: { + name: 'common', + minChunks: 2, + priority: -20, + reuseExistingChunk: true, + chunks: 'initial', + }, + }, + }, + }, + plugins: [ + new HtmlWebPackPlugin({ + title: "shareview", + template: resolve('index.html'), + filename: 'index.html', + chunks: ['main'] + }), + new AddAssetHtmlPlugin( + [ + { + filepath: "./src/loading.css", + typeOfAsset: "css", + }, + { + filepath: "./node_modules/normalize.css/normalize.css", + typeOfAsset: "css", + }, + { + filepath: "./node_modules/@blueprintjs/core/lib/css/blueprint.css", + typeOfAsset: "css", + includeRelatedFiles: false + }, + // { glob: "./dist/*.dll.js", }, + ] + ), + new webpack.ProvidePlugin({ + ReactDOM: 'react-dom', + React: 'react', + THREE: "three" + }), + new webpack.DefinePlugin({ 'process': "globalThis", version: JSON.stringify(buildVersion) }), + new CleanTerminalPlugin(), + + new WebpackBar(), + // new HardSourceWebpackPlugin(), + // new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }), + new CleanWebpackPlugin({ + cleanOnceBeforeBuildPatterns: ["*"] + }), + ], + node: { global: true }, +} as webpack.Configuration; diff --git a/src/Add-on/ShareView/webpack.dev.ts b/src/Add-on/ShareView/webpack.dev.ts new file mode 100644 index 000000000..e1e923784 --- /dev/null +++ b/src/Add-on/ShareView/webpack.dev.ts @@ -0,0 +1,63 @@ +import { Configuration } from "webpack"; +import { merge } from 'webpack-merge'; +import common from './webpack.common'; +//hmr +import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'; + +export default merge(common, { + mode: "development", + output: { pathinfo: false }, + /** + * eval-source-map 无法断点src\UI\Components\Board\BoardOptionModal.tsx:37:42 + * 并且https://github.com/microsoft/vscode/issues/194988 + */ + devtool: "source-map", + //https://www.webpackjs.com/configuration/stats/ + stats: "errors-only" || { + assets: false, + timings: false, + + builtAt: false, + cachedAssets: false, + hash: false, + modules: false, + performance: false, + entrypoints: false, + + // 添加 children 信息 + children: false, + // 添加 chunk 信息(设置为 `false` 能允许较少的冗长输出) + chunks: false, + // 将构建模块信息添加到 chunk 信息 + chunkModules: false, + // 添加 chunk 和 chunk merge 来源的信息 + chunkOrigins: false, + + reasons: false, + source: false + }, + devServer: { + static: false, + port: 7776, + host: "0.0.0.0", + hot: true, + proxy: { + "/api": { + target: "https://cad.leye.site", + pathRewrite: { '^/api': '' }, + secure: false, + headers: { + Host: 'cfcad.cn', + Origin: "https://cfcad.cn" + } + } + } + }, + optimization: { + moduleIds: "named", + }, + //hmr + plugins: [ + new ReactRefreshWebpackPlugin() + ], +} as Configuration); diff --git a/src/Add-on/ShareView/webpack.prod.ts b/src/Add-on/ShareView/webpack.prod.ts new file mode 100644 index 000000000..b74605c44 --- /dev/null +++ b/src/Add-on/ShareView/webpack.prod.ts @@ -0,0 +1,20 @@ +import TerserPlugin from "terser-webpack-plugin"; +import { merge } from 'webpack-merge'; +import common from './webpack.common'; + +export default merge(common, { + mode: "production", + devtool: false, + optimization: { + minimizer: [ + new TerserPlugin({ + parallel: true, + terserOptions: { + ecma: 2020, + sourceMap: false, + keep_classnames: true, + } + }), + ] + } +}); diff --git a/src/Editor/CameraControls.ts b/src/Editor/CameraControls.ts index eb84ccd44..ef5a9cccc 100644 --- a/src/Editor/CameraControls.ts +++ b/src/Editor/CameraControls.ts @@ -86,10 +86,10 @@ export class CameraControls this.domElement.addEventListener("mouseup", this.onMouseUp, false); window.addEventListener("keydown", this.onKeyDown, false); window.addEventListener("keyup", this.onKeyUp, false); - this.domElement.addEventListener("wheel", this.onMouseWheel, { passive: false }); + this.domElement.addEventListener("wheel", (e) => this.onMouseWheel(e), { passive: false }); - this.domElement.addEventListener("touchstart", this.onTouchStart, { passive: false }); - this.domElement.addEventListener("touchend", this.onTouchEnd, false); + this.domElement.addEventListener("touchstart", (e) => this.onTouchStart(e), { passive: false }); + this.domElement.addEventListener("touchend", (e) => this.onTouchEnd(e), false); this.domElement.addEventListener("touchmove", e => { if (!this.EnableTouchControl && e.touches.length === 1) return; @@ -147,7 +147,7 @@ export class CameraControls { this.State = CameraControlState.Null; }; - onTouchMove = (event: Touch_Event) => + onTouchMove(event: Touch_Event) { event.preventDefault(); event.stopPropagation(); @@ -335,7 +335,7 @@ export class CameraControls * 鼠标滚轮事件 */ cameraNormal = new Vector3; - onMouseWheel = (event: WheelEvent) => + onMouseWheel(event: WheelEvent) { event.preventDefault(); event.stopPropagation(); diff --git a/src/GraphicsSystem/CameraUpdateForIos.ts b/src/GraphicsSystem/CameraUpdateForIos.ts index 3bab78e4b..d6a85f143 100644 --- a/src/GraphicsSystem/CameraUpdateForIos.ts +++ b/src/GraphicsSystem/CameraUpdateForIos.ts @@ -61,6 +61,6 @@ export class CameraUpdateForIos camera.Target.copy(this._iPoint); camera.Camera.near = 0.1; - camera.Camera.far = this.boundingSphere.radius * 2; + camera.Camera.far = this.boundingSphere.radius * 10; } }