diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml index 5c77cbc6..3936dbf7 100644 --- a/.github/workflows/static-code-analysis.yml +++ b/.github/workflows/static-code-analysis.yml @@ -34,6 +34,8 @@ jobs: run: npm install -g npm@latest - name: Install dependencies run: npm install + - name: Re-install opencascade.js@beta dependency + run: npm install -w packages/frontend opencascade.js@beta - name: Build sources run: npm run build - name: Lint sources diff --git a/packages/backend/scripts/src/modules/rest/versions/version.service.ts b/packages/backend/scripts/src/modules/rest/versions/version.service.ts index bf8dc3d2..e5a41baa 100644 --- a/packages/backend/scripts/src/modules/rest/versions/version.service.ts +++ b/packages/backend/scripts/src/modules/rest/versions/version.service.ts @@ -139,6 +139,9 @@ export class VersionService implements VersionREST exec && setGroup(model.scene)) } else if (props.path.endsWith('.ldr') || props.path.endsWith('.mpd')) { getLDrawModel(props.path).then(group => exec && setGroup(group)) + } else if (props.path.endsWith('.FCStd')) { + getFCStdModel(props.path).then(group => exec && setGroup(group)) } } else { setGroup(undefined) diff --git a/packages/frontend/src/scripts/components/widgets/ModelView3D.tsx b/packages/frontend/src/scripts/components/widgets/ModelView3D.tsx index 494b6721..c22ca2c4 100644 --- a/packages/frontend/src/scripts/components/widgets/ModelView3D.tsx +++ b/packages/frontend/src/scripts/components/widgets/ModelView3D.tsx @@ -104,22 +104,24 @@ export class ModelView3D extends React.Component { this.highlight_cache[mesh.uuid] = mesh.material const highlighted = this.props.highlighted.filter(prefix => comparePath(prefix, path)).length > 0 const marked = this.props.marked.filter(prefix => comparePath(prefix, path)).length > 0 - if (highlighted && marked) { - mesh.material = new MeshStandardMaterial({ - color: 0x0000ff - }) - } else if (highlighted) { - mesh.material = new MeshStandardMaterial({ - color: 0xff0000 - }) - } else if (marked) { - mesh.material = new MeshStandardMaterial({ - color: 0x00ff00 - }) - } else { - mesh.material = new MeshStandardMaterial({ - color: 0xffffff, transparent: true, opacity: 0.25 - }) + if (mesh.material instanceof MeshStandardMaterial && !mesh.material.wireframe) { + if (highlighted && marked) { + mesh.material = new MeshStandardMaterial({ + color: 0x0000ff + }) + } else if (highlighted) { + mesh.material = new MeshStandardMaterial({ + color: 0xff0000 + }) + } else if (marked) { + mesh.material = new MeshStandardMaterial({ + color: 0x00ff00 + }) + } else { + mesh.material = new MeshStandardMaterial({ + color: 0xffffff, transparent: true, opacity: 0.25 + }) + } } } // Process children @@ -154,7 +156,9 @@ export class ModelView3D extends React.Component { const copy = material.clone() if (copy instanceof MeshStandardMaterial) { const standard = copy as MeshStandardMaterial - standard.emissive.setScalar(0.1) + if (!standard.wireframe) { + standard.emissive.setScalar(0.1) + } } array.push(copy) } @@ -163,7 +167,9 @@ export class ModelView3D extends React.Component { const copy = mesh.material.clone() if (copy instanceof MeshStandardMaterial) { const standard = copy as MeshStandardMaterial - standard.emissive.setScalar(0.1) + if (!standard.wireframe) { + standard.emissive.setScalar(0.1) + } } mesh.material = copy } diff --git a/packages/frontend/src/scripts/loaders/fcstd.ts b/packages/frontend/src/scripts/loaders/fcstd.ts index d07c893e..ef6760e4 100644 --- a/packages/frontend/src/scripts/loaders/fcstd.ts +++ b/packages/frontend/src/scripts/loaders/fcstd.ts @@ -1,10 +1,11 @@ -import { TextWriter, Uint8ArrayWriter, ZipReader } from '@zip.js/zip.js' +import { BlobReader, TextWriter, Uint8ArrayWriter, ZipReader } from '@zip.js/zip.js' import initOpenCascade, { OpenCascadeInstance } from 'opencascade.js' import { Color, Group, Mesh, MeshStandardMaterial, Object3D } from 'three' import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader' import { BRep, parseBRep } from './brep' import { parseGLTFModel } from './gltf' +import { CacheAPI } from '../clients/cache' let OCCT: Promise @@ -60,8 +61,8 @@ export class FreeCADObject { } export async function loadFCStdModel(path: string) { - console.log('Not yet implemented!', path) - return new Group() + const file = await CacheAPI.loadFile(path) + return parseFCStdModel(new BlobReader(new Blob([file]))) } function traverse(object: Object3D, material: MeshStandardMaterial) { @@ -73,7 +74,7 @@ function traverse(object: Object3D, material: MeshStandardMaterial) { } } -export async function parseFCStdModel(data: ReadableStream) { +export async function parseFCStdModel(data: ReadableStream | BlobReader) { const diffuse: {[name: string]: MeshStandardMaterial[]} = {} const breps: {[name: string]: BRep} = {} const gltfs: {[name: string]: GLTF} = {}