From 7d16a1e11bc3d53be3e55dc3ed4e431209272c1e Mon Sep 17 00:00:00 2001 From: Dylan Hojnoski Date: Wed, 7 Aug 2024 20:33:52 -0400 Subject: [PATCH 1/6] added 3d view and 3d element support --- main.ts | 35 ++++++++++++++--------------------- src/types.ts | 13 ++++++++++++- src/utils.ts | 45 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 61 insertions(+), 32 deletions(-) diff --git a/main.ts b/main.ts index 3ca1636..d80c298 100644 --- a/main.ts +++ b/main.ts @@ -1,7 +1,7 @@ import { loadMathJax, Plugin } from 'obsidian'; -import { Board, boards, JSXGraph } from 'jsxgraph'; +import { JSXGraph } from 'jsxgraph'; import { renderError } from 'src/error'; -import { GraphInfo, JSXElement } from 'src/types'; +import { GraphInfo, Graph } from 'src/types'; import "./src/theme/obsidian.ts" import { DEFAULT_SETTINGS, ObsidianGraphsSettings, ObsidianGraphsSettingsTab } from 'src/settings'; import { Utils } from 'src/utils'; @@ -11,6 +11,7 @@ export default class ObsidianGraphs extends Plugin { currentFileName: string; count = 0; utils: Utils = new Utils(); + graphs: Graph[] = []; async onload () { await this.loadSettings(); @@ -45,11 +46,9 @@ export default class ObsidianGraphs extends Plugin { files.forEach((file) => activeFileNames.push(file.getDisplayText().replace(/\s/g, ""))); // go through all the boards and delete ones that are not in active files - //@ts-ignore - for (const key in boards) { + for (const graph of this.graphs) { let active = false; - //@ts-ignore - const div = boards[key].containerObj; + const div = graph.board.containerObj; // check the if it is in the active files for (const name of activeFileNames) { @@ -61,10 +60,8 @@ export default class ObsidianGraphs extends Plugin { // it is not in active files so delete if (!active) { - //@ts-ignore - boards[key].containerObj.remove(); - //@ts-ignore - JSXGraph.freeBoard(boards[key]); + graph.board.containerObj.remove(); + JSXGraph.freeBoard(graph.board); } } }); @@ -81,7 +78,7 @@ export default class ObsidianGraphs extends Plugin { return; } - let board: Board; + let graph: Graph; // if the current file name is undefined need to get the current file if (this.currentFileName == undefined) { @@ -99,19 +96,18 @@ export default class ObsidianGraphs extends Plugin { try { // create the board - board = this.utils.createBoard(graphDiv, graphInfo); + graph = this.utils.createBoard(graphDiv, graphInfo); + this.graphs.push(graph); } catch (e) { renderError(e,element); return; } - const createdElements: JSXElement[] = []; - if (graphInfo.elements != undefined) { // add every element to the graph for (let i = 0; i < graphInfo.elements.length; i++) { try { - this.utils.addElement(board, graphInfo.elements[i], createdElements); + this.utils.addElement(graph, graphInfo.elements[i]); } catch (e) { renderError(e,element); return; @@ -122,13 +118,10 @@ export default class ObsidianGraphs extends Plugin { } onunload() { - //@ts-ignore - for (const key in boards) { - //@ts-ignore - const div = boards[key].containerObj; + for (const graph of this.graphs) { + const div = graph.board.containerObj; - //@ts-ignore - JSXGraph.freeBoard(boards[key]); + JSXGraph.freeBoard(graph.board); div.remove(); } } diff --git a/src/types.ts b/src/types.ts index 49c4aa4..767209d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { GeometryElement } from "jsxgraph"; +import { Board, GeometryElement, View3D } from "jsxgraph"; export interface JSXElement { name: string, @@ -27,6 +27,17 @@ export interface GraphInfo { // plugin specific settings height: number | undefined, width: number | undefined, + bounds3d: [ + [ x1: number, y1: number ], + [ x2: number, y2: number ], + [ x3: number, y3: number ], + ] | undefined +} + +export interface Graph { + board: Board, + createdElements: JSXElement[], + view3d: View3D | undefined } export interface ElementInfo { diff --git a/src/utils.ts b/src/utils.ts index 082858d..eb264dc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,6 @@ -import { Board, JSXGraph, GeometryElement } from "jsxgraph"; +import { Board, JSXGraph, GeometryElement, View3D } from "jsxgraph"; import { parseYaml } from "obsidian"; -import { ElementInfo, GraphInfo, JSXElement, Types } from "./types"; +import { ElementInfo, Graph, GraphInfo, JSXElement, Types } from "./types"; export class Utils { argsArray: string[]; @@ -25,7 +25,8 @@ export class Utils { axis: true, defaultAxes: JXG.Options.board.defaultAxes, elements: [], height: undefined, - width: undefined}; + width: undefined, + bounds3d: undefined}; // there is nothing inside of the codeblock if (source == null || source == "") { @@ -61,7 +62,7 @@ export class Utils { } } - createBoard(graphDiv: HTMLElement, graphInfo: GraphInfo) :Board { + createBoard(graphDiv: HTMLElement, graphInfo: GraphInfo) : Graph { // make sure that the are defined if (graphInfo.bounds == undefined && graphInfo.elements == undefined && graphInfo.keepAspectRatio == undefined) { @@ -71,7 +72,7 @@ export class Utils { this.validateBounds(graphInfo.bounds); // create the board for the graph - const graph = JSXGraph.initBoard(graphDiv, {boundingBox: graphInfo.bounds, + const board = JSXGraph.initBoard(graphDiv, {boundingBox: graphInfo.bounds, maxBoundingBox: graphInfo.maxBoundingBox, drag: {enabled: graphInfo.drag}, axis: graphInfo.axis, @@ -80,6 +81,11 @@ export class Utils { //@ts-ignore theme: 'obsidian', keepAspectRatio: graphInfo.keepAspectRatio}); + const graph: Graph = { + board: board, + createdElements: [], + view3d: undefined + } if (graphInfo.height) { graphDiv.style.height = graphInfo.height + "px"; @@ -87,6 +93,13 @@ export class Utils { if (graphInfo.width) { graphDiv.style.maxWidth = graphInfo.width + "px"; } + if (graphInfo.bounds3d != undefined) { + const xLength = Math.abs(graphInfo.bounds[2]-graphInfo.bounds[0]); + const yLength = Math.abs(graphInfo.bounds[1]-graphInfo.bounds[3]); + const xMin = graphInfo.bounds[0] <= 0 ? graphInfo.bounds[0] + xLength*0.15 : graphInfo.bounds[0] - xLength*0.15; + const yMin = graphInfo.bounds[3] <= 0 ? graphInfo.bounds[3] + yLength*0.15 : graphInfo.bounds[3] - yLength*0.15; + graph.view3d = board.create("view3d",[[xMin, yMin], [xLength-xLength*0.3, yLength-yLength*0.3], graphInfo.bounds3d] ); + } return graph; } @@ -108,17 +121,29 @@ export class Utils { } } - addElement(board: Board, element: ElementInfo, createdElements: JSXElement[]) { - this.validateElement(element, createdElements); + addElement(graph: Graph, element: ElementInfo) { + this.validateElement(element, graph.createdElements); let createdElement: GeometryElement; + let createOn: Board | View3D = graph.board; + + if (element.type.contains("3d") ) { + if (graph.view3d != undefined) { + createOn = graph.view3d; + } + else { + throw new SyntaxError("Have to set 3d bounds to use 3d elements"); + } + } if (element.att == undefined) { - createdElement = board.create(element.type, element.def); + //@ts-ignore + createdElement = createOn.create(element.type, element.def); } else { - createdElement = board.create(element.type, element.def, element.att); + //@ts-ignore + createdElement = createOn.create(element.type, element.def, element.att); } - createdElements.push({name: element.type, element: createdElement}); + graph.createdElements.push({name: element.type, element: createdElement}); } private validateElement(element: ElementInfo, createdElements: JSXElement[]) { From 9bd39e8157a724c9a578ce8a070cf0910f0d1a54 Mon Sep 17 00:00:00 2001 From: Dylan Hojnoski Date: Wed, 7 Aug 2024 21:09:25 -0400 Subject: [PATCH 2/6] Added validation to 3d bounds --- main.ts | 27 ++++++++++++++++----------- src/utils.ts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/main.ts b/main.ts index d80c298..9425420 100644 --- a/main.ts +++ b/main.ts @@ -1,7 +1,7 @@ import { loadMathJax, Plugin } from 'obsidian'; -import { JSXGraph } from 'jsxgraph'; +import { Board, boards, JSXGraph } from 'jsxgraph'; import { renderError } from 'src/error'; -import { GraphInfo, Graph } from 'src/types'; +import { GraphInfo, JSXElement } from 'src/types'; import "./src/theme/obsidian.ts" import { DEFAULT_SETTINGS, ObsidianGraphsSettings, ObsidianGraphsSettingsTab } from 'src/settings'; import { Utils } from 'src/utils'; @@ -11,7 +11,6 @@ export default class ObsidianGraphs extends Plugin { currentFileName: string; count = 0; utils: Utils = new Utils(); - graphs: Graph[] = []; async onload () { await this.loadSettings(); @@ -46,9 +45,11 @@ export default class ObsidianGraphs extends Plugin { files.forEach((file) => activeFileNames.push(file.getDisplayText().replace(/\s/g, ""))); // go through all the boards and delete ones that are not in active files - for (const graph of this.graphs) { + //@ts-ignore + for (const key in boards) { let active = false; - const div = graph.board.containerObj; + //@ts-ignore + const div = boards[key].containerObj; // check the if it is in the active files for (const name of activeFileNames) { @@ -60,8 +61,10 @@ export default class ObsidianGraphs extends Plugin { // it is not in active files so delete if (!active) { - graph.board.containerObj.remove(); - JSXGraph.freeBoard(graph.board); + //@ts-ignore + boards[key].containerObj.remove(); + //@ts-ignore + JSXGraph.freeBoard(boards[key]); } } }); @@ -97,7 +100,6 @@ export default class ObsidianGraphs extends Plugin { try { // create the board graph = this.utils.createBoard(graphDiv, graphInfo); - this.graphs.push(graph); } catch (e) { renderError(e,element); return; @@ -118,10 +120,13 @@ export default class ObsidianGraphs extends Plugin { } onunload() { - for (const graph of this.graphs) { - const div = graph.board.containerObj; + //@ts-ignore + for (const key in boards) { + //@ts-ignore + const div = boards[key].containerObj; - JSXGraph.freeBoard(graph.board); + //@ts-ignore + JSXGraph.freeBoard(boards[key]); div.remove(); } } diff --git a/src/utils.ts b/src/utils.ts index eb264dc..527191f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -94,6 +94,7 @@ export class Utils { graphDiv.style.maxWidth = graphInfo.width + "px"; } if (graphInfo.bounds3d != undefined) { + this.validate3dBounds(graphInfo.bounds3d); const xLength = Math.abs(graphInfo.bounds[2]-graphInfo.bounds[0]); const yLength = Math.abs(graphInfo.bounds[1]-graphInfo.bounds[3]); const xMin = graphInfo.bounds[0] <= 0 ? graphInfo.bounds[0] + xLength*0.15 : graphInfo.bounds[0] - xLength*0.15; @@ -121,6 +122,21 @@ export class Utils { } } + private validate3dBounds(bounds: number[][]) { + if (bounds.length != 3) { + throw new SyntaxError("The amount of 3d bounds given is incorrect"); + } + + for (let i = 0; i < 3; i++) { + if (bounds[i].length != 2) { + throw new SyntaxError("The amount of 3d bounds given is incorrect"); + } + if (bounds[i][0] >= bounds[i][1]) { + throw new SyntaxError("The amount of 3d bounds given is incorrect"); + } + } + } + addElement(graph: Graph, element: ElementInfo) { this.validateElement(element, graph.createdElements); let createdElement: GeometryElement; From e33652fd490c2fb3b758ebef8f63c6f2ae292293 Mon Sep 17 00:00:00 2001 From: Dylan Hojnoski Date: Thu, 8 Aug 2024 21:06:16 -0400 Subject: [PATCH 3/6] Setup functional 3d view attributes --- main.ts | 4 +-- src/types.ts | 34 +++++++++++++++++++++++--- src/utils.ts | 69 +++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 83 insertions(+), 24 deletions(-) diff --git a/main.ts b/main.ts index 9425420..be56bee 100644 --- a/main.ts +++ b/main.ts @@ -1,7 +1,7 @@ import { loadMathJax, Plugin } from 'obsidian'; -import { Board, boards, JSXGraph } from 'jsxgraph'; +import { boards, JSXGraph } from 'jsxgraph'; import { renderError } from 'src/error'; -import { GraphInfo, JSXElement } from 'src/types'; +import { Graph, GraphInfo } from 'src/types'; import "./src/theme/obsidian.ts" import { DEFAULT_SETTINGS, ObsidianGraphsSettings, ObsidianGraphsSettingsTab } from 'src/settings'; import { Utils } from 'src/utils'; diff --git a/src/types.ts b/src/types.ts index 767209d..708d338 100644 --- a/src/types.ts +++ b/src/types.ts @@ -31,8 +31,36 @@ export interface GraphInfo { [ x1: number, y1: number ], [ x2: number, y2: number ], [ x3: number, y3: number ], - ] | undefined + ] | undefined, + att3d: Att3d | undefined, } + export interface Att3d { + axisPosition: string, + + xAxis: Attributes , + xPlaneFront: Attributes, + xPlaneFrontYAxis: Attributes, + xPlaneFrontZAxis: Attributes, + xPlaneRear: Attributes, + xPlaneRearYAxis: Attributes, + xPlaneRearZAxis: Attributes, + + yAxis: Attributes, + yPlaneFront: Attributes, + yPlaneFrontXAxis: Attributes, + yPlaneFrontZAxis: Attributes, + yPlaneRear: Attributes, + yPlaneRearXAxis: Attributes, + yPlaneRearZAxis: Attributes, + + zAxis: Attributes, + zPlaneFront: Attributes, + zPlaneFrontXAxis: Attributes, + zPlaneFrontYAxis: Attributes, + zPlaneRear: Attributes, + zPlaneRearXAxis: Attributes, + zPlaneRearYAxis: Attributes, + } export interface Graph { board: Board, @@ -43,10 +71,10 @@ export interface Graph { export interface ElementInfo { type: string, def: any[], - att: Attributes, + att: Attributes | Att3d | undefined, } -export type Attributes = { +export interface Attributes { name: string, inverse: boolean, chartStyle: string, diff --git a/src/utils.ts b/src/utils.ts index 527191f..4b916a2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,6 @@ -import { Board, JSXGraph, GeometryElement, View3D } from "jsxgraph"; +import { Board, JSXGraph, GeometryElement, View3D, elements } from "jsxgraph"; import { parseYaml } from "obsidian"; -import { ElementInfo, Graph, GraphInfo, JSXElement, Types } from "./types"; +import { Att3d, Attributes, ElementInfo, Graph, GraphInfo, JSXElement, Types } from "./types"; export class Utils { argsArray: string[]; @@ -26,7 +26,8 @@ export class Utils { elements: [], height: undefined, width: undefined, - bounds3d: undefined}; + bounds3d: undefined, + att3d: undefined}; // there is nothing inside of the codeblock if (source == null || source == "") { @@ -62,7 +63,7 @@ export class Utils { } } - createBoard(graphDiv: HTMLElement, graphInfo: GraphInfo) : Graph { + createBoard(graphDiv: HTMLElement, graphInfo: GraphInfo): Graph { // make sure that the are defined if (graphInfo.bounds == undefined && graphInfo.elements == undefined && graphInfo.keepAspectRatio == undefined) { @@ -95,11 +96,27 @@ export class Utils { } if (graphInfo.bounds3d != undefined) { this.validate3dBounds(graphInfo.bounds3d); + const xLength = Math.abs(graphInfo.bounds[2]-graphInfo.bounds[0]); const yLength = Math.abs(graphInfo.bounds[1]-graphInfo.bounds[3]); const xMin = graphInfo.bounds[0] <= 0 ? graphInfo.bounds[0] + xLength*0.15 : graphInfo.bounds[0] - xLength*0.15; const yMin = graphInfo.bounds[3] <= 0 ? graphInfo.bounds[3] + yLength*0.15 : graphInfo.bounds[3] - yLength*0.15; - graph.view3d = board.create("view3d",[[xMin, yMin], [xLength-xLength*0.3, yLength-yLength*0.3], graphInfo.bounds3d] ); + + const element: ElementInfo = { + type: "view3d", + def: [[xMin, yMin], [xLength-xLength*0.3, yLength-yLength*0.3], graphInfo.bounds3d], + att: graphInfo.att3d + } + + + if (graphInfo.att3d == undefined) { + graph.view3d = board.create("view3d", [[xMin, yMin], [xLength-xLength*0.3, yLength-yLength*0.3], graphInfo.bounds3d]) + } + else { + this.checkComposedAtts(graphInfo.att3d, graph.createdElements); + //@ts-ignore + graph.view3d = board.create(element.type, element.def, element.att); + } } return graph; @@ -174,7 +191,7 @@ export class Utils { } this.validateDef(element.def, createdElements); - this.validateAtt(element, createdElements); + this.checkComposedAtts(element.att as Attributes, createdElements); } private validateDef(def: any[], createdElements: JSXElement[]) { @@ -207,24 +224,38 @@ export class Utils { return -1; } - private validateAtt(element: ElementInfo, createdElements: JSXElement[]) { + private checkComposedAtts(att: Attributes | Att3d, createdElements: JSXElement[]) { + if (att != undefined) { + this.validateAtt(att as Attributes, createdElements); + for (const key of Object.keys(att)) { + //@ts-ignore + if (typeof att[key] === 'object') { + //@ts-ignore + this.checkComposedAtts(att[key], createdElements); + } + } + } + + } + + private validateAtt(attribute: Attributes, createdElements: JSXElement[]) { // check attributes for elements - if (element.att != undefined) { - if (typeof element.att.anchor === 'string') { - const index = this.checkComposedElements(element.att.anchor, createdElements); - element.att.anchor = createdElements[index].element; + if (attribute != undefined) { + if (typeof attribute.anchor === 'string') { + const index = this.checkComposedElements(attribute.anchor, createdElements); + attribute.anchor = createdElements[index].element; } - if (typeof element.att.fillColor === 'string') { - element.att.fillColor = this.changeColorValue(element.att.fillColor); + if (typeof attribute.fillColor === 'string') { + attribute.fillColor = this.changeColorValue(attribute.fillColor); } - if (typeof element.att.strokeColor === 'string') { - element.att.strokeColor = this.changeColorValue(element.att.strokeColor); + if (typeof attribute.strokeColor === 'string') { + attribute.strokeColor = this.changeColorValue(attribute.strokeColor); } - if (typeof element.att.highlightFillColor === 'string') { - element.att.highlightFillColor= this.changeColorValue(element.att.highlightFillColor); + if (typeof attribute.highlightFillColor === 'string') { + attribute.highlightFillColor= this.changeColorValue(attribute.highlightFillColor); } - if (typeof element.att.highlightStrokeColor === 'string') { - element.att.highlightStrokeColor = this.changeColorValue(element.att.highlightStrokeColor); + if (typeof attribute.highlightStrokeColor === 'string') { + attribute.highlightStrokeColor = this.changeColorValue(attribute.highlightStrokeColor); } } } From 814a0ede7dad101fadf25bba37f145cd3c3f906e Mon Sep 17 00:00:00 2001 From: Dylan Hojnoski Date: Fri, 9 Aug 2024 17:13:39 -0400 Subject: [PATCH 4/6] Added theming to 3d elements --- src/theme/obsidian.ts | 30 ++++++++++++++++++++++++++++++ src/utils.ts | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/theme/obsidian.ts b/src/theme/obsidian.ts index 9ef742f..be3f229 100644 --- a/src/theme/obsidian.ts +++ b/src/theme/obsidian.ts @@ -23,6 +23,36 @@ JXG.themes['obsidian'] = { highlightStrokeColor: interactiveAccentHover, }, + view3d: { + xAxis: { + strokeColor: "var(--color-orange)", + }, + yAxis: { + strokeColor: "var(--color-green)", + }, + zAxis: { + strokeColor: "var(--color-blue)", + }, + xPlaneRear: { + fillColor: textNormal, + }, + yPlaneRear: { + fillColor: textNormal, + }, + zPlaneRear: { + fillColor: textNormal, + }, + }, + + point3d: { + fillColor: interactiveAccent, + strokeColor: interactiveAccent, + }, + + line3d: { + strokeColor: interactiveAccent, + }, + ellipse: { strokeColor: interactiveAccent, fillColor: interactiveAccent, diff --git a/src/utils.ts b/src/utils.ts index 4b916a2..f00f5c3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -314,7 +314,7 @@ export class Utils { const equation = item; // create function that is used to calculate the values - return new Function(...this.argsArray, "createdElements", "x", "y", "return " + equation + ";").bind({}, ...this.mathFunctions, createdElements); + return new Function(...this.argsArray, "createdElements", "x", "y", "z", "return " + equation + ";").bind({}, ...this.mathFunctions, createdElements); } return item; } From e43d6d873b21816a2c21e6d551d5661877417c7c Mon Sep 17 00:00:00 2001 From: Dylan Hojnoski Date: Wed, 14 Aug 2024 12:03:16 -0400 Subject: [PATCH 5/6] Fixed curve3d and adjusted theme --- src/theme/obsidian.ts | 16 +++++++++++++--- src/utils.ts | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/theme/obsidian.ts b/src/theme/obsidian.ts index be3f229..267a68c 100644 --- a/src/theme/obsidian.ts +++ b/src/theme/obsidian.ts @@ -34,13 +34,13 @@ JXG.themes['obsidian'] = { strokeColor: "var(--color-blue)", }, xPlaneRear: { - fillColor: textNormal, + fillColor: textMuted, }, yPlaneRear: { - fillColor: textNormal, + fillColor: textMuted, }, zPlaneRear: { - fillColor: textNormal, + fillColor: textMuted, }, }, @@ -53,6 +53,16 @@ JXG.themes['obsidian'] = { strokeColor: interactiveAccent, }, + sphere3d: { + fillColor: interactiveAccent, + strokeColor: interactiveAccent, + gradient: 'radial', + gradientSecondColor: interactiveAccent, + gradientFX: 0.7, + gradientFY: 0.3, + fillOpacity: 0.4 + }, + ellipse: { strokeColor: interactiveAccent, fillColor: interactiveAccent, diff --git a/src/utils.ts b/src/utils.ts index f00f5c3..4b916a2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -314,7 +314,7 @@ export class Utils { const equation = item; // create function that is used to calculate the values - return new Function(...this.argsArray, "createdElements", "x", "y", "z", "return " + equation + ";").bind({}, ...this.mathFunctions, createdElements); + return new Function(...this.argsArray, "createdElements", "x", "y", "return " + equation + ";").bind({}, ...this.mathFunctions, createdElements); } return item; } From 86036e32394adcb1f820c7b76f74e03e4829a894 Mon Sep 17 00:00:00 2001 From: Dylan Hojnoski Date: Wed, 14 Aug 2024 15:05:24 -0400 Subject: [PATCH 6/6] Added elements to types enum --- src/types.ts | 14 +++++++++++++- src/utils.ts | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/types.ts b/src/types.ts index 708d338..0273be1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -98,29 +98,39 @@ export enum Types { Boxplot = "boxplot", Chart = "chart", Cicumcircle = "circumcircle", + Circle3D = "circle3d", Circle = "circle", Circumcenter = "circumcenter", CircumcircleArc = "circumcirclearc", + Curve3D = "curve3d", Curve = "curve", CurveDifference = "curvedifference", CurveIntersection = "curveintersection", CurveUnion = "curveunion", Derivaative = "derivative", Ellipse = "ellipse", + Function3D = "functiongraph3d", Function = "functiongraph", Glider = "glider", Incenter = "incenter", Inequality = "inequality", Integral = "integral", + IntersectionCircle3D = "intersectioncircle3d", Intersection = "intersection", + IntersectionLine3D = "intersectionline3d", Label = "label", + Line3D = "line3d", Line = "line", Parabola = "parabola", Parallel = "parallel", + ParametricSurface3D = "parametricsurface3d", Perpendicular = "perpendicular", + Plane3D = "plane3d", + Point3D = "point3d", Point = "point", - Polygon = "polygon", + Polygon3D = "polygon3d", PolygonalChain = "polygonalchain", + Polygon = "polygon", RegularPolygon = "regularpolygon", Riemannsum = "riemannsum", Sector = "sector", @@ -129,9 +139,11 @@ export enum Types { Slider = "slider", SlopeField = "slopefield", SlopeTriangle = "slopetriangle", + Sphere3D = "sphere3d", Stepfunction = "stepfunction", Tangent = "tangent", Tapemeasure = "tapemeasure", Text = "text", + Vectorfield3D = "vectorfield3d", VectorField = "vectorfield", } diff --git a/src/utils.ts b/src/utils.ts index 4b916a2..83932e6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { Board, JSXGraph, GeometryElement, View3D, elements } from "jsxgraph"; +import { Board, JSXGraph, GeometryElement, View3D } from "jsxgraph"; import { parseYaml } from "obsidian"; import { Att3d, Attributes, ElementInfo, Graph, GraphInfo, JSXElement, Types } from "./types"; @@ -313,8 +313,9 @@ export class Utils { } const equation = item; + // create function that is used to calculate the values - return new Function(...this.argsArray, "createdElements", "x", "y", "return " + equation + ";").bind({}, ...this.mathFunctions, createdElements); + return new Function(...this.argsArray, "createdElements", "x", "y", "z", "return " + equation + ";").bind({}, ...this.mathFunctions, createdElements); } return item; }