Skip to content

Commit

Permalink
feat: draw line custom mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
gong9 committed Oct 19, 2023
1 parent 9150431 commit b6669f2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@umijs/max": "^4.0.72",
"ahooks": "^3.7.8",
"antd": "^5.6.3",
"classnames": "^2.3.2",
"dexie": "^3.2.4",
"fast-json-patch": "^3.1.1",
"hotkeys-js": "^3.10.4",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/image/mouse.ico
Binary file not shown.
8 changes: 7 additions & 1 deletion src/pages/Editor/canvas/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.editor {
min-width: 1000px;
}

}

.drawline {
cursor: url('../../../../public/image/mouse.ico'),
default;
}
7 changes: 5 additions & 2 deletions src/pages/Editor/canvas/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { FC } from 'react'
import { Suspense, useEffect, useRef, useState } from 'react'
import { Canvas, useFrame, useThree } from '@react-three/fiber'
import { Canvas, useThree } from '@react-three/fiber'
import { GizmoHelper, GizmoViewcube, GizmoViewport, OrbitControls, OrthographicCamera } from '@react-three/drei'
import type { OrbitControls as OrbitControlsImpl } from 'three-stdlib'
import type { PerspectiveCamera } from 'three'
import classnames from 'classnames'

import RenderModels from './components/RenderModels'
import RenderMesh from './components/RenderMesh'
import { getMainCamera } from './3d/index'
import useModeStore from '@/store/mode'
import ReactLoading from '@/components/Loding'
import store from '@/store'

Expand Down Expand Up @@ -79,6 +81,7 @@ const CanvasContent = () => {
const Center: FC<EditorProps> = () => {
const canvasRef = useRef<HTMLDivElement>(null)
const [isRenderCanvas, setIsRenderCanvas] = useState(false)
const { drawline } = useModeStore(state => state)

// const { initialMainCameraPosition } = store.schemaStore(state => ({
// initialMainCameraPosition: state.initialMainCameraPosition,
Expand All @@ -94,7 +97,7 @@ const Center: FC<EditorProps> = () => {
}, [])

return (
<div className='h-screen absolute w-full editor' ref={canvasRef}>
<div className={classnames('h-screen absolute w-full editor', { drawline })} ref={canvasRef}>
{isRenderCanvas
&& <Suspense fallback={<ReactLoading />}>
<Canvas camera={getMainCamera(canvasRef, angleOfView)! as (PerspectiveCamera) } frameloop='demand' style={{ backgroundColor: '#222' }}>
Expand Down

0 comments on commit b6669f2

Please sign in to comment.