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

Fix typos in the documentation #108

Merged
merged 2 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions docs/benchmarks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
See the live benchmakrs:
See the live benchmarks:
<!-- each graphics container MUST have an UNIQUE id -->
<!-- filename aplhabetic order -->
<!-- filename alphabetic order -->
- [Cuboid](benchmarks/cuboid)
- [Line](benchmarks/line)
- [Point](benchmarks/point)
Expand Down
4 changes: 2 additions & 2 deletions docs/developers/polygons.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ for (let i = 0; i < coords.length; i++) {
}
```

To test the coplanarity of the polygon we create a
To test whether a polygon is coplanar we create a
[plane](https://en.wikipedia.org/wiki/Plane_(geometry)) using the 1st, 2nd
and last coordinates of the polygon (these coordinates are choosen
and last coordinates of the polygon (these coordinates are chosen
because the vectors 1st->2nd and last->2nd have different directions,
what is necessary to build the
[plane](https://en.wikipedia.org/wiki/Plane_(geometry))).
Expand Down
4 changes: 2 additions & 2 deletions docs/documentation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Welcome to the mathics-threejs-backend documentation!

You can use mathics-threejs-backend in 2 ways:
- **production** — a stable release. To use either use the content-development network (CDN) or host the files in your own webserver:
- **production** — a stable release. To use either use the content-development network (CDN) or host the files in your own web-server:
- to use the CDN:
```html
<script src="https://cdn.jsdelivr.net/npm/@mathicsorg/mathics-threejs-backend"></script>
Expand Down Expand Up @@ -36,7 +36,7 @@ The main function of mathics-threejs-backend is `drawGraphics3d`, takes the foll
- `ticks` (type: [number[], number[], string[]][3]) — array containing the ticks' information for, respectively, x, y and z axes. The ticks' information is an array of three elements: big ticks' 0-1 coordinates, small ticks' 0-1 coordinates, big ticks' labels. Default: `[]`
- `ticks_style` (type: [color[3]](/mathics-threejs-backend/types/color)) — array containing the ticks' colors for, respectively, x, y and z axes. Default: `[[0, 0, 0], [0, 0, 0], [0, 0, 0]]` (all ticks are black)
- `elements` (type: [element[]](/mathics-threejs-backend/types/color) — array of primitives, default: `[]`
- `extent` (type: object) — the size of the bounding box. This is optional, only use this if you don't want the default behaviour. This is an object with the following properties:
- `extent` (type: object) — the size of the bounding box. This is optional, only use this if you don't want the default behavior. This is an object with the following properties:
- `xmin` (type: number)
- `ymin` (type: number)
- `zmin` (type: number)
Expand Down
4 changes: 2 additions & 2 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
See our gallery:

<!-- each graphics container MUST have an UNIQUE id -->
<!-- description aplhabetic order -->
<!-- description alphabetic order -->
- [☆ 2 connected cones with edges](examples/cones-with-edges)
- [☆ 2 connected cylinders](examples/connected-cylinders)
- [● Black point](examples/black-point)
Expand All @@ -24,7 +24,7 @@ See our gallery:
- [☆ Simple tube](examples/simple-tube)
- [● Sine points](examples/sine-points)
- [○ Sphere with yellow spotlight](examples/yellow-spotlight)
- [○ Spheres with center pointlight](examples/spheres-with-center-pointlight)
- [○ Spheres with center point light](examples/spheres-with-center-pointlight)
- [⬠ Tetrahedron](examples/tetrahedron)
- [△ Triangle with edges](examples/triangle-with-edges)
- [☆ Tube, dodecahedrons and spheres](examples/tube-dodecahedrons-and-spheres)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Welcome to the mathics-threejs-backend documentation and examples!

mathics-threejs-backend is a JavaScript library for rendering [Mathics](https://mathics.org) (and eventually Wolfram Language) [Graphics3D](https://reference.wolfram.com/language/ref/Graphics3D.html) objects.

This can be used in Mathics front ends like [Mathics-Django](https://pypi.org/project/Mathics-Django/) and [Symja](https://github.com/axkr/symja_android_library) to handle 3D graphics. The code may also be useful as a guide for other kinds of Mathics/WL frontends to other kinds of JavaScript graphics engines.
This can be used in Mathics front ends like [Mathics-Django](https://pypi.org/project/Mathics-Django/) and [Symja](https://github.com/axkr/symja_android_library) to handle 3D graphics. The code may also be useful as a guide for other kinds of Mathics/WL front-ends to other kinds of JavaScript graphics engines.

See [our gallery](examples).

Expand Down
6 changes: 3 additions & 3 deletions docs/primitives/cone.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Properties:
- `color` (type: [color/mathics-threejs-backend/types/color)) — default: white
- `coords` (type: [coord[]/mathics-threejs-backend/types/coord)) — array of cylinders' centers
- `color` (type: [color](/mathics-threejs-backend/types/color)) — default: white
- `coords` (type: [coord[]](/mathics-threejs-backend/types/coord)) — array of cylinders' centers
- `edgeForm` (type: object) — default: `{}`, object with the following properties:
- `color` (type: [color/mathics-threejs-backend/types/color)) — edges' color, default: black
- `color` (type: [color](/mathics-threejs-backend/types/color)) — edges' color, default: black
- `showEdges` (type: bool) — default: `true`
- `radius` (type: number) — default: `1`
- `opacity` (type: number) — default: `1`
Expand Down
6 changes: 3 additions & 3 deletions docs/primitives/cuboid.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Properties:
- `color` (type: [color](documentation/types/color)) — default: white
- `coords` (type: [coord[]](documentation/types/coord)) — array of the cuboids' begins and ends
- `color` (type: [color](/mathics-threejs-backend/types/color)) — default: white
- `coords` (type: [coord[]](/mathics-threejs-backend/types/coord)) — array of the cuboids' begins and ends
- `edgeForm` (type: object) — default: `{}`, object with the following properties:
- `color` (type: [color](documentation/types/color)) — edges' color, default: black
- `color` (type: [color](/mathics-threejs-backend/types/color)) — edges' color, default: black
- `showEdges` (type: bool) — default: `true`
- `opacity` (type: number) — default: `1`

Expand Down
2 changes: 1 addition & 1 deletion docs/primitives/line.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ Draw a line from the first coordinate to the last one.
</script>

## Notes
- Our behavor is different from Wolframs Language's Line; our lines aren't affected by the lighting and therefore don't have VertexNormals.
- Our behavior is different from Wolframs Language's Line; our lines aren't affected by the lighting and therefore don't have VertexNormals.
2 changes: 1 addition & 1 deletion docs/primitives/point.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ Draw points with the point size being canvas' size times `pointSize`.
![1000 points](https://user-images.githubusercontent.com/62714153/124356523-ce9b9680-dbec-11eb-87e0-d200ea93f4c0.png)

## Notes
- Our behavor is different from Wolframs Language's Point, our points aren't affected by lighting and therefore don't have VertexNormals.
- Our behavior is different from Wolframs Language's Point, our points aren't affected by lighting and therefore don't have VertexNormals.
2 changes: 1 addition & 1 deletion docs/types/container.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A HTML element obtained with `document.getElementById` or similars.
A HTML element obtained with `document.getElementById` or similar.

The canvas will occupy the whole container.

Expand Down
2 changes: 1 addition & 1 deletion src/bufferUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function getPopulatedCoordinateBuffer(coords, extent) {
/**
* Create 2 coordinate buffers and copy the even-numbered coordinates from
* coords to the 1st coordinate buffer and the odd-numbered ones to the 2nd.
* This is usuful when the primitive have a begin and a end coordinate.
* This is useful when the primitive have a begin and a end coordinate.
* Both can't be in the same BufferAttribute.
* @param {Array<[Coordinate, null] | [null, Coordinate]>} coords
* @param {import('./extent.js').Extent} extent
Expand Down
2 changes: 1 addition & 1 deletion src/extent.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function extent(elements) {
});

if (needs2ndPass) {
// 2nd pass, necesary for primitives with scaled coordinates and
// 2nd pass, necessary for primitives with scaled coordinates and
// radius > extent.
elements.forEach((element) => {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/graphics3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function (
camera.lookAt(focus);
}

// Without this the initial axes postion is wrong.
// Without this the initial axes position is wrong.
updateCameraPosition();
camera.up.set(0, 0, 1);

Expand Down
12 changes: 9 additions & 3 deletions src/primitives/cone.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,17 @@ export default function ({ color = [1, 1, 1], coords, edgeForm = {}, opacity = 1

group.add(cones);

// Differently from cuboid's edges, the cones' ones are in a different object. It is very hard or maybe impossible to draw edges with complex shapes in the fragment shader.
// Differently from cuboid's edges, the cones' ones are in a
// different object. It is very hard or maybe impossible to draw
// edges with complex shapes in the fragment shader.

// The lines below are the cone base edges' vertices' positions.
// The magic numbers below are modified from the position attribute of a three.js EdgesGeometry of the cone.
// Differently from cylinders' edges, the cones' ones are drawed through Line, now LineSegments, so before putting them in the code we need to remove the repeated numbers. This saves RAM and increases the performance.
// The magic numbers below are modified from the position attribute
// of a three.js EdgesGeometry of the cone.
// Differently from cylinders' edges, the cones' ones are drawn
// through Line, now LineSegments, so before putting them in the
// code we need to remove the repeated numbers. This saves RAM and
// increases the performance.
// To get them: console.log(new EdgesGeometry(coneGeometry).attributes.position.array)

const edgesGeometry = new InstancedBufferGeometry()
Expand Down
4 changes: 2 additions & 2 deletions src/primitives/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

// This file exports implmentations using three.js of Mathematica and
// This file exports implementations using three.js of Mathematica and
// Mathics Graphics3D primitives like "Sphere", or "Cuboid, etc.

// A full list of primitives that this might grow to can be found at:
Expand Down Expand Up @@ -68,7 +68,7 @@
// Also note that in contrast to he Mathematica/Mathics name, we
// downcase the first letter of the corresponding name. For example,
// we use the function name "sphere" and "uniformPolyhedron", not
// "Sphere" and "UnformPolyhedron".
// "Sphere" and "UniformPolyhedron".

// Usually the vertices are stored in the attribute "position".

Expand Down
7 changes: 4 additions & 3 deletions src/primitives/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import { scaleCoordinate } from '../coordinateUtils.js';

/**
* Get the unit normal vector from the 1st, 2nd and last coordinate
* (these numbers were choosen because the vectors 1st->2nd and last->2nd
* have different directions, what is necessary for some calculations)
* (these numbers were chosen because the vectors 1st->2nd and
* last->2nd have different directions, what is necessary for some
* calculations)
* Note: a "better" way to do this is compute an approximation plane
* by taking linear least squares, but that would be way slower and
* there would be only difference for very specific polygons.
Expand Down Expand Up @@ -314,7 +315,7 @@ export default function ({ color = [1, 1, 1], coords, edgeForm = {}, opacity = 1
edgeForm.color ??= [0, 0, 0];

// Differently from polyhedrons, polygons use a Mesh and a material
// with "wirefram: true". This is slower than LineSegments, but
// with "wireframe: true". This is slower than LineSegments, but
// creating a new BufferGeometry is also slow and uses more RAM
// (LineSegments don't support indexed BufferGeometries).
group.add(new Mesh(
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/uniformPolyhedron.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export default function ({ color = [1, 1, 1], coords, edgeForm = {}, edgeLength

group.add(polyhedrons);

// The polyhedrons' edges are basicaly the same as the cylinders' ones.
// The polyhedrons' edges are basically the same as the cylinders' ones.

const edgesGeometry = new InstancedBufferGeometry();

Expand Down
2 changes: 1 addition & 1 deletion vendors/earcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {

// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
function isValidDiagonal(a, b) {
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
Expand Down