Skip to content

Commit 91a7298

Browse files
committed
Refactoring
1 parent 15215f4 commit 91a7298

File tree

7 files changed

+70
-82
lines changed

7 files changed

+70
-82
lines changed

README.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,42 @@ Currently:
2323
- GLTF (triangles only)
2424

2525
## Roadmap
26-
- [x] Grid in the background
27-
- [x] Translucent models to see wirefame in the background
28-
- [x] Snap vertices
29-
- [x] Translation - scale - rotate
30-
- [x] Split models
31-
- [x] Hide models
32-
- [x] Delete model
33-
- [x] Loading SHP - *needs our own library to load, noone supports multipatch*
34-
- [x] BVH build into worker
35-
- [x] Loading screen + Add chicken
36-
- [x] Add React Context
37-
- [x] Tabs in sidepanel
38-
- [x] Redesign
39-
- [x] Sidepanel view settings
40-
- [x] Intro screen
41-
- [x] Selecting alignment for loaded models
42-
- [x] Worker pool for loading
43-
- [x] Status - counter, update global loading status
44-
- [x] Reading metadata from IFC files - inspeciton of metadata?
45-
- [x] CI na githubu autodeploy
46-
47-
### Short term
48-
- [ ] Loading points and lines from SHP
49-
- [ ] Loading GeoJSON
50-
- [ ] Project export
51-
- [ ] Project import
52-
- [ ] Allow labeling geometry
53-
- [ ] Uniforms copy on model add
54-
- [ ] Rotate Splash screen bug
26+
27+
- [x] Grid in the background
28+
- [x] Translucent models to see wirefame in the background
29+
- [x] Snap vertices
30+
- [x] Translation - scale - rotate
31+
- [x] Split models
32+
- [x] Hide models
33+
- [x] Delete model
34+
- [x] Loading SHP - _needs our own library to load, noone supports multipatch_
35+
- [x] BVH build into worker
36+
- [x] Loading screen + Add chicken
37+
- [x] Add React Context
38+
- [x] Tabs in sidepanel
39+
- [x] Redesign
40+
- [x] Sidepanel view settings
41+
- [x] Intro screen
42+
- [x] Selecting alignment for loaded models
43+
- [x] Worker pool for loading
44+
- [x] Status - counter, update global loading status
45+
- [x] Reading metadata from IFC files - inspeciton of metadata?
46+
- [x] CI na githubu autodeploy
47+
- [x] Uniforms copy on model add
48+
- [x] Rotate Splash screen bug
49+
- [ ] Loading points and lines from SHP
50+
- [ ] Loading GeoJSON
51+
- [ ] Project export
52+
- [ ] Project import
53+
- [ ] Allow labeling geometry
54+
- [ ] delete selected submodel
55+
- [ ] merge submodels
5556

5657
### Backlog
57-
- [ ] IFC metadata loading (memory-efficiency???)
58-
- [ ] BVH
59-
- [ ] remesh models - intersection of triangles
60-
- [ ] delete submodel - *for now as (split + delete)*
61-
- [ ] frustum culling
62-
- [ ] rectangular select
58+
59+
- [ ] IFC metadata loading (memory-efficiency???)
60+
- [ ] BVH
61+
- [ ] remesh models - intersection of triangles
62+
- [ ] delete submodel - _for now as (split + delete)_
63+
- [ ] frustum culling
64+
- [ ] rectangular select

