Skip to content

Commit

Permalink
Merge branch 'main' into transform-controls
Browse files Browse the repository at this point in the history
  • Loading branch information
arjxn-py authored Nov 3, 2024
2 parents 8301256 + 2d78f0b commit 9f6000e
Show file tree
Hide file tree
Showing 43 changed files with 816 additions and 428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/comment-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: 'Comment galata link on workflow'
uses: trungleduc/appsharingspace-pr-comment/.github/actions/pr-comment@v2
with:
comment_prefix: '**Integration tests repot:**'
comment_prefix: '**Integration tests report:**'
artifact_name: galata-apss
github_token: ${{ secrets.github_token }}
index_path: playwright-report/index.html
50 changes: 48 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,54 @@ pip install jupytercad-freecad

<!-- <START NEW CHANGELOG ENTRY> -->

## 3.0.0a5

([Full Changelog](https://github.com/jupytercad/JupyterCAD/compare/v3.0.0a4...8d0b77fa32ef01ed2b3d7f1d6f806aef3577c18f))

### Enhancements made

- Improve selection logic [#542](https://github.com/jupytercad/JupyterCAD/pull/542) ([@martinRenou](https://github.com/martinRenou))
- Object properties panel: Use selected object name as the title [#540](https://github.com/jupytercad/JupyterCAD/pull/540) ([@martinRenou](https://github.com/martinRenou))
- ClipPlane: fix z-fighting artifacts [#539](https://github.com/jupytercad/JupyterCAD/pull/539) ([@martinRenou](https://github.com/martinRenou))
- Set visible back to True for operator inputs upon removal of the output [#534](https://github.com/jupytercad/JupyterCAD/pull/534) ([@martinRenou](https://github.com/martinRenou))
- Allow opening JupyterCAD documents with the JSON viewer + Allow opening STL and STEP in JupyterLite [#531](https://github.com/jupytercad/JupyterCAD/pull/531) ([@martinRenou](https://github.com/martinRenou))
- Grey icon in tabs [#527](https://github.com/jupytercad/JupyterCAD/pull/527) ([@martinRenou](https://github.com/martinRenou))
- Reorder toolbar icons [#522](https://github.com/jupytercad/JupyterCAD/pull/522) ([@arjxn-py](https://github.com/arjxn-py))
- Update main logo [#520](https://github.com/jupytercad/JupyterCAD/pull/520) ([@martinRenou](https://github.com/martinRenou))
- JupyterCAD icons to left and right tabs [#519](https://github.com/jupytercad/JupyterCAD/pull/519) ([@martinRenou](https://github.com/martinRenou))

### Bugs fixed

- Re-add `setColor` api [#552](https://github.com/jupytercad/JupyterCAD/pull/552) ([@arjxn-py](https://github.com/arjxn-py))
- Prevent getting back to non-wireframe after operator [#549](https://github.com/jupytercad/JupyterCAD/pull/549) ([@arjxn-py](https://github.com/arjxn-py))
- Fix ui issues [#548](https://github.com/jupytercad/JupyterCAD/pull/548) ([@trungleduc](https://github.com/trungleduc))
- Fix clip plane controls when switching camera projection [#538](https://github.com/jupytercad/JupyterCAD/pull/538) ([@martinRenou](https://github.com/martinRenou))
- Revert "Orthographic camera: fix missing near and far parameters" [#536](https://github.com/jupytercad/JupyterCAD/pull/536) ([@martinRenou](https://github.com/martinRenou))
- Fix context switching for the right panel [#533](https://github.com/jupytercad/JupyterCAD/pull/533) ([@martinRenou](https://github.com/martinRenou))
- Update CAD app to include missing collaboration tokens [#530](https://github.com/jupytercad/JupyterCAD/pull/530) ([@martinRenou](https://github.com/martinRenou))
- Set collaborative attribute to False in Jupyterlite [#525](https://github.com/jupytercad/JupyterCAD/pull/525) ([@martinRenou](https://github.com/martinRenou))
- Cleanup and fix SVG logo [#523](https://github.com/jupytercad/JupyterCAD/pull/523) ([@martinRenou](https://github.com/martinRenou))
- Fix bounding box on exploded view [#521](https://github.com/jupytercad/JupyterCAD/pull/521) ([@arjxn-py](https://github.com/arjxn-py))
- Fix handling of theme change [#505](https://github.com/jupytercad/JupyterCAD/pull/505) ([@arjxn-py](https://github.com/arjxn-py))

### Maintenance and upkeep improvements

- Bump jupyter-collaboration v3 [#553](https://github.com/jupytercad/JupyterCAD/pull/553) ([@trungleduc](https://github.com/trungleduc))
- Unpin jupyterlite-xeus in lite build [#541](https://github.com/jupytercad/JupyterCAD/pull/541) ([@martinRenou](https://github.com/martinRenou))
- Pin Python in docs build [#528](https://github.com/jupytercad/JupyterCAD/pull/528) ([@martinRenou](https://github.com/martinRenou))

### Documentation improvements

- Pin Python in docs build [#528](https://github.com/jupytercad/JupyterCAD/pull/528) ([@martinRenou](https://github.com/martinRenou))

### Contributors to this release

([GitHub contributors page for this release](https://github.com/jupytercad/JupyterCAD/graphs/contributors?from=2024-10-21&to=2024-10-29&type=c))

[@arjxn-py](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Aarjxn-py+updated%3A2024-10-21..2024-10-29&type=Issues) | [@github-actions](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Agithub-actions+updated%3A2024-10-21..2024-10-29&type=Issues) | [@martinRenou](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3AmartinRenou+updated%3A2024-10-21..2024-10-29&type=Issues) | [@SylvainCorlay](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3ASylvainCorlay+updated%3A2024-10-21..2024-10-29&type=Issues) | [@trungleduc](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Atrungleduc+updated%3A2024-10-21..2024-10-29&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 3.0.0a4

([Full Changelog](https://github.com/jupytercad/JupyterCAD/compare/v3.0.0a3...b6be4f502cf89961d78cbd4afd96b36c0b65e102))
Expand Down Expand Up @@ -93,8 +141,6 @@ pip install jupytercad-freecad

[@arjxn-py](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Aarjxn-py+updated%3A2024-10-09..2024-10-21&type=Issues) | [@davidbrochart](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Adavidbrochart+updated%3A2024-10-09..2024-10-21&type=Issues) | [@github-actions](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Agithub-actions+updated%3A2024-10-09..2024-10-21&type=Issues) | [@IsabelParedes](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3AIsabelParedes+updated%3A2024-10-09..2024-10-21&type=Issues) | [@martinRenou](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3AmartinRenou+updated%3A2024-10-09..2024-10-21&type=Issues) | [@SylvainCorlay](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3ASylvainCorlay+updated%3A2024-10-09..2024-10-21&type=Issues) | [@trungleduc](https://github.com/search?q=repo%3Ajupytercad%2FJupyterCAD+involves%3Atrungleduc+updated%3A2024-10-09..2024-10-21&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 3.0.0a3

([Full Changelog](https://github.com/jupytercad/JupyterCAD/compare/@jupytercad/[email protected]))
Expand Down
12 changes: 11 additions & 1 deletion examples/Notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@
"metadata": {},
"outputs": [],
"source": [
"doc.add_cone().add_sphere(radius=0.8).cut()"
"doc.add_cone().add_sphere(radius=0.8).cut(color='#ff0000')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab3d7be6",
"metadata": {},
"outputs": [],
"source": [
"doc.set_color('Cut 1', '#00ff00')"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupytercad/jupytercad-root",
"version": "3.0.0-alpha.4",
"version": "3.0.0-alpha.5",
"private": true,
"homepage": "https://github.com/jupytercad/JupyterCAD",
"repository": {
Expand Down Expand Up @@ -52,8 +52,8 @@
"build:app": "lerna run --ignore @jupytercad/jupytercad-lab build"
},
"resolutions": {
"@jupyter/collaboration": "^3.0.0-rc.1",
"@jupyter/ydoc": "^3.0.0-b0",
"@jupyter/collaboration": "^3.0.0",
"@jupyter/ydoc": "^3.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@lumino/coreutils": "^2.0.0",
"@jupyterlab/notebook": "^4.0.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupytercad/base",
"version": "3.0.0-alpha.4",
"version": "3.0.0-alpha.5",
"description": "A JupyterLab extension for 3D modelling.",
"keywords": [
"jupyter",
Expand Down Expand Up @@ -36,10 +36,10 @@
},
"dependencies": {
"@deathbeds/jupyterlab-rjsf": "^1.1.0",
"@jupyter/collaborative-drive": "^3.0.0-rc.1",
"@jupyter/ydoc": "^3.0.0-b0",
"@jupytercad/occ-worker": "^3.0.0-alpha.4",
"@jupytercad/schema": "^3.0.0-alpha.4",
"@jupyter/collaborative-drive": "^3.0.0",
"@jupyter/ydoc": "^3.0.0",
"@jupytercad/occ-worker": "^3.0.0-alpha.5",
"@jupytercad/schema": "^3.0.0-alpha.5",
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@jupyterlab/completer": "^4.2.4",
Expand Down
21 changes: 19 additions & 2 deletions packages/base/src/3dview/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ export function buildShape(options: {
clippingPlanes: THREE.Plane[];
selected: boolean;
isSolid: boolean;
isWireframe: boolean;
objColor?: THREE.Color | string | number;
}): {
meshGroup: THREE.Group;
mainMesh: THREE.Mesh<THREE.BufferGeometry, THREE.MeshStandardMaterial>;
edgesMeshes: LineSegments2[];
} | null {
const { objName, data, isSolid, clippingPlanes, objColor } = options;
const { objName, data, isSolid, isWireframe, clippingPlanes, objColor } =
options;
const { faceList, edgeList, jcObject } = data;

const vertices: Array<number> = [];
Expand Down Expand Up @@ -158,7 +160,7 @@ export function buildShape(options: {
// it's too bad Three.js does not easily allow setting uniforms independently per-mesh
const material = new THREE.MeshStandardMaterial({
color: new THREE.Color(color),
wireframe: false,
wireframe: isWireframe,
flatShading: false,
clippingPlanes,
metalness: 0.5,
Expand Down Expand Up @@ -258,6 +260,21 @@ export function buildShape(options: {
edgeIdx++;
}

const bbox = new THREE.Box3().setFromObject(mainMesh);
const size = new THREE.Vector3();
bbox.getSize(size);
const center = new THREE.Vector3();
bbox.getCenter(center);

const boundingBox = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.BoxGeometry(size.x, size.y, size.z)),
new THREE.LineBasicMaterial({ color: BOUNDING_BOX_COLOR, depthTest: false })
);
boundingBox.position.copy(center);
boundingBox.visible = false;
boundingBox.name = SELECTION_BOUNDING_BOX;
meshGroup.add(boundingBox);

meshGroup.add(mainMesh);
mainMesh.position.copy(center);

Expand Down
75 changes: 27 additions & 48 deletions packages/base/src/3dview/mainview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ export class MainView extends React.Component<IProps, IStates> {
const selected = selectedNames.includes(objName);
const obj = this._model.sharedModel.getObjectByName(objName);
const objColor = obj?.parameters?.Color;
const isWireframe = this.state.wireframe;

// TODO Have a more generic way to spot non-solid objects
const isSolid = !(
Expand All @@ -720,6 +721,7 @@ export class MainView extends React.Component<IProps, IStates> {
clippingPlanes: this._clippingPlanes,
selected,
isSolid,
isWireframe,
objColor
});

Expand Down Expand Up @@ -967,6 +969,12 @@ export class MainView extends React.Component<IProps, IStates> {
this._objToMesh(objName, postResult as any);
});
}

const localState = this._model.localState;

if (localState?.selected?.value) {
this._updateSelected(localState.selected.value);
}
}

private _updatePointersScale(refLength): void {
Expand Down Expand Up @@ -1043,11 +1051,14 @@ export class MainView extends React.Component<IProps, IStates> {
selectedMesh.material.color = originalColor;
}

const groupBoundingBox = this._meshGroup?.getObjectByName(
const parentGroup = this._meshGroup?.getObjectByName(
selectedMesh.name
)?.parent;
const boundingBox = parentGroup?.getObjectByName(
SELECTION_BOUNDING_BOX
);
if (groupBoundingBox) {
this._meshGroup?.remove(groupBoundingBox);
) as THREE.Mesh;
if (boundingBox) {
boundingBox.visible = false;
}

const material = selectedMesh.material as THREE.Material & {
Expand All @@ -1072,6 +1083,10 @@ export class MainView extends React.Component<IProps, IStates> {
continue;
}

if (!selectedMesh.visible) {
continue;
}

if (selectedMesh.name.startsWith('edge')) {
// Highlight edges using the old method
if (!selectedMesh.userData.originalColor) {
Expand All @@ -1094,52 +1109,16 @@ export class MainView extends React.Component<IProps, IStates> {
// Highlight non-edges using a bounding box
this._selectedMeshes.push(selectedMesh);

// Create and add bounding box
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.LineBasicMaterial({
color: BOUNDING_BOX_COLOR,
depthTest: false
});
const boundingBox = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry),
material
);
boundingBox.name = SELECTION_BOUNDING_BOX;
const parentGroup = this._meshGroup?.getObjectByName(
selectedMesh.name
)?.parent;
const boundingBox = parentGroup?.getObjectByName(
SELECTION_BOUNDING_BOX
) as THREE.Mesh;

// Set the bounding box size and position
const bbox = new THREE.Box3().setFromObject(selectedMesh);
const size = new THREE.Vector3();
bbox.getSize(size);
boundingBox.scale.copy(size);

const center = new THREE.Vector3();
bbox.getCenter(center);
boundingBox.position.copy(center);

this._meshGroup?.add(boundingBox);

const matchingChild = this._meshGroup?.children.find(child =>
child.name.startsWith(selectedMesh.name)
);

if (matchingChild) {
this._transformControls.attach(matchingChild as BasicMesh);

this._transformControls.position.copy(selectedMesh.position);

this._transformControls.visible = true;
this._transformControls.enabled = true;
if (boundingBox) {
boundingBox.visible = true;
}
// if (this._selectedMeshes.length === 1) {
// const selectedMesh = this._selectedMeshes[0];

// const bbox = new THREE.Box3().setFromObject(selectedMesh);
// const center = new THREE.Vector3();
// bbox.getCenter(center);
// console.log(center);

// // this._transformControls.position.copy(center);
// }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/panelview/formbuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class ObjectPropertiesForm extends React.Component<IProps, IStates> {
className="jpcad-property-panel"
data-path={this.props.filePath ?? ''}
>
<div className="jpcad-property-outer">
<div className="jpcad-property-outer jp-scrollbar-tiny">
<LuminoSchemaForm>{formSchema}</LuminoSchemaForm>
</div>
<div className="jpcad-property-buttons">
Expand Down
23 changes: 12 additions & 11 deletions packages/base/src/panelview/leftpanel.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {
IAnnotationModel,
JupyterCadDoc,
IJupyterCadTracker
IJupyterCadTracker,
IJCadFormSchemaRegistry
} from '@jupytercad/schema';
import { SidePanel } from '@jupyterlab/ui-components';

import { IControlPanelModel } from '../types';
import { Annotations } from './annotations';
import { ControlPanelHeader } from './header';
import { ObjectTree } from './objecttree';
import { ObjectProperties } from './objectproperties';
import { AccordionPanel } from '@lumino/widgets';

export class LeftPanelWidget extends SidePanel {
constructor(options: LeftPanelWidget.IOptions) {
Expand All @@ -17,41 +18,41 @@ export class LeftPanelWidget extends SidePanel {
this.addClass('data-jcad-keybinding');
this.node.tabIndex = 0;
this._model = options.model;
this._annotationModel = options.annotationModel;
const header = new ControlPanelHeader();
this.header.addWidget(header);

const tree = new ObjectTree({ controlPanelModel: this._model });
this.addWidget(tree);

const annotations = new Annotations({ model: this._annotationModel });
this.addWidget(annotations);
const properties = new ObjectProperties({
controlPanelModel: this._model,
formSchemaRegistry: options.formSchemaRegistry,
tracker: options.tracker
});
this.addWidget(properties);

options.tracker.currentChanged.connect((_, changed) => {
if (changed) {
header.title.label = changed.context.localPath;
this._annotationModel.context =
options.tracker.currentWidget?.context || undefined;
} else {
header.title.label = '-';
this._annotationModel.context = undefined;
}
});
(this.content as AccordionPanel).setRelativeSizes([4, 6]);
}

dispose(): void {
super.dispose();
}

private _model: IControlPanelModel;
private _annotationModel: IAnnotationModel;
}

export namespace LeftPanelWidget {
export interface IOptions {
model: IControlPanelModel;
annotationModel: IAnnotationModel;
tracker: IJupyterCadTracker;
formSchemaRegistry: IJCadFormSchemaRegistry;
}

export interface IProps {
Expand Down
Loading

0 comments on commit 9f6000e

Please sign in to comment.