mathbox-react 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/{types/components → components}/ContainedMathbox.d.ts +0 -0
- package/build/cjs/{types/components → components}/Mathbox.d.ts +0 -0
- package/build/cjs/components/MathboxNodeContext.d.ts +4 -0
- package/build/cjs/{types/components → components}/components.d.ts +6 -1
- package/build/cjs/{types/components → components}/index.d.ts +0 -0
- package/build/{esm/types → cjs}/components/types.d.ts +2 -2
- package/build/cjs/{types/components → components}/util.d.ts +1 -1
- package/build/cjs/{types/index.d.ts → index.d.ts} +0 -0
- package/build/cjs/index.js +1 -24
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/{types/testSetup.d.ts → testSetup.d.ts} +0 -0
- package/build/cjs/{types/testUtils.d.ts → testUtils.d.ts} +0 -0
- package/build/esm/{types/components → components}/ContainedMathbox.d.ts +0 -0
- package/build/esm/{types/components → components}/Mathbox.d.ts +0 -0
- package/build/esm/components/MathboxNodeContext.d.ts +4 -0
- package/build/esm/{types/components → components}/components.d.ts +6 -1
- package/build/esm/{types/components → components}/index.d.ts +0 -0
- package/build/{cjs/types → esm}/components/types.d.ts +2 -2
- package/build/esm/{types/components → components}/util.d.ts +1 -1
- package/build/esm/{types/index.d.ts → index.d.ts} +0 -0
- package/build/esm/index.js +1 -24
- package/build/esm/index.js.map +1 -1
- package/build/esm/{types/testSetup.d.ts → testSetup.d.ts} +0 -0
- package/build/esm/{types/testUtils.d.ts → testUtils.d.ts} +0 -0
- package/build/index.d.ts +8 -3
- package/package.json +40 -45
- package/.eslintrc.js +0 -72
- package/.github/workflows/lint.yaml +0 -20
- package/.prettierrc +0 -1
- package/.storybook/main.js +0 -9
- package/.storybook/preview.js +0 -11
- package/LICENSE +0 -29
- package/README.md +0 -6
- package/babel.config.js +0 -3
- package/build/cjs/types/components/MathboxNodeContext.d.ts +0 -4
- package/build/cjs/types/components/components.spec.d.ts +0 -1
- package/build/cjs/types/stories/utils.d.ts +0 -5
- package/build/esm/types/components/MathboxNodeContext.d.ts +0 -4
- package/build/esm/types/components/components.spec.d.ts +0 -1
- package/build/esm/types/stories/utils.d.ts +0 -5
- package/jest.config.js +0 -12
- package/rollup.config.js +0 -38
- package/scratch.js +0 -149
- package/src/components/ContainedMathbox.tsx +0 -38
- package/src/components/Mathbox.tsx +0 -63
- package/src/components/MathboxNodeContext.ts +0 -6
- package/src/components/components.spec.tsx +0 -276
- package/src/components/components.tsx +0 -419
- package/src/components/index.ts +0 -3
- package/src/components/types.ts +0 -9
- package/src/components/util.ts +0 -106
- package/src/index.ts +0 -1
- package/src/stories/Cartesian.stories.tsx +0 -36
- package/src/stories/Grid.stories.tsx +0 -38
- package/src/stories/Mathbox.stories.tsx +0 -16
- package/src/stories/Point.stories.tsx +0 -68
- package/src/stories/utils.tsx +0 -33
- package/src/testSetup.ts +0 -3
- package/src/testUtils.ts +0 -46
- package/tsconfig.base.json +0 -17
- package/tsconfig.json +0 -5
|
File without changes
|
|
File without changes
|
package/build/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { NodeType, Props, MathboxSelection, RootProps } from 'mathbox';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type WithChildren<T> = {
|
|
5
5
|
children?: ReactNode | ReactNode[];
|
|
6
6
|
} & T;
|
|
7
7
|
|
|
8
8
|
declare const CAN_HAVE_CHILDREN: readonly ["view", "cartesian", "cartesian4", "polar", "spherical", "stereographic", "stereographic4", "transform", "transform4", "vertex", "fragment", "layer", "mask", "group", "inherit", "root", "unit", "rtt", "clock", "now", "move", "present", "reveal", "slide"];
|
|
9
|
-
|
|
9
|
+
type ParentNodeTypes = typeof CAN_HAVE_CHILDREN[number];
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
type LiveProps<P> = {
|
|
12
|
+
[K in keyof P]: (t: number, dt: number) => P[K];
|
|
13
|
+
};
|
|
14
|
+
type MathboxComponent<T extends NodeType> = React.ForwardRefExoticComponent<(T extends ParentNodeTypes ? WithChildren<Props[T]> : Props[T]) & React.RefAttributes<MathboxSelection<T>> & {
|
|
15
|
+
liveProps?: LiveProps<Props[T]>;
|
|
16
|
+
}>;
|
|
12
17
|
/**
|
|
13
18
|
* Component wrapper for mathbox [`area`](https://gitgud.io/unconed/mathbox/-/blob/master/docs/primitives.md#dataarea).
|
|
14
19
|
*/
|
package/package.json
CHANGED
|
@@ -1,62 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mathbox-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "React wrapper for Mathbox",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Chris Chudzicki",
|
|
7
7
|
"main": "build/cjs/index.js",
|
|
8
8
|
"module": "build/esm/index.js",
|
|
9
|
-
"types": "build/
|
|
9
|
+
"types": "build/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"build"
|
|
12
|
+
],
|
|
10
13
|
"scripts": {
|
|
11
|
-
"build": "rm -rf build && rollup
|
|
12
|
-
"build-
|
|
14
|
+
"build": "rm -rf build && rollup --config",
|
|
15
|
+
"build-watch": "rollup --config --watch",
|
|
13
16
|
"storybook": "start-storybook -p 6006",
|
|
14
|
-
"lint": "
|
|
15
|
-
"format": "
|
|
16
|
-
"autofix": "
|
|
17
|
-
"prepack": "
|
|
17
|
+
"lint": "yarn global:lint",
|
|
18
|
+
"format": "yarn global:format",
|
|
19
|
+
"autofix": "yarn global:autofix",
|
|
20
|
+
"prepack": "yarn build",
|
|
18
21
|
"test": "jest"
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
|
-
"@babel/core": "
|
|
22
|
-
"@babel/preset-env": "
|
|
23
|
-
"@rollup/plugin-commonjs": "
|
|
24
|
-
"@rollup/plugin-node-resolve": "
|
|
25
|
-
"@rollup/plugin-typescript": "
|
|
26
|
-
"@storybook/addon-actions": "
|
|
27
|
-
"@storybook/addon-essentials": "
|
|
28
|
-
"@storybook/addon-interactions": "
|
|
29
|
-
"@storybook/addon-links": "
|
|
30
|
-
"@storybook/react": "
|
|
31
|
-
"@storybook/testing-library": "
|
|
32
|
-
"@testing-library/react": "
|
|
33
|
-
"@types/jest": "
|
|
34
|
-
"@types/lodash": "
|
|
35
|
-
"@types/react": "
|
|
36
|
-
"@types/three": "
|
|
37
|
-
"babel-jest": "
|
|
38
|
-
"babel-loader": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"react-dom": "^17.0.2",
|
|
50
|
-
"rollup": "^2.67.3",
|
|
51
|
-
"rollup-plugin-dts": "^4.1.0",
|
|
52
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
53
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
54
|
-
"three": "^0.137.5",
|
|
55
|
-
"ts-jest": "^27.1.3",
|
|
56
|
-
"typescript": "^4.5.5"
|
|
24
|
+
"@babel/core": "7.19.3",
|
|
25
|
+
"@babel/preset-env": "7.19.4",
|
|
26
|
+
"@rollup/plugin-commonjs": "23.0.0",
|
|
27
|
+
"@rollup/plugin-node-resolve": "15.0.0",
|
|
28
|
+
"@rollup/plugin-typescript": "9.0.1",
|
|
29
|
+
"@storybook/addon-actions": "6.5.12",
|
|
30
|
+
"@storybook/addon-essentials": "6.5.12",
|
|
31
|
+
"@storybook/addon-interactions": "6.5.12",
|
|
32
|
+
"@storybook/addon-links": "6.5.12",
|
|
33
|
+
"@storybook/react": "6.5.12",
|
|
34
|
+
"@storybook/testing-library": "0.0.13",
|
|
35
|
+
"@testing-library/react": "12.1.5",
|
|
36
|
+
"@types/jest": "27.5.2",
|
|
37
|
+
"@types/lodash": "4.14.186",
|
|
38
|
+
"@types/react": "18.0.21",
|
|
39
|
+
"@types/three": "0.140.0",
|
|
40
|
+
"babel-jest": "27.5.1",
|
|
41
|
+
"babel-loader": "8.2.5",
|
|
42
|
+
"jest": "27.5.1",
|
|
43
|
+
"mathbox": "2.2.1",
|
|
44
|
+
"react": "17.0.2",
|
|
45
|
+
"react-dom": "17.0.2",
|
|
46
|
+
"rollup": "2.79.1",
|
|
47
|
+
"rollup-plugin-dts": "4.2.3",
|
|
48
|
+
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
49
|
+
"rollup-plugin-terser": "7.0.2",
|
|
50
|
+
"three": "0.140.0",
|
|
51
|
+
"ts-jest": "27.1.5"
|
|
57
52
|
},
|
|
58
53
|
"peerDependencies": {
|
|
59
|
-
"mathbox": "^2.1
|
|
54
|
+
"mathbox": "^2.2.1",
|
|
60
55
|
"react": "^17.0.2 || ^18.0.0",
|
|
61
56
|
"three": ">=0.118.0"
|
|
62
57
|
},
|
package/.eslintrc.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
"react-app",
|
|
4
|
-
"react-app/jest",
|
|
5
|
-
"airbnb",
|
|
6
|
-
"airbnb-typescript",
|
|
7
|
-
"prettier",
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:react/recommended",
|
|
10
|
-
"plugin:@typescript-eslint/recommended",
|
|
11
|
-
"plugin:react-hooks/recommended",
|
|
12
|
-
],
|
|
13
|
-
plugins: ["react", "@typescript-eslint", "prettier"],
|
|
14
|
-
rules: {
|
|
15
|
-
"import/no-extraneous-dependencies": [
|
|
16
|
-
"error",
|
|
17
|
-
{
|
|
18
|
-
devDependencies: ["**/*.stories.*", "**/*.spec.*"],
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
"import/prefer-default-export": "off",
|
|
22
|
-
"max-classes-per-file": "off",
|
|
23
|
-
"react/destructuring-assignment": "off",
|
|
24
|
-
"react/function-component-definition": [
|
|
25
|
-
"error",
|
|
26
|
-
{
|
|
27
|
-
namedComponents: "arrow-function",
|
|
28
|
-
unnamedComponents: "arrow-function",
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
"@typescript-eslint/no-unused-vars": [
|
|
32
|
-
"warn",
|
|
33
|
-
{
|
|
34
|
-
ignoreRestSiblings: true,
|
|
35
|
-
argsIgnorePattern: "^_",
|
|
36
|
-
varsIgnorePattern: "^_",
|
|
37
|
-
caughtErrorsIgnorePattern: "^_",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
"@typescript-eslint/naming-convention": [
|
|
41
|
-
"error",
|
|
42
|
-
{
|
|
43
|
-
selector: "variable",
|
|
44
|
-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
45
|
-
filter: {
|
|
46
|
-
regex: "^_",
|
|
47
|
-
match: false,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
settings: {},
|
|
53
|
-
overrides: [
|
|
54
|
-
{
|
|
55
|
-
files: ["**/*.ts?(x)"],
|
|
56
|
-
rules: {
|
|
57
|
-
"react/prop-types": "off",
|
|
58
|
-
"react/require-default-props": "off",
|
|
59
|
-
"react/jsx-props-no-spreading": "off",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
files: ["**/*.stories.*"],
|
|
64
|
-
rules: {
|
|
65
|
-
"import/no-anonymous-default-export": "off",
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
parserOptions: {
|
|
70
|
-
project: "./tsconfig.base.json",
|
|
71
|
-
},
|
|
72
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: tests
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
linting_and_tests:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- uses: actions/setup-node@v2
|
|
13
|
-
with:
|
|
14
|
-
node-version: "16"
|
|
15
|
-
cache: "npm"
|
|
16
|
-
cache-dependency-path: package-lock.json
|
|
17
|
-
- run: npm ci
|
|
18
|
-
- run: npm run format
|
|
19
|
-
- run: npm run lint
|
|
20
|
-
- run: npm run test
|
package/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
semi: false
|
package/.storybook/main.js
DELETED
package/.storybook/preview.js
DELETED
package/LICENSE
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022, Chris Chudzicki
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
DELETED
package/babel.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/jest.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: "ts-jest",
|
|
3
|
-
transform: {
|
|
4
|
-
"^.+\\.(ts|tsx)?$": "ts-jest",
|
|
5
|
-
"^.+\\.(js|jsx)$": "babel-jest",
|
|
6
|
-
},
|
|
7
|
-
transformIgnorePatterns: [
|
|
8
|
-
"node_modules/(?!(mathbox|threestrap|three|shadergraph)/)",
|
|
9
|
-
],
|
|
10
|
-
testEnvironment: "jsdom",
|
|
11
|
-
setupFiles: ["./src/testSetup.ts"],
|
|
12
|
-
}
|
package/rollup.config.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import resolve from "@rollup/plugin-node-resolve";
|
|
2
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
3
|
-
import typescript from "@rollup/plugin-typescript";
|
|
4
|
-
import dts from "rollup-plugin-dts";
|
|
5
|
-
import { terser } from "rollup-plugin-terser";
|
|
6
|
-
import peerDepsExternal from "rollup-plugin-peer-deps-external";
|
|
7
|
-
import packageJson from "./package.json";
|
|
8
|
-
|
|
9
|
-
export default [
|
|
10
|
-
{
|
|
11
|
-
input: "src/index.ts",
|
|
12
|
-
output: [
|
|
13
|
-
{
|
|
14
|
-
file: packageJson.main,
|
|
15
|
-
format: "cjs",
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
file: packageJson.module,
|
|
20
|
-
format: "esm",
|
|
21
|
-
sourcemap: true,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
plugins: [
|
|
25
|
-
peerDepsExternal(),
|
|
26
|
-
resolve(),
|
|
27
|
-
commonjs(),
|
|
28
|
-
typescript({ tsconfig: "./tsconfig.json" }),
|
|
29
|
-
terser(),
|
|
30
|
-
],
|
|
31
|
-
external: ["react", "react-dom", "styled-components"],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
input: "build/esm/types/index.d.ts",
|
|
35
|
-
output: [{ file: "build/index.d.ts", format: "esm" }],
|
|
36
|
-
plugins: [dts()],
|
|
37
|
-
},
|
|
38
|
-
];
|
package/scratch.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
const classDescriptions = {
|
|
2
|
-
axis: ["draw", "Draw an axis", {}, { end: "true", zBias: "-1" }],
|
|
3
|
-
face: ["draw", "Draw polygon faces"],
|
|
4
|
-
grid: ["draw", "Draw a 2D line grid", {}, { width: "1", zBias: "-2" }],
|
|
5
|
-
line: ["draw", "Draw lines"],
|
|
6
|
-
point: ["draw", "Draw points"],
|
|
7
|
-
strip: ["draw", "Draw triangle strips"],
|
|
8
|
-
surface: ["draw", "Draw surfaces", {}, { lineX: "false", lineY: "false" }],
|
|
9
|
-
ticks: ["draw", "Draw ticks"],
|
|
10
|
-
vector: ["draw", "Draw vectors"],
|
|
11
|
-
|
|
12
|
-
view: ["view", "Adjust view range"],
|
|
13
|
-
cartesian: ["view", "Apply cartesian view"],
|
|
14
|
-
cartesian4: ["view", "Apply 4D cartesian view"],
|
|
15
|
-
polar: ["view", "Apply polar view"],
|
|
16
|
-
spherical: ["view", "Apply spherical view"],
|
|
17
|
-
stereographic: ["view", "Apply stereographic projection"],
|
|
18
|
-
stereographic4: ["view", "Apply 4D stereographic projection"],
|
|
19
|
-
|
|
20
|
-
transform: ["transform", "Transform geometry in 3D"],
|
|
21
|
-
transform4: ["transform", "Transform geometry in 4D"],
|
|
22
|
-
vertex: ["transform", "Apply custom vertex shader pass"],
|
|
23
|
-
fragment: ["transform", "Apply custom fragment shader pass"],
|
|
24
|
-
layer: ["transform", "Independent 2D layer/overlay"],
|
|
25
|
-
mask: ["transform", "Apply custom mask pass"],
|
|
26
|
-
|
|
27
|
-
array: [
|
|
28
|
-
"data",
|
|
29
|
-
"1D array",
|
|
30
|
-
{ expr: "function (emit, i, time, delta) { ... }" },
|
|
31
|
-
],
|
|
32
|
-
interval: [
|
|
33
|
-
"data",
|
|
34
|
-
"1D sampled array",
|
|
35
|
-
{ expr: "function (emit, x, i, time, delta) { ... }" },
|
|
36
|
-
],
|
|
37
|
-
matrix: [
|
|
38
|
-
"data",
|
|
39
|
-
"2D matrix",
|
|
40
|
-
{ expr: "function (emit, i, j, time, delta) { ... }" },
|
|
41
|
-
],
|
|
42
|
-
area: [
|
|
43
|
-
"data",
|
|
44
|
-
"2D sampled matrix",
|
|
45
|
-
{ expr: "function (emit, x, y, i, j, time, delta) { ... }" },
|
|
46
|
-
],
|
|
47
|
-
voxel: [
|
|
48
|
-
"data",
|
|
49
|
-
"3D voxels",
|
|
50
|
-
{ expr: "function (emit, i, j, k, time, delta) { ... }" },
|
|
51
|
-
],
|
|
52
|
-
volume: [
|
|
53
|
-
"data",
|
|
54
|
-
"3D sampled voxels",
|
|
55
|
-
{ expr: "function (emit, x, y, z, i, j, k, time, delta) { ... }" },
|
|
56
|
-
],
|
|
57
|
-
scale: ["data", "Human-friendly divisions on an axis, subdivided as needed"],
|
|
58
|
-
|
|
59
|
-
html: ["overlay", "HTML element source"],
|
|
60
|
-
dom: ["overlay", "HTML DOM injector"],
|
|
61
|
-
|
|
62
|
-
text: [
|
|
63
|
-
"text",
|
|
64
|
-
"GL text source",
|
|
65
|
-
{},
|
|
66
|
-
{ minFilter: '"linear"', magFilter: '"linear"' },
|
|
67
|
-
],
|
|
68
|
-
format: [
|
|
69
|
-
"text",
|
|
70
|
-
"Text formatter",
|
|
71
|
-
{ expr: "function (x, y, z, w, i, j, k, l, time, delta) { ... }" },
|
|
72
|
-
{ minFilter: '"linear"', magFilter: '"linear"' },
|
|
73
|
-
],
|
|
74
|
-
retext: ["text", "Text atlas resampler"],
|
|
75
|
-
label: ["text", "Draw GL labels"],
|
|
76
|
-
|
|
77
|
-
clamp: ["operator", "Clamp out-of-bounds samples to the nearest data point"],
|
|
78
|
-
grow: ["operator", "Scale data relative to reference data point"],
|
|
79
|
-
join: [
|
|
80
|
-
"operator",
|
|
81
|
-
"Join two array dimensions into one by concatenating rows/columns/stacks",
|
|
82
|
-
],
|
|
83
|
-
lerp: ["operator", "Linear interpolation of data"],
|
|
84
|
-
memo: ["operator", "Memoize data to an array/texture"],
|
|
85
|
-
readback: [
|
|
86
|
-
"operator",
|
|
87
|
-
"Read data back to a binary JavaScript array",
|
|
88
|
-
{ expr: "function (x, y, z, w, i, j, k, l) { ... }" },
|
|
89
|
-
],
|
|
90
|
-
resample: ["operator", "Resample data to new dimensions with a shader"],
|
|
91
|
-
repeat: ["operator", "Repeat data in one or more dimensions"],
|
|
92
|
-
swizzle: ["operator", "Swizzle data values"],
|
|
93
|
-
spread: ["operator", "Spread data values according to array indices"],
|
|
94
|
-
split: [
|
|
95
|
-
"operator",
|
|
96
|
-
"Split one array dimension into two by splitting rows/columns/etc",
|
|
97
|
-
],
|
|
98
|
-
slice: ["operator", "Select one or more rows/columns/stacks"],
|
|
99
|
-
subdivide: ["operator", "Subdivide data points evenly or with a bevel"],
|
|
100
|
-
transpose: ["operator", "Transpose array dimensions"],
|
|
101
|
-
|
|
102
|
-
group: ["base", "Group elements for visibility and activity"],
|
|
103
|
-
inherit: ["base", "Inherit and inject a trait from another element"],
|
|
104
|
-
root: ["base", "Tree root"],
|
|
105
|
-
unit: ["base", "Change unit sizing for drawing ops"],
|
|
106
|
-
|
|
107
|
-
shader: ["shader", "Custom shader snippet"],
|
|
108
|
-
|
|
109
|
-
camera: ["camera", "Camera instance or proxy"],
|
|
110
|
-
|
|
111
|
-
rtt: [
|
|
112
|
-
"rtt",
|
|
113
|
-
"Render objects to a texture",
|
|
114
|
-
{},
|
|
115
|
-
{ minFilter: '"linear"', magFilter: '"linear"', type: '"unsignedByte"' },
|
|
116
|
-
],
|
|
117
|
-
compose: [
|
|
118
|
-
"rtt",
|
|
119
|
-
"Full-screen render pass",
|
|
120
|
-
{},
|
|
121
|
-
{ zWrite: "false", zTest: "false", color: '"white"' },
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
clock: ["time", "Relative clock that starts from zero."],
|
|
125
|
-
now: ["time", "Absolute UNIX time in seconds since 01/01/1970"],
|
|
126
|
-
|
|
127
|
-
move: ["present", "Move elements in/out on transition"],
|
|
128
|
-
play: ["present", "Play a sequenced animation"],
|
|
129
|
-
present: ["present", "Present a tree of slides"],
|
|
130
|
-
reveal: ["present", "Reveal/hide elements on transition"],
|
|
131
|
-
slide: ["present", "Presentation slide"],
|
|
132
|
-
step: ["present", "Step through a sequenced animation"],
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const capitalize = (s) => `${s[0].toUpperCase()}${s.slice(1)}`
|
|
136
|
-
|
|
137
|
-
const makeDef = (name) => {
|
|
138
|
-
const [group] = classDescriptions[name]
|
|
139
|
-
const Name = capitalize(name)
|
|
140
|
-
const dest = `https://gitgud.io/unconed/mathbox/-/blob/master/docs/primitives.md#${group}${name}`
|
|
141
|
-
const def = `
|
|
142
|
-
/**
|
|
143
|
-
* Component wrapper for mathbox [\`${name}\`](${dest}).
|
|
144
|
-
*/
|
|
145
|
-
export const ${Name} = mathboxComponentFactory('${name}');`
|
|
146
|
-
console.log(def)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
Object.keys(classDescriptions).sort().forEach(makeDef)
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useState, forwardRef } from "react"
|
|
2
|
-
import { RootProps, MathBoxOptions, MathboxSelection } from "mathbox"
|
|
3
|
-
import Mathbox from "./Mathbox"
|
|
4
|
-
import { WithChildren } from "./types"
|
|
5
|
-
|
|
6
|
-
type Props = WithChildren<
|
|
7
|
-
{
|
|
8
|
-
containerId?: string
|
|
9
|
-
containerClass?: string
|
|
10
|
-
containerStyle?: React.CSSProperties
|
|
11
|
-
options?: MathBoxOptions
|
|
12
|
-
} & RootProps
|
|
13
|
-
>
|
|
14
|
-
|
|
15
|
-
const ContainedMathbox = (
|
|
16
|
-
props: Props,
|
|
17
|
-
ref: React.Ref<MathboxSelection<"root">>
|
|
18
|
-
) => {
|
|
19
|
-
const { children, containerId, containerClass, containerStyle, ...others } =
|
|
20
|
-
props
|
|
21
|
-
const [container, setContainer] = useState<HTMLDivElement | null>(null)
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
ref={setContainer}
|
|
25
|
-
id={containerId}
|
|
26
|
-
className={containerClass}
|
|
27
|
-
style={containerStyle}
|
|
28
|
-
>
|
|
29
|
-
{container && (
|
|
30
|
-
<Mathbox ref={ref} container={container} {...others}>
|
|
31
|
-
{children}
|
|
32
|
-
</Mathbox>
|
|
33
|
-
)}
|
|
34
|
-
</div>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default forwardRef(ContainedMathbox)
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useState,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
} from "react"
|
|
7
|
-
import { Color } from "three"
|
|
8
|
-
import { mathBox, RootProps, MathboxSelection, MathBoxOptions } from "mathbox"
|
|
9
|
-
import MathboxAPIContext from "./MathboxNodeContext"
|
|
10
|
-
import { WithChildren } from "./types"
|
|
11
|
-
import { useDeepCompareMemo } from "./util"
|
|
12
|
-
|
|
13
|
-
type Props = WithChildren<
|
|
14
|
-
{
|
|
15
|
-
container: HTMLElement
|
|
16
|
-
options?: MathBoxOptions
|
|
17
|
-
} & RootProps
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
const Mathbox = (
|
|
21
|
-
props: Props,
|
|
22
|
-
ref: React.Ref<MathboxSelection<"root"> | null>
|
|
23
|
-
) => {
|
|
24
|
-
const { container, children, options, ...rootProps } = props
|
|
25
|
-
const mathboxOptions = useDeepCompareMemo(options ?? {}, {})
|
|
26
|
-
const [selection, setSelection] = useState<MathboxSelection<"root"> | null>(
|
|
27
|
-
null
|
|
28
|
-
)
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!container) return () => {}
|
|
31
|
-
|
|
32
|
-
const mathbox = mathBox({
|
|
33
|
-
...mathboxOptions,
|
|
34
|
-
element: container,
|
|
35
|
-
})
|
|
36
|
-
setSelection(mathbox)
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* TODO: Should Mathbox component allow setting these more easily?
|
|
40
|
-
*/
|
|
41
|
-
mathbox.three.renderer.setClearColor(new Color(0xffffff), 1.0)
|
|
42
|
-
mathbox.three.camera.position.set(1, 1, 2)
|
|
43
|
-
return () => {
|
|
44
|
-
mathbox.select("*").remove()
|
|
45
|
-
mathbox.three.destroy()
|
|
46
|
-
setSelection(null)
|
|
47
|
-
}
|
|
48
|
-
}, [container, mathboxOptions])
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!selection) return
|
|
52
|
-
selection.set(rootProps)
|
|
53
|
-
}, [selection, rootProps])
|
|
54
|
-
|
|
55
|
-
useImperativeHandle(ref, () => selection, [selection])
|
|
56
|
-
return (
|
|
57
|
-
<MathboxAPIContext.Provider value={selection}>
|
|
58
|
-
{children}
|
|
59
|
-
</MathboxAPIContext.Provider>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default forwardRef(Mathbox)
|