chore: Add draft full typing for x_ite

This makes all of the x_ite methods available to call from Civet/
  TypeScript -- for example, setBrowserOption, which is used to deal
  with the viewer navigation.

  Resolves #17.
This commit is contained in:
Glen Whitney 2023-09-10 18:45:18 -07:00
parent 6bcec494e2
commit 56fbc0a0e9
3 changed files with 2057 additions and 27 deletions

View File

@ -38,7 +38,15 @@ export interface AppletObject {
startSaveCallback(title: string, visibility: string, callbackAction: string): void;
initCAS(): void;
setErrorDialogsActive(flag: boolean): void;
setCoordSystem(xmin: number, xmax: number, ymin: number, ymax: number, zmin?: number, zmax?: number, yVertical?: boolean): void;
setCoordSystem(
xmin: number,
xmax: number,
ymin: number,
ymax: number,
zmin?: number,
zmax?: number,
yVertical?: boolean
): void;
reset(): void;
refreshViews(): void;
setVisible(objName: string, visible: boolean): void;
@ -249,32 +257,32 @@ export interface AppletObject {
}
export type AxisConfiguration = {
label: string | null,
unitLabel: string | null,
positiveAxis: boolean,
showNumbers: boolean,
tickStyle: number,
visible: boolean
}
label: string | null;
unitLabel: string | null;
positiveAxis: boolean;
showNumbers: boolean;
tickStyle: number;
visible: boolean;
};
export type AxesConfiguration = {
x: AxisConfiguration,
y: AxisConfiguration,
z: AxisConfiguration
}
x: AxisConfiguration;
y: AxisConfiguration;
z: AxisConfiguration;
};
export type GraphicsOptions = {
axesColor: string,
bgColor: string,
gridColor: string,
axes: AxesConfiguration,
grid: boolean,
gridDistance: {x: number | null, y: number | null},
gridType: number,
pointCapturing: number,
rightAngleStyle: number,
rulerType: number
}
axesColor: string;
bgColor: string;
gridColor: string;
axes: AxesConfiguration;
grid: boolean;
gridDistance: { x: number | null; y: number | null };
gridType: number;
pointCapturing: number;
rightAngleStyle: number;
rulerType: number;
};
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;

2025
etc/deps/x_ite.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,11 @@ X3D from https://create3000.github.io/code/x_ite/latest/x_ite.mjs
certainlyHandled := '.x3d .gltf .glb .obj .stl .ply'.split ' '
canvas := X3D.createBrowser()
browser := X3D.getBrowser canvas
browser.setBrowserOption 'StraightenHorizon', false
site := $('a[href^="http"]')
url := site.attr('href') ?? ''
if certainlyHandled.some((ext) => url.includes ext)
canvas.setAttribute 'src', url
else if url.includes '.wrl'
@ -14,7 +17,7 @@ else if url.includes '.wrl'
text .= await response.text()
if /#\s*VRML\s*V?1./i.test(text)
text = convert(text)
browser := X3D.getBrowser canvas
scene := await browser.createX3DFromString text
browser.replaceWorld(scene)
site.after(canvas)