Chore: Removed file-saver from plugin-r3f

This commit is contained in:
Aria Minaei 2021-06-29 15:00:20 +02:00
parent 14b3207680
commit 040317f53b
2 changed files with 13 additions and 26 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "@theatre/plugin-r3f", "name": "@theatre/plugin-r3f",
"version": "1.0.0-dev", "version": "1.0.0-dev.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"authors": [ "authors": [
{ {
@ -30,7 +30,6 @@
"build": "tsc --build ./tsconfig.json" "build": "tsc --build ./tsconfig.json"
}, },
"devDependencies": { "devDependencies": {
"@types/file-saver": "^2.0.2",
"@types/jest": "^26.0.23", "@types/jest": "^26.0.23",
"@types/lodash-es": "^4.17.4", "@types/lodash-es": "^4.17.4",
"@types/node": "^15.6.2", "@types/node": "^15.6.2",
@ -43,7 +42,6 @@
"@theatre/core": "workspace:*", "@theatre/core": "workspace:*",
"@theatre/studio": "workspace:*", "@theatre/studio": "workspace:*",
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"file-saver": "^2.0.5",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"prism-react-renderer": "1.2.1", "prism-react-renderer": "1.2.1",
"react": "^17.0.2", "react": "^17.0.2",

View file

@ -4,7 +4,6 @@ import TransformControlsModeSelect from './TransformControlsModeSelect'
import {useEditorStore} from '../store' import {useEditorStore} from '../store'
import shallow from 'zustand/shallow' import shallow from 'zustand/shallow'
import ReferenceWindow from './ReferenceWindow' import ReferenceWindow from './ReferenceWindow'
import {saveAs} from 'file-saver'
import TransformControlsSpaceSelect from './TransformControlsSpaceSelect' import TransformControlsSpaceSelect from './TransformControlsSpaceSelect'
import ViewportShadingSelect from './ViewportShadingSelect' import ViewportShadingSelect from './ViewportShadingSelect'
import {AiFillEye, GiPocketBow, RiFocus3Line} from 'react-icons/all' import {AiFillEye, GiPocketBow, RiFocus3Line} from 'react-icons/all'
@ -68,14 +67,15 @@ const UI: VFC = () => {
label="Focus on selected" label="Focus on selected"
icon={<RiFocus3Line />} icon={<RiFocus3Line />}
onClick={() => { onClick={() => {
const orbitControls = useEditorStore.getState() const orbitControls =
.orbitControlsRef?.current useEditorStore.getState().orbitControlsRef?.current
const selected = useEditorStore.getState().selected const selected = useEditorStore.getState().selected
let focusObject let focusObject
if (selected) { if (selected) {
focusObject = useEditorStore.getState() focusObject =
.editablesSnapshot![selected].proxyObject useEditorStore.getState().editablesSnapshot![selected]
.proxyObject
} }
if (orbitControls && focusObject) { if (orbitControls && focusObject) {
@ -92,15 +92,18 @@ const UI: VFC = () => {
label="Align object to view" label="Align object to view"
icon={<GiPocketBow />} icon={<GiPocketBow />}
onClick={() => { onClick={() => {
const camera = (useEditorStore.getState().orbitControlsRef const camera = (
?.current as $FixMe)?.object useEditorStore.getState().orbitControlsRef
?.current as $FixMe
)?.object
const selected = useEditorStore.getState().selected const selected = useEditorStore.getState().selected
let proxyObject let proxyObject
if (selected) { if (selected) {
proxyObject = useEditorStore.getState() proxyObject =
.editablesSnapshot![selected].proxyObject useEditorStore.getState().editablesSnapshot![selected]
.proxyObject
if (proxyObject && camera) { if (proxyObject && camera) {
const direction = new Vector3() const direction = new Vector3()
@ -142,20 +145,6 @@ const UI: VFC = () => {
> >
Close Close
</Button> </Button>
{/* Bottom-right corner */}
<Button
className="absolute right-0 bottom-0 pointer-events-auto"
onClick={() => {
const blob = new Blob(
[JSON.stringify(useEditorStore.getState().serialize())],
{type: 'text/json;charset=utf-8'},
)
saveAs(blob, 'editableState.json')
}}
>
Export
</Button>
</div> </div>
</div> </div>
</div> </div>