Skip to content

Commit

Permalink
2024/01/12 - Testing some debug settings
Browse files Browse the repository at this point in the history
  • Loading branch information
FadiShawki committed Jan 12, 2024
1 parent e275e25 commit 2a0fadf
Show file tree
Hide file tree
Showing 3 changed files with 299 additions and 214 deletions.
48 changes: 43 additions & 5 deletions src/@orbitmines/explorer/Ray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {NotImplementedError, PreventsImplementationBug} from "./errors/errors";
import {InterfaceOptions} from "./OrbitMinesExplorer";


// SHOULDNT CLASSIFY THESE?
// TODO: SHOULDNT CLASSIFY THESE?
export enum RayType {
// NONE = ' ',
REFERENCE = ' | ',
Expand Down Expand Up @@ -190,14 +190,14 @@ export class Ray // Other possibly names: AbstractDirectionality, ..., ??
throw new PreventsImplementationBug();
}
case RayType.VERTEX: {
const next_vertex = Ray.vertex(b.as_arbitrary()); // TODO: Could be a reference too, now just force as a next element
// const next_vertex = b; // TODO: Could be a reference too, now just force as a next element

if (this.is_none()) {
// 'Empty' vertex from this perspective.

this.vertex = next_vertex.as_arbitrary();
this.vertex = b.as_arbitrary();
console.log('first element');
return next_vertex.as_reference(); // TODO: Generally, return something which knows where all continuations are.
return b; // TODO: Generally, return something which knows where all continuations are.
}

switch (b.type) {
Expand All @@ -212,7 +212,45 @@ export class Ray // Other possibly names: AbstractDirectionality, ..., ??
}
}

return next_vertex.as_reference();
return b;
}
}
}

pop = (): Ray => {
switch (this.type) {
case RayType.REFERENCE: {
throw new PreventsImplementationBug();
}
case RayType.TERMINAL:
case RayType.INITIAL: {
throw new PreventsImplementationBug();
}
case RayType.VERTEX: {
const previous_vertex = this.self.initial.self.initial.as_reference();

if (this.is_none()) {
return this; // TODO; Already empty, perhaps throw
}

switch (previous_vertex.type) {
case RayType.REFERENCE: {
throw new PreventsImplementationBug();
}
case RayType.INITIAL: {
throw new PreventsImplementationBug();
}
case RayType.TERMINAL: {
throw new PreventsImplementationBug();
}
case RayType.VERTEX: {
console.log(previous_vertex)
// TODO: NONHACKY

previous_vertex.self.terminal = new Ray({ vertex: Ray.None, initial: previous_vertex.self.as_arbitrary() }).o({ debug: 'terminal ref'}).as_arbitrary()
return previous_vertex;
}
}
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions src/@orbitmines/explorer/debug/DebugCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import _ from "lodash";
// TODO: It's, rende rboth draw equivalence, then ignore the difference from either perspective or take some middle thing. - Line from both ends, also vertex? (or take the pos, take the x from one/other, y from the other/..)

// TODO: Could be a function on Ray (any func really)
const Render = ({ ray }: { ray: Ray }) => {
export const Render = ({ ray }: { ray: Ray }) => {
const initial: Required<InterfaceOptions> = ray.self.initial.as_reference().render_options;
const vertex: Required<InterfaceOptions> = ray.render_options;
const terminal: Required<InterfaceOptions> = ray.self.terminal.as_reference().render_options;
Expand Down Expand Up @@ -41,7 +41,7 @@ const Render = ({ ray }: { ray: Ray }) => {
}
}

const DebugInterface = ({ scale = 1.5 }: InterfaceOptions) => {
export const DebugInterface = ({ scale = 1.5 }: InterfaceOptions) => {
const ref = useRef<any>();
const hotkeyConfig = useHotkeys();

Expand All @@ -57,11 +57,13 @@ const DebugInterface = ({ scale = 1.5 }: InterfaceOptions) => {
const memory = true;

const [Interface] = useState<Ray>(Ray.vertex().o({
selection: Ray.vertex(() => Ray.vertex().o2({
initial: { position: [-space_between, 0, 0], scale, rotation: [0, 0, Math.PI / 2] },
vertex: { position: [0, 0, 0], scale, color: '#FF55FF' },
terminal: { position: [space_between, 0, 0 ], scale, rotation: [0, 0, Math.PI / 2] }
})).o2({
selection: Ray.vertex(
// () => Ray.vertex().o2({
// initial: { position: [-space_between, 0, 0], scale, rotation: [0, 0, Math.PI / 2] },
// vertex: { position: [0, 0, 0], scale, color: '#FF55FF' },
// terminal: { position: [space_between, 0, 0 ], scale, rotation: [0, 0, Math.PI / 2] }
// })
).o2({
initial: { position: [-space_between, 0, 0], scale },
vertex: { position: [0, 0, 0], scale, color: '#FF55FF' },
terminal: { position: [space_between, 0, 0 ], scale }
Expand Down Expand Up @@ -168,7 +170,7 @@ const DebugInterface = ({ scale = 1.5 }: InterfaceOptions) => {
</>
}

const StatsPanels = () => {
export const StatsPanels = () => {
const [_, forceUpdate] = useReducer((x) => !x, false);

const parent = useRef(document.createElement('div'));
Expand All @@ -192,7 +194,7 @@ const StatsPanels = () => {
</>
}

const DebugCanvas = (
export const DebugCanvas = (
{
listeners = [],
}: {
Expand Down
Loading

0 comments on commit 2a0fadf

Please sign in to comment.