src/Components/Editor/SidePanel/PanelViewSettings/Widgets/CameraGround.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ export function CameraGroundWidget() {
1313
if (!ctx) return null;
1414
const { renderer, activeView, camTargetZ, setCamTargetZ } = ctx;
1515

16-
const [upShortcut, setUpShortcut] = React.useState<GL.ShortcutOnPress>(
17-
new GL.ShortcutOnPress('ArrowUp', () => {})
18-
);
19-
const [downShortcut, setDownShortcut] = React.useState<GL.ShortcutOnPress>(
20-
new GL.ShortcutOnPress('ArrowDown', () => {})
21-
);
22-
2316
const updateCamTargetZ = (value: number) => {
2417
if (isNaN(value)) return;
2518

@@ -28,24 +21,6 @@ export function CameraGroundWidget() {
2821
setCamTargetZ(value);
2922
};
3023

31-
React.useEffect(() => {
32-
renderer.onInit = () => {
33-
const controls = renderer.window.controls;
34-
controls.addShortcut(upShortcut);
35-
controls.addShortcut(downShortcut);
36-
};
37-
}, []);
38-
39-
React.useEffect(() => {
40-
upShortcut.onTrigger = (view) => {
41-
updateCamTargetZ(camTargetZ + 1);
42-
};
43-
44-
downShortcut.onTrigger = (view) => {
45-
updateCamTargetZ(camTargetZ - 1);
46-
};
47-
}, [camTargetZ]);
48-
4924
return (
5025
<DetailWidget>
5126
<WidgetLine>

src/Utils/models/models/TriangleModel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class TriangleModel extends EditorModel {
1717
}
1818

1919
export async function addTriangleModel(model: ModelData, ctx: EditorModelData) {
20-
let { coordMode, globalShift, position, rotation, scale, selection, scene } = ctx;
20+
let { coordMode, globalShift, position, rotation, scale, selection, scene, uniforms } = ctx;
2121

2222
position = position || vec3.create();
2323
rotation = rotation || vec3.create();
@@ -56,8 +56,8 @@ export async function addTriangleModel(model: ModelData, ctx: EditorModelData) {
5656
glmodel.wireframeShader = wireframeShader;
5757
glmodel.data = model.metadata.data;
5858
glmodel.name = model.metadata.name;
59-
//glmodel.uniforms = uniforms || DEFAULT_UNIFORMS; //TODO fix this, needs deep copy of the uniforms
60-
glmodel.uniforms = DEFAULT_UNIFORMS;
59+
if (uniforms) glmodel.uniforms = GL.cloneUniforms(uniforms);
60+
else glmodel.uniforms = DEFAULT_UNIFORMS;
6161
glmodel.position = position.slice() as vec3;
6262
glmodel.rotation = rotation.slice() as vec3;
6363
glmodel.scale = scale.slice() as vec3;

src/bananagl/bananagl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Renderer } from './renderer/renderer';
1212
import { mountRenderer, unmountRenderer } from './renderer/setup';
1313
import { Scene } from './scene/scene';
1414
import { Selection, SelectionManager } from './scene/selection';
15+
import { cloneUniforms } from './shaders/clone';
1516
import { Shader } from './shaders/shader';
1617
import { Profiler } from './utils/profiler';
1718
import { Shortcut, ShortcutOnMouseMove, ShortcutOnPress } from './window/shortcuts';
@@ -41,6 +42,7 @@ export {
4142
ShortcutOnMouseMove,
4243
mountRenderer,
4344
unmountRenderer,
45+
cloneUniforms,
4446
};
4547

4648
export type { Selectable, Shortcut };

src/bananagl/shaders/clone.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { UniformValue } from './shader';
2+
3+
function isArray(a: any): a is any[] {
4+
return Array.isArray(a);
5+
}
6+
7+
export function cloneValue(value: UniformValue) {
8+
//TODO optimize this to prevent reallocation
9+
if (isArray(value)) return value.slice();
10+
if (value instanceof Float32Array) return new Float32Array(value);
11+
if (value instanceof Int32Array) return new Int32Array(value);
12+
if (value instanceof Int16Array) return new Int16Array(value);
13+
if (value instanceof Int8Array) return new Int8Array(value);
14+
if (value instanceof Uint32Array) return new Uint32Array(value);
15+
if (value instanceof Uint16Array) return new Uint16Array(value);
16+
if (value instanceof Uint8Array) return new Uint8Array(value);
17+
return value;
18+
}
19+
20+
export function cloneUniforms(uniforms: { [name: string]: UniformValue }) {
21+
const clone: { [name: string]: UniformValue } = {};
22+
for (const name in uniforms) {
23+
const value = uniforms[name];
24+
clone[name] = cloneValue(value);
25+
}
26+
return clone;
27+
}

src/bananagl/shaders/shader.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import equal from 'fast-deep-equal/es6';
22

3+
import { cloneValue } from './clone';
34
import { handleErrors } from './errors';
45

56
const VER = `#version 300 es
@@ -21,23 +22,6 @@ export type TypedArray =
2122

2223
export type UniformValue = number | number[] | boolean | boolean[] | TypedArray | null;
2324

24-
function isArray(a: any): a is any[] {
25-
return Array.isArray(a);
26-
}
27-
28-
function cloneValue(value: UniformValue) {
29-
//TODO optimize this to prevent reallocation
30-
if (isArray(value)) return value.slice();
31-
if (value instanceof Float32Array) return new Float32Array(value);
32-
if (value instanceof Int32Array) return new Int32Array(value);
33-
if (value instanceof Int16Array) return new Int16Array(value);
34-
if (value instanceof Int8Array) return new Int8Array(value);
35-
if (value instanceof Uint32Array) return new Uint32Array(value);
36-
if (value instanceof Uint16Array) return new Uint16Array(value);
37-
if (value instanceof Uint8Array) return new Uint8Array(value);
38-
return value;
39-
}
40-
4125
const ROW_MAJOR = false;
4226

4327
export class Shader {

src/bananagl/window/controls.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class WindowControls {
4949
removeShortcut(shortcut: Shortcut) {
5050
const index = this.shortcuts_.indexOf(shortcut);
5151
if (index >= 0) {
52-
//console.log('Shortcut removed', index, this.shortcuts_, shortcut);
5352
this.shortcuts_.splice(index, 1);
5453
} else {
5554
console.warn('Shortcut not found', this.shortcuts_, shortcut);
@@ -78,7 +77,6 @@ export class WindowControls {
7877
}
7978

8079
this.downTime_ = Date.now();
81-
//event.preventDefault();
8280
};
8381

8482
onMouseMove = (event: MouseEvent) => {

0 commit comments

Comments
 (0)