Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

功能请求 | 希望增加侧边菜单自定义功能 #17

Open
wxx97168 opened this issue Feb 25, 2025 · 3 comments
Open

功能请求 | 希望增加侧边菜单自定义功能 #17

wxx97168 opened this issue Feb 25, 2025 · 3 comments

Comments

@wxx97168
Copy link

你好,我是一名React个人开发,正在学习使用@icraft/player-react开发3D交互项目。当前组件非常方便,但在自定义侧边菜单时遇到限制。
能否开放以下功能?
(1)允许通过props自定义菜单项(如动态增删菜单)
(2)提供菜单点击事件的回调接口
(3)支持基础样式覆盖(如调整菜单位置/颜色)
这将极大帮助学习者实现更灵活的界面交互实验。如果需要具体用例说明,我可以提供demo片段。感谢!

@yuanguandong
Copy link
Member

自定义菜单具体指的是什么呀?可以用图来示意吗?或是demo片段

@wxx97168
Copy link
Author

自定义菜单具体指的是什么呀?可以用图来示意吗?或是demo片段

感谢您的跟进!以下是当前使用场景中希望实现的侧边菜单自定义能力细节,结合代码示例与场景示意图说明:

Image
当前@icraft/player-react只能预览模型,无法编辑模型,无法满足修改编辑模型的场景。
期望实现 提供类似menuItems的数组型prop,支持动态增删(如通过playerRef.current.updateMenuItems(newItems)的API)
参考案例 类似Antd Menu组件的动态生成逻辑(如从后端获取菜单数据后递归渲染),期望@icraft/player-react能开放同等灵活度。
<ICraftPlayer
src={srcValue}
ref={playerRef}
locale="zh-CN"
addons={["CameraBar", "ZoomBar"]}
// 期望新增props ↓
menuItems={[
{ id: "rotate", label: "模型1", icon: },
{ id: "highlight", label: "设备2", children: [...] }
]}
onMenuClick={(item) => {
if (item.id === "rotate")
playerRef.current.startCameraRotation();
}}
/>
此扩展能力将显著提升@icraft/player-react组件在数字孪生教学实验中的实用性,期待您的进一步反馈!

@yuanguandong
Copy link
Member

看了描述,如果只是增加菜单的话,完全可以在外部实现,@icraft/player-react 目前有开放鼠标单击事件以及双击事件,后续可以提供右键事件,用户可以通过右键事件捕获当前坐标以及元素等,外部动态渲染一个菜单到对应位置即可实现描述的效果,你觉得这样如何?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants