Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI refresh #155

Merged
merged 33 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
181437c
added bottom toolbar
slimbuck Jul 26, 2024
f9b6083
added right toolbar
slimbuck Jul 26, 2024
35232ea
add top menu
slimbuck Jul 26, 2024
cc034ed
added transform panel
slimbuck Jul 26, 2024
343639f
scene panel working
slimbuck Jul 29, 2024
6775db2
add logo svg
slimbuck Jul 29, 2024
a78423e
added view options pane
slimbuck Jul 30, 2024
1f66fc4
remove picker selection tool and already-migrated bits from control-p…
slimbuck Jul 30, 2024
7a26ad3
completely migrate and remove old toolbar
slimbuck Jul 30, 2024
4b9eda9
tweaks
slimbuck Jul 30, 2024
5665f6f
get focus working
slimbuck Jul 30, 2024
6b7b837
added initial menu panel
slimbuck Jul 31, 2024
0f3d333
bump package version
slimbuck Jul 31, 2024
4f1646e
menu styling, move app lable
slimbuck Jul 31, 2024
01e87db
move selection items from control panel to menu
slimbuck Aug 1, 2024
48919a1
move all data toggle to menu
slimbuck Aug 1, 2024
0e98ad0
support disabled menu items
slimbuck Aug 1, 2024
28664dc
added sphere tool
slimbuck Aug 2, 2024
65cb584
remove control panel
slimbuck Aug 2, 2024
3a1dae4
fix popup stying, support loading multiple ply
slimbuck Aug 5, 2024
fd23da6
grid sphere shape
slimbuck Aug 5, 2024
44e0be4
lint
slimbuck Aug 5, 2024
0618125
disable select globally, update sphere visual, add css autoprefixer
slimbuck Aug 6, 2024
418f86d
revert to eslint 8
slimbuck Aug 6, 2024
054dccd
add menu icons, update svg
slimbuck Aug 6, 2024
fa4b714
remove unused tools, integrate final splat list icons
slimbuck Aug 6, 2024
f48d4f3
small panel footer update
slimbuck Aug 6, 2024
9da8306
add about popup
slimbuck Aug 6, 2024
b6e3c5d
sphere selection bugfix and dbl click to place, popup styling
slimbuck Aug 7, 2024
4302b2a
styling, open pc site on icon click
slimbuck Aug 7, 2024
b173d7d
add model toggel
slimbuck Aug 7, 2024
44072a9
v1.0.0
slimbuck Aug 7, 2024
80e6cc4
final tweaks
slimbuck Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,254 changes: 629 additions & 625 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supersplat",
"version": "0.25.2",
"version": "1.0.0",
"author": "PlayCanvas<[email protected]>",
"homepage": "https://playcanvas.com/supersplat/editor",
"description": "3D Gaussian Splat Editor",
Expand Down Expand Up @@ -51,7 +51,7 @@
"test": "jest"
},
"devDependencies": {
"@playcanvas/eslint-config": "^1.7.1",
"@playcanvas/eslint-config": "^1.7.4",
"@playcanvas/pcui": "^4.4.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-image": "^3.0.3",
Expand All @@ -63,13 +63,15 @@
"@types/wicg-file-system-access": "^2023.10.5",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"autoprefixer": "^10.4.20",
"concurrently": "^8.2.2",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"playcanvas": "^1.73.1",
"rollup": "^4.18.0",
"playcanvas": "^1.73.4",
"postcss": "^8.4.41",
"rollup": "^4.20.0",
"rollup-plugin-sass": "^1.13.0",
"rollup-plugin-visualizer": "^5.12.0",
"serve": "^14.2.3",
Expand Down
14 changes: 11 additions & 3 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import resolve from '@rollup/plugin-node-resolve';
import strip from '@rollup/plugin-strip';
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import sass from 'rollup-plugin-sass';
// import { visualizer } from 'rollup-plugin-visualizer';

import autoprefixer from 'autoprefixer';
import postcss from 'postcss';
import sass from 'rollup-plugin-sass';

// prod is release build
if (process.env.BUILD_TYPE === 'prod') {
process.env.BUILD_TYPE = 'release';
Expand Down Expand Up @@ -63,10 +66,15 @@ const application = {
}),
alias({entries: aliasEntries}),
resolve(),
image({dom: true}),
image({dom: false}),
sass({
output: false,
insert: true
insert: true,
processor: (css) => {
return postcss([autoprefixer])
.process(css)
.then(result => result.css);
}
}),
json(),
typescript({
Expand Down
2 changes: 1 addition & 1 deletion src/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class Camera extends Element {

const device = this.scene.graphicsDevice as WebglGraphicsDevice;
const events = this.scene.events;
const alpha = events.invoke('camera.mode') === 'rings' ? 0.0 : 0.2;
const alpha = events.invoke('camera.debug') && events.invoke('camera.mode') === 'rings' ? 0.0 : 0.2;

// hide non-selected elements
const splats = this.scene.getElementsByType(ElementType.splat);
Expand Down
4 changes: 3 additions & 1 deletion src/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ class PointerController {
};

const dblclick = (event: globalThis.MouseEvent) => {
camera.pickFocalPoint(event.offsetX, event.offsetY);
if (event.target === target) {
camera.pickFocalPoint(event.offsetX, event.offsetY);
}
};

// key state
Expand Down
167 changes: 103 additions & 64 deletions src/editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
BoundingBox,
Color,
Mat4,
Vec3,
Vec4,
Expand Down Expand Up @@ -30,41 +29,6 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
return selected?.visible ? [selected] : [];
};

const debugSphereCenter = new Vec3();
let debugSphereRadius = 0;

const debugPlane = new Vec3();
let debugPlaneDistance = 0;

// draw debug mesh instances
events.on('prerender', () => {
const app = scene.app;

if (debugSphereRadius > 0) {
app.drawWireSphere(debugSphereCenter, debugSphereRadius, Color.RED, 40);
}

if (debugPlane.length() > 0) {
vec.copy(debugPlane).mulScalar(debugPlaneDistance);
vec2.add2(vec, debugPlane);

mat.setLookAt(vec, vec2, Math.abs(Vec3.UP.dot(debugPlane)) > 0.99 ? Vec3.FORWARD : Vec3.UP);

const lines = [
new Vec3(-1,-1, 0), new Vec3( 1,-1, 0),
new Vec3( 1,-1, 0), new Vec3( 1, 1, 0),
new Vec3( 1, 1, 0), new Vec3(-1, 1, 0),
new Vec3(-1, 1, 0), new Vec3(-1,-1, 0),
new Vec3( 0, 0, 0), new Vec3( 0, 0,-1)
];
for (let i = 0; i < lines.length; ++i) {
mat.transformPoint(lines[i], lines[i]);
}

app.drawLines(lines, Color.RED);
}
});

const processSelection = (state: Uint8Array, op: string, pred: (i: number) => boolean) => {
for (let i = 0; i < state.length; ++i) {
if (state[i] & (State.deleted | State.hidden)) {
Expand Down Expand Up @@ -94,7 +58,7 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S

// add unsaved changes warning message.
window.addEventListener("beforeunload", function (e) {
if (editHistory.cursor === lastExportCursor) {
if (!events.invoke('scene.dirty')) {
// if the undo cursor matches last export, then we have no unsaved changes
return undefined;
}
Expand All @@ -104,6 +68,10 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
return msg;
});

events.function('scene.dirty', () => {
return editHistory.cursor !== lastExportCursor;
});

events.on('scene.saved', () => {
lastExportCursor = editHistory.cursor;
});
Expand All @@ -112,24 +80,31 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
scene.forceRender = true;
});

events.on('splatSize', () => {
events.on('camera.debug', () => {
scene.forceRender = true;
});

events.on('show.gridOn', () => {
scene.grid.visible = true;
events.on('camera.splatSize', () => {
scene.forceRender = true;
});

events.on('show.gridOff', () => {
scene.grid.visible = false;
const setGridVisible = (visible: boolean) => {
if (visible !== scene.grid.visible) {
scene.grid.visible = visible;
events.fire('grid.visible', visible);
}
};

events.function('grid.visible', () => {
return scene.grid.visible;
});

events.on('show.gridToggle', () => {
scene.grid.visible = !scene.grid.visible;
events.on('grid.toggleVisible', () => {
setGridVisible(!scene.grid.visible);
});

events.function('show.grid', () => {
return scene.grid.visible;
events.on('grid.setVisible', (visible: boolean) => {
setGridVisible(visible);
});

events.on('camera.focus', () => {
Expand Down Expand Up @@ -208,20 +183,6 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
});
});

events.on('select.bySpherePlacement', (sphere: number[]) => {
debugSphereCenter.set(sphere[0], sphere[1], sphere[2]);
debugSphereRadius = sphere[3];

scene.forceRender = true;
});

events.on('select.byPlanePlacement', (axis: number[], distance: number) => {
debugPlane.set(axis[0], axis[1], axis[2]);
debugPlaneDistance = distance;

scene.forceRender = true;
});

events.on('select.bySphere', (op: string, sphere: number[]) => {
selectedSplats().forEach((splat) => {
const splatData = splat.splatData;
Expand All @@ -230,7 +191,9 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
const y = splatData.getProp('y');
const z = splatData.getProp('z');

const radius2 = sphere[3] * sphere[3];
splat.worldTransform.getScale(vec);

const radius2 = (sphere[3] / vec.x) ** 2;
vec.set(sphere[0], sphere[1], sphere[2]);

mat.invert(splat.worldTransform);
Expand Down Expand Up @@ -405,7 +368,7 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
const y = splatData.getProp('y');
const z = splatData.getProp('z');

const splatSize = events.invoke('splatSize');
const splatSize = events.invoke('camera.splatSize');
const camera = scene.camera.entity.camera;
const sx = point.x * width;
const sy = point.y * height;
Expand Down Expand Up @@ -478,8 +441,84 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
});
});

events.on('allData', (value: boolean) => {
scene.assetLoader.loadAllData = value;
const setAllData = (value: boolean) => {
if (value !== scene.assetLoader.loadAllData) {
scene.assetLoader.loadAllData = value;
events.fire('allData', scene.assetLoader.loadAllData);
}
};

events.function('allData', () => {
return scene.assetLoader.loadAllData;
});

events.on('toggleAllData', (value: boolean) => {
setAllData(!events.invoke('allData'));
});

// camera mode

let activeMode = 'centers';

const setCameraMode = (mode: string) => {
if (mode !== activeMode) {
activeMode = mode;
events.fire('camera.mode', activeMode);
}
};

events.function('camera.mode', () => {
return activeMode;
});

events.on('camera.setMode', (mode: string) => {
setCameraMode(mode);
});

events.on('camera.toggleMode', () => {
setCameraMode(events.invoke('camera.mode') === 'centers' ? 'rings' : 'centers');
});

// camera debug

let cameraDebug = true;

const setCameraDebug = (enabled: boolean) => {
if (enabled !== cameraDebug) {
cameraDebug = enabled;
events.fire('camera.debug', cameraDebug);
}
};

events.function('camera.debug', () => {
return cameraDebug;
});

events.on('camera.setDebug', (value: boolean) => {
setCameraDebug(value);
});

events.on('camera.toggleDebug', () => {
setCameraDebug(!events.invoke('camera.debug'));
});

// splat size

let splatSize = 2;

const setSplatSize = (value: number) => {
if (value !== splatSize) {
splatSize = value;
events.fire('camera.splatSize', splatSize);
}
};

events.function('camera.splatSize', () => {
return splatSize;
});

events.on('camera.setSplatSize', (value: number) => {
setSplatSize(value);
});
}

Expand Down
Loading
Loading