Began building out screenshot capture feature.

This commit is contained in:
Frank Noirot
2021-02-25 01:50:03 -05:00
parent a2b69ece29
commit 6e6425735f
5 changed files with 113 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ import CascadeController from 'src/helpers/cascadeController'
import IdeToolbar from 'src/components/IdeToolbar'
import { useEffect, useState } from 'react'
import { threejsViewport } from 'src/cascade/js/MainPage/CascadeState'
import { element } from 'prop-types'
import { uploadToCloudinary } from 'src/helpers/cloudinary'
const defaultExampleCode = `// Welcome to Cascade Studio! Here are some useful functions:
// Translate(), Rotate(), Scale(), Union(), Difference(), Intersection()
@@ -70,6 +72,18 @@ const IdeCascadeStudio = ({ part, saveCode, loading }) => {
partTitle: part?.title,
image: part?.user?.image,
}}
onCapture={ async () => {
// Get the canvas image as a Data URL
const imgBlob = await CascadeController.capture(threejsViewport.environment)
const imgURL = window.URL.createObjectURL(imgBlob)
// TODO: Upload the image to Cloudinary
// uploadToCloudinary(imgBlob)
// TODO: Save the screenshot as the mainImage if none has been set
// If it has been set, pass along the Blob without uploading
// onSave(part?.id, { ...input, mainImage: cloudinaryPublicId })
}}
/>
</div>
</>