Update integration to use bundled version of CascadeStudio

resolves #139
This commit is contained in:
Kurt Hutten
2021-01-24 21:24:49 +11:00
parent 79ba400368
commit bb70b29324
7 changed files with 65 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ import { useAuth } from '@redwoodjs/auth'
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'
const defaultExampleCode = `// Welcome to Cascade Studio! Here are some useful functions:
// Translate(), Rotate(), Scale(), Union(), Difference(), Intersection()

View File

@@ -292,23 +292,16 @@ const IdeToolbar = ({
transformOrigin={transformOrigin}
className="material-ui-overrides transform translate-y-4"
>
<div className="text-sm p-2 text-gray-500 max-w-md">
<div className="text-sm p-4 text-gray-500 max-w-md">
<div className="text-base text-gray-700 py-2">
Model never generating?
Can't export stl/obj/STEP?
</div>
Due to the current integration with CascadeStudio and the order in
which the code initialise sometimes the 3d model never generates
<div className="text-base text-gray-700 py-2">Work around</div>
<p>
Usually going to the <a href="/">homepage</a>, then refreshing,
waiting a good 10 seconds before navigating back to the part
your interested in should fix the issue.
</p>
Currently exports are only working for chrome and edge browsers
<p>
If this problem is frustrating to you, leave a comment on its{' '}
<OutBound
className="text-gray-600 underline"
to="https://github.com/Irev-Dev/cadhub/issues/139"
to="https://github.com/zalo/CascadeStudio/pull/39#issuecomment-766206091"
>
github issue
</OutBound>{' '}

View File

@@ -1,4 +1,5 @@
import { initialize, getEditor } from 'src/cascade/js/MainPage/CascadeMain'
import { initialize } from 'src/cascade/js/MainPage/CascadeMain'
import { monacoEditor } from 'src/cascade/js/MainPage/CascadeState'
class CascadeController {
_hasInitialised = false
@@ -9,14 +10,14 @@ class CascadeController {
initialise(onCodeChange, code) {
const onInit = () => {
const editor = getEditor()
const editor = monacoEditor
editor.setValue(code)
editor.evaluateCode(false)
}
// only inits on first call, after that it just updates the editor and revaluates code, maybe should rename?
this.incomingOnCodeChang = onCodeChange
if (!this._hasInitialised) {
initialize(this.controllerOnCodeChange, code, onInit)
new initialize(this.controllerOnCodeChange, code, onInit)
this._hasInitialised = true
return
}