Began building out screenshot capture feature.
This commit is contained in:
@@ -23,6 +23,29 @@ class CascadeController {
|
||||
}
|
||||
onInit()
|
||||
}
|
||||
|
||||
capture(environment) {
|
||||
let width = 512, height = 384;
|
||||
environment.camera.aspect = width / height;
|
||||
environment.camera.updateProjectionMatrix();
|
||||
environment.renderer.setSize(width, height);
|
||||
environment.renderer.render(environment.scene, environment.camera, null, false);
|
||||
let imgBlob = new Promise((resolve, reject) => {
|
||||
environment.renderer.domElement.toBlob(
|
||||
(blob) => {
|
||||
blob.name = `part_capture-${ Date.now() }`
|
||||
resolve(blob)
|
||||
},
|
||||
'image/jpeg',
|
||||
1
|
||||
);
|
||||
})
|
||||
|
||||
// Return to original dimensions
|
||||
environment.onWindowResize();
|
||||
|
||||
return imgBlob
|
||||
}
|
||||
}
|
||||
|
||||
export default new CascadeController()
|
||||
|
||||
23
web/src/helpers/cloudinary.js
Normal file
23
web/src/helpers/cloudinary.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// TODO: create a tidy util for uploading to Cloudinary and returning the public ID
|
||||
import axios from 'axios'
|
||||
|
||||
const CLOUDINARY_UPLOAD_PRESET = 'CadHub_project_images'
|
||||
const CLOUDINARY_UPLOAD_URL = 'https://api.cloudinary.com/v1_1/irevdev/upload'
|
||||
|
||||
export async function uploadToCloudinary(imgBlob) {
|
||||
// const imageData = new FormData()
|
||||
// imageData.append('upload_preset', CLOUDINARY_UPLOAD_PRESET)
|
||||
// imageData.append('file', croppedFile)
|
||||
// let upload = axios.post(CLOUDINARY_UPLOAD_URL, imageData)
|
||||
|
||||
// try {
|
||||
// const { data } = await upload
|
||||
// if (data && data.public_id !== '') {
|
||||
// onImageUpload({ cloudinaryPublicId: data.public_id })
|
||||
// setCloudinaryId(data.public_id)
|
||||
// setIsModalOpen(false)
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error('ERROR', e)
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user