vgpu-render 0.1.0 → 0.2.0
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/README.md +76 -26
- package/dist/curve.d.ts +1 -1
- package/dist/debug-draw-3d.d.ts +3 -3
- package/dist/debug-draw-3d.js +10 -10
- package/dist/{frame-recorder-2d.d.ts → frame-draw-list-2d.d.ts} +11 -11
- package/dist/{frame-recorder-2d.js → frame-draw-list-2d.js} +6 -6
- package/dist/{frame-recorder.d.ts → frame-draw-list.d.ts} +60 -8
- package/dist/{frame-recorder.js → frame-draw-list.js} +51 -10
- package/dist/geometry-generators.d.ts +2 -2
- package/dist/geometry-generators.js +1 -1
- package/dist/gpu-debug-draw-2d.d.ts +1 -1
- package/dist/gpu-debug-draw-3d.d.ts +1 -1
- package/dist/gpu-debug-draw-3d.js +4 -2
- package/dist/gpu-text-3d.d.ts +1 -1
- package/dist/gpu-text-3d.js +49 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -3
- package/dist/mesh-batch-3d.d.ts +1 -1
- package/dist/shape2d-shader.js +3 -2
- package/dist/text-atlas.d.ts +6 -4
- package/dist/text-atlas.js +9 -6
- package/dist/text-font.d.ts +48 -7
- package/dist/text-font.js +63 -11
- package/dist/text-layout.d.ts +63 -4
- package/dist/text-layout.js +58 -8
- package/dist/text-msdf-baked.d.ts +9 -4
- package/dist/text-msdf-baked.js +9 -4
- package/dist/text-msdf-font.d.ts +10 -4
- package/dist/text-msdf-font.js +9 -3
- package/dist/vector-math.d.ts +19 -0
- package/dist/vector-math.js +37 -0
- package/package.json +1 -1
- package/dist/layout-3d.d.ts +0 -227
- package/dist/layout-3d.js +0 -226
- package/dist/scene-examples.d.ts +0 -39
- package/dist/scene-examples.js +0 -200
- package/dist/scenes-2d.d.ts +0 -18
- package/dist/scenes-2d.js +0 -160
- package/dist/scenes-3d.d.ts +0 -46
- package/dist/scenes-3d.js +0 -1994
- package/dist/text-scenes.d.ts +0 -85
- package/dist/text-scenes.js +0 -338
package/dist/layout-3d.d.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout and drawing specifications ported from `the upstream reference`.
|
|
3
|
-
*
|
|
4
|
-
* Every reference scene shares the same layout contract, which is why it lives here rather
|
|
5
|
-
* than being re-derived per scene:
|
|
6
|
-
*
|
|
7
|
-
* ```
|
|
8
|
-
* column_x(column) = column * COLUMN_SPACING + 0.5 // COLUMN_SPACING is 2.0, axes 2.2
|
|
9
|
-
* row_z(row) = SAMPLE_START_Z - row * spacing // START_Z is -0.45, rows go along -Z
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* Each scene has its own `SAMPLE_SPACING`, and some columns override it (radius, size,
|
|
13
|
-
* angle, height). Coordinates are local to the scene root; the reference capture harness
|
|
14
|
-
* translates the whole root by `REFERENCE_OFFSET` without rescaling any geometry, so the
|
|
15
|
-
* same translation is applied here.
|
|
16
|
-
*/
|
|
17
|
-
import type { Color, Vec3 } from "./frame-recorder.js";
|
|
18
|
-
/** `scene.position = Vector3(-10, 0, 1.5)` from `the reference capture script`. */
|
|
19
|
-
export declare const REFERENCE_OFFSET: Vec3;
|
|
20
|
-
export declare function referenceOffset(p: Vec3): Vec3;
|
|
21
|
-
/** Shared value tables used by the reference scenes. */
|
|
22
|
-
export declare const WIDTH_VALUES: readonly [1, 2, 5.5, 10];
|
|
23
|
-
export declare const ALPHA_VALUES: readonly [1, 0.65, 0.35, 0.1];
|
|
24
|
-
export declare const DASH_VALUES: readonly (readonly [number, number])[];
|
|
25
|
-
export declare const JOINT_VALUES: readonly ["none", "round", "bevel", "miter"];
|
|
26
|
-
export declare const RADIUS_VALUES: readonly [0.18, 0.28, 0.38, 0.5];
|
|
27
|
-
export declare const SEGMENT_VALUES: readonly [8, 16, 32, 64];
|
|
28
|
-
export declare const ROTATION_SAMPLE_COUNT = 8;
|
|
29
|
-
export declare const NORMAL_SAMPLE_COUNT = 4;
|
|
30
|
-
export declare const WHITE: Color;
|
|
31
|
-
export declare const CYAN: Color;
|
|
32
|
-
export declare const LIME: Color;
|
|
33
|
-
export declare const ORANGE: Color;
|
|
34
|
-
export declare const ORANGE_SOFT: Color;
|
|
35
|
-
export declare const VIOLET: Color;
|
|
36
|
-
export declare const TEAL: Color;
|
|
37
|
-
export declare const PINK: Color;
|
|
38
|
-
export declare const GOLD: Color;
|
|
39
|
-
/** Reference `_get_normal_sample_color` / `_get_normal_sample_width`, shared by most scenes. */
|
|
40
|
-
export declare function normalSampleColor(row: number): Color;
|
|
41
|
-
export declare function normalSampleWidth(row: number, baseWidth: number): number;
|
|
42
|
-
/**
|
|
43
|
-
* reference `Color.from_hsv(h, s, v, a)`. The reference solid samples use this, so a fixed
|
|
44
|
-
* palette color cannot reproduce them. `h` is in `[0, 1]`, matching reference.
|
|
45
|
-
*/
|
|
46
|
-
export declare function fromHsv(h: number, s: number, v: number, a: number): Color;
|
|
47
|
-
export declare function normalizeVector(p: Vec3): Vec3;
|
|
48
|
-
export declare function crossVector(a: Vec3, b: Vec3): Vec3;
|
|
49
|
-
/** reference `Vector3.rotated(axis, angle)` equivalent (right-handed Rodrigues). */
|
|
50
|
-
export declare function rotateAroundAxis(p: Vec3, axis: Vec3, angle: number): Vec3;
|
|
51
|
-
export type CircleBasis = {
|
|
52
|
-
readonly x: Vec3;
|
|
53
|
-
readonly y: Vec3;
|
|
54
|
-
readonly z: Vec3;
|
|
55
|
-
};
|
|
56
|
-
/** Port of `_get_circle_rotation(normal, angle)` from `circle.gd`. */
|
|
57
|
-
export declare function circleBasis(normal: Vec3, angle: number): CircleBasis;
|
|
58
|
-
/** Points on a circle in the plane spanned by a reference rotation basis. */
|
|
59
|
-
export declare function basisCirclePoints(centerLocal: Vec3, radius: number, segments: number, basis: CircleBasis): Vec3[];
|
|
60
|
-
/**
|
|
61
|
-
* Column/row placement shared by every reference scene.
|
|
62
|
-
*
|
|
63
|
-
* The reference files re-implement the same three lines per scene, differing only in the
|
|
64
|
-
* spacing constants. Modelling that here keeps each scene a small table of numbers instead
|
|
65
|
-
* of another copy of the coordinate math:
|
|
66
|
-
*
|
|
67
|
-
* - `columnX(column) = column * columnSpacing + columnOffset`
|
|
68
|
-
* - `rowZ(row) = sampleStartZ - row * rowSpacing` (rows advance along **-Z**)
|
|
69
|
-
* - a per-column override covers the scenes whose radius/size/angle/height columns use a
|
|
70
|
-
* wider spacing than the rest (for example `circle` radius 1.15 vs 0.82).
|
|
71
|
-
*/
|
|
72
|
-
export type SceneLayout = {
|
|
73
|
-
/** Distance between adjacent columns; `2.0` for every scene except `axes` (2.2). */
|
|
74
|
-
readonly columnSpacing: number;
|
|
75
|
-
/** Added to `column * columnSpacing`; `0.5` for every ported scene. */
|
|
76
|
-
readonly columnOffset: number;
|
|
77
|
-
readonly sampleSpacing: number;
|
|
78
|
-
readonly sampleStartZ: number;
|
|
79
|
-
/** Row spacing for specific columns, overriding `sampleSpacing`. */
|
|
80
|
-
readonly perColumnSpacing?: Readonly<Record<number, number>>;
|
|
81
|
-
/** Column-specific Y offset, used by scenes that lift a tunnel or grow by radius. */
|
|
82
|
-
readonly columnY?: (column: number, row: number, baseY: number) => number;
|
|
83
|
-
};
|
|
84
|
-
export declare function createLayout(layout: SceneLayout, baseY: number): {
|
|
85
|
-
columnX: (column: number) => number;
|
|
86
|
-
rowZ: (column: number, row: number) => number;
|
|
87
|
-
rowSpacing: (column: number) => number;
|
|
88
|
-
at: (column: number, row: number) => Vec3;
|
|
89
|
-
atLocal: (column: number, row: number) => Vec3;
|
|
90
|
-
};
|
|
91
|
-
export type ScenePositions = ReturnType<typeof createLayout>;
|
|
92
|
-
/** Reference `circle.gd` layout: radius column uses 1.15 row spacing, the rest 0.82. */
|
|
93
|
-
export declare const CIRCLE_REFERENCE_LAYOUT: SceneLayout;
|
|
94
|
-
/**
|
|
95
|
-
* Per-scene layouts, copied from the constants at the top of each `examples/*.gd`.
|
|
96
|
-
*
|
|
97
|
-
* Every reference scene differs only in these numbers, so they are data here rather than
|
|
98
|
-
* duplicated coordinate math. `columnSpacing` is 2.0 everywhere except `axes` (2.2).
|
|
99
|
-
*/
|
|
100
|
-
export declare const SCENE_LAYOUTS: {
|
|
101
|
-
/** `index.gd`: absolute origin, its own row spacing, samples lifted to y = 0.55. */
|
|
102
|
-
readonly index: {
|
|
103
|
-
readonly columnSpacing: 2;
|
|
104
|
-
readonly columnOffset: 1;
|
|
105
|
-
readonly sampleSpacing: 1.25;
|
|
106
|
-
readonly sampleStartZ: -1;
|
|
107
|
-
readonly baseY: 0.55;
|
|
108
|
-
};
|
|
109
|
-
readonly arrow: {
|
|
110
|
-
readonly columnSpacing: 2;
|
|
111
|
-
readonly columnOffset: 0.5;
|
|
112
|
-
readonly sampleSpacing: 0.78;
|
|
113
|
-
readonly sampleStartZ: -0.45;
|
|
114
|
-
readonly baseY: 0.1;
|
|
115
|
-
};
|
|
116
|
-
readonly axes: {
|
|
117
|
-
readonly columnSpacing: 2.2;
|
|
118
|
-
readonly columnOffset: 0.5;
|
|
119
|
-
readonly sampleSpacing: 0.86;
|
|
120
|
-
readonly sampleStartZ: -0.45;
|
|
121
|
-
readonly baseY: 0.1;
|
|
122
|
-
readonly perColumnSpacing: {
|
|
123
|
-
readonly 0: 1.05;
|
|
124
|
-
readonly 3: 1.05;
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
readonly grid: {
|
|
128
|
-
readonly columnSpacing: 2;
|
|
129
|
-
readonly columnOffset: 0.5;
|
|
130
|
-
readonly sampleSpacing: 0.72;
|
|
131
|
-
readonly sampleStartZ: -0.45;
|
|
132
|
-
readonly baseY: 0.06;
|
|
133
|
-
};
|
|
134
|
-
readonly rect: {
|
|
135
|
-
readonly columnSpacing: 2;
|
|
136
|
-
readonly columnOffset: 0.5;
|
|
137
|
-
readonly sampleSpacing: 0.62;
|
|
138
|
-
readonly sampleStartZ: -0.45;
|
|
139
|
-
readonly baseY: 0.1;
|
|
140
|
-
readonly perColumnSpacing: {
|
|
141
|
-
readonly 1: 0.9;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
readonly box: {
|
|
145
|
-
readonly columnSpacing: 2;
|
|
146
|
-
readonly columnOffset: 0.5;
|
|
147
|
-
readonly sampleSpacing: 0.82;
|
|
148
|
-
readonly sampleStartZ: -0.45;
|
|
149
|
-
readonly baseY: 0.08;
|
|
150
|
-
readonly perColumnSpacing: {
|
|
151
|
-
readonly 1: 1.05;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
readonly arc: {
|
|
155
|
-
readonly columnSpacing: 2;
|
|
156
|
-
readonly columnOffset: 0.5;
|
|
157
|
-
readonly sampleSpacing: 0.92;
|
|
158
|
-
readonly sampleStartZ: -0.45;
|
|
159
|
-
readonly baseY: 0.1;
|
|
160
|
-
readonly perColumnSpacing: {
|
|
161
|
-
readonly 1: 1.15;
|
|
162
|
-
readonly 2: 1.08;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
readonly curve: {
|
|
166
|
-
readonly columnSpacing: 2;
|
|
167
|
-
readonly columnOffset: 0.5;
|
|
168
|
-
readonly sampleSpacing: 0.82;
|
|
169
|
-
readonly sampleStartZ: -2;
|
|
170
|
-
readonly baseY: 0.1;
|
|
171
|
-
readonly perColumnSpacing: {
|
|
172
|
-
readonly 2: number;
|
|
173
|
-
readonly 4: number;
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
readonly sphere: {
|
|
177
|
-
readonly columnSpacing: 2;
|
|
178
|
-
readonly columnOffset: 0.5;
|
|
179
|
-
readonly sampleSpacing: 0.86;
|
|
180
|
-
readonly sampleStartZ: -0.45;
|
|
181
|
-
readonly baseY: 0.1;
|
|
182
|
-
readonly perColumnSpacing: {
|
|
183
|
-
readonly 1: 1.08;
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
readonly cone: {
|
|
187
|
-
readonly columnSpacing: 2;
|
|
188
|
-
readonly columnOffset: 0.5;
|
|
189
|
-
readonly sampleSpacing: 0.84;
|
|
190
|
-
readonly sampleStartZ: -0.45;
|
|
191
|
-
readonly baseY: 0.1;
|
|
192
|
-
readonly perColumnSpacing: {
|
|
193
|
-
readonly 1: 1.05;
|
|
194
|
-
readonly 2: 1.08;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
readonly cylinder: {
|
|
198
|
-
readonly columnSpacing: 2;
|
|
199
|
-
readonly columnOffset: 0.5;
|
|
200
|
-
readonly sampleSpacing: 0.84;
|
|
201
|
-
readonly sampleStartZ: -0.45;
|
|
202
|
-
readonly baseY: 0.1;
|
|
203
|
-
readonly perColumnSpacing: {
|
|
204
|
-
readonly 1: 1.05;
|
|
205
|
-
readonly 2: 1.08;
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
readonly capsule: {
|
|
209
|
-
readonly columnSpacing: 2;
|
|
210
|
-
readonly columnOffset: 0.5;
|
|
211
|
-
readonly sampleSpacing: 0.86;
|
|
212
|
-
readonly sampleStartZ: -0.45;
|
|
213
|
-
readonly baseY: 0.1;
|
|
214
|
-
readonly perColumnSpacing: {
|
|
215
|
-
readonly 1: 1.02;
|
|
216
|
-
readonly 2: 1.02;
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
readonly world_space_width: {
|
|
220
|
-
readonly columnSpacing: 2;
|
|
221
|
-
readonly columnOffset: 1;
|
|
222
|
-
readonly sampleSpacing: 1.25;
|
|
223
|
-
readonly sampleStartZ: -1;
|
|
224
|
-
readonly baseY: 0.55;
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
export type SceneLayoutId = keyof typeof SCENE_LAYOUTS;
|
package/dist/layout-3d.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout and drawing specifications ported from `the upstream reference`.
|
|
3
|
-
*
|
|
4
|
-
* Every reference scene shares the same layout contract, which is why it lives here rather
|
|
5
|
-
* than being re-derived per scene:
|
|
6
|
-
*
|
|
7
|
-
* ```
|
|
8
|
-
* column_x(column) = column * COLUMN_SPACING + 0.5 // COLUMN_SPACING is 2.0, axes 2.2
|
|
9
|
-
* row_z(row) = SAMPLE_START_Z - row * spacing // START_Z is -0.45, rows go along -Z
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* Each scene has its own `SAMPLE_SPACING`, and some columns override it (radius, size,
|
|
13
|
-
* angle, height). Coordinates are local to the scene root; the reference capture harness
|
|
14
|
-
* translates the whole root by `REFERENCE_OFFSET` without rescaling any geometry, so the
|
|
15
|
-
* same translation is applied here.
|
|
16
|
-
*/
|
|
17
|
-
/** `scene.position = Vector3(-10, 0, 1.5)` from `the reference capture script`. */
|
|
18
|
-
export const REFERENCE_OFFSET = [-10, 0, 1.5];
|
|
19
|
-
export function referenceOffset(p) {
|
|
20
|
-
return [p[0] + REFERENCE_OFFSET[0], p[1] + REFERENCE_OFFSET[1], p[2] + REFERENCE_OFFSET[2]];
|
|
21
|
-
}
|
|
22
|
-
/** Shared value tables used by the reference scenes. */
|
|
23
|
-
export const WIDTH_VALUES = [1, 2, 5.5, 10];
|
|
24
|
-
export const ALPHA_VALUES = [1, 0.65, 0.35, 0.1];
|
|
25
|
-
export const DASH_VALUES = [[0.1, 0.1], [0.2, 0.1], [0.4, 0.15], [0.04, 0.12]];
|
|
26
|
-
export const JOINT_VALUES = ["none", "round", "bevel", "miter"];
|
|
27
|
-
export const RADIUS_VALUES = [0.18, 0.28, 0.38, 0.5];
|
|
28
|
-
export const SEGMENT_VALUES = [8, 16, 32, 64];
|
|
29
|
-
export const ROTATION_SAMPLE_COUNT = 8;
|
|
30
|
-
export const NORMAL_SAMPLE_COUNT = 4;
|
|
31
|
-
export const WHITE = [1, 1, 1, 1];
|
|
32
|
-
export const CYAN = [0.15, 0.85, 1, 0.95];
|
|
33
|
-
export const LIME = [0.7, 1, 0.25, 1];
|
|
34
|
-
export const ORANGE = [1, 0.45, 0.2, 1];
|
|
35
|
-
export const ORANGE_SOFT = [1, 0.45, 0.2, 0.95];
|
|
36
|
-
export const VIOLET = [0.75, 0.45, 1, 1];
|
|
37
|
-
export const TEAL = [0.25, 0.95, 0.9, 1];
|
|
38
|
-
export const PINK = [1, 0.3, 0.6, 1];
|
|
39
|
-
export const GOLD = [1, 0.75, 0.25, 1];
|
|
40
|
-
/** Reference `_get_normal_sample_color` / `_get_normal_sample_width`, shared by most scenes. */
|
|
41
|
-
export function normalSampleColor(row) {
|
|
42
|
-
if (row === 1)
|
|
43
|
-
return [0.25, 0.95, 0.9, 0.35];
|
|
44
|
-
if (row === 2)
|
|
45
|
-
return [1, 0.45, 0.2, 1];
|
|
46
|
-
return [0.25, 0.95, 0.9, 1];
|
|
47
|
-
}
|
|
48
|
-
export function normalSampleWidth(row, baseWidth) {
|
|
49
|
-
return row === 3 ? 10 : baseWidth;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* reference `Color.from_hsv(h, s, v, a)`. The reference solid samples use this, so a fixed
|
|
53
|
-
* palette color cannot reproduce them. `h` is in `[0, 1]`, matching reference.
|
|
54
|
-
*/
|
|
55
|
-
export function fromHsv(h, s, v, a) {
|
|
56
|
-
const hue = ((h % 1) + 1) % 1;
|
|
57
|
-
const i = Math.floor(hue * 6);
|
|
58
|
-
const f = hue * 6 - i;
|
|
59
|
-
const p = v * (1 - s);
|
|
60
|
-
const q = v * (1 - s * f);
|
|
61
|
-
const t = v * (1 - s * (1 - f));
|
|
62
|
-
switch (i % 6) {
|
|
63
|
-
case 0: return [v, t, p, a];
|
|
64
|
-
case 1: return [q, v, p, a];
|
|
65
|
-
case 2: return [p, v, t, a];
|
|
66
|
-
case 3: return [p, q, v, a];
|
|
67
|
-
case 4: return [t, p, v, a];
|
|
68
|
-
default: return [v, p, q, a];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export function normalizeVector(p) {
|
|
72
|
-
const length = Math.hypot(p[0], p[1], p[2]) || 1;
|
|
73
|
-
return [p[0] / length, p[1] / length, p[2] / length];
|
|
74
|
-
}
|
|
75
|
-
export function crossVector(a, b) {
|
|
76
|
-
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
77
|
-
}
|
|
78
|
-
/** reference `Vector3.rotated(axis, angle)` equivalent (right-handed Rodrigues). */
|
|
79
|
-
export function rotateAroundAxis(p, axis, angle) {
|
|
80
|
-
const a = normalizeVector(axis);
|
|
81
|
-
const cos = Math.cos(angle);
|
|
82
|
-
const sin = Math.sin(angle);
|
|
83
|
-
const dot = p[0] * a[0] + p[1] * a[1] + p[2] * a[2];
|
|
84
|
-
const cross = crossVector(a, p);
|
|
85
|
-
return [
|
|
86
|
-
p[0] * cos + cross[0] * sin + a[0] * dot * (1 - cos),
|
|
87
|
-
p[1] * cos + cross[1] * sin + a[1] * dot * (1 - cos),
|
|
88
|
-
p[2] * cos + cross[2] * sin + a[2] * dot * (1 - cos),
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
/** Port of `_get_circle_rotation(normal, angle)` from `circle.gd`. */
|
|
92
|
-
export function circleBasis(normal, angle) {
|
|
93
|
-
const n = normalizeVector(normal);
|
|
94
|
-
const reference = Math.abs(n[0]) > 0.95 ? [0, 0, 1] : [1, 0, 0];
|
|
95
|
-
const projection = reference[0] * n[0] + reference[1] * n[1] + reference[2] * n[2];
|
|
96
|
-
const planar = [reference[0] - n[0] * projection, reference[1] - n[1] * projection, reference[2] - n[2] * projection];
|
|
97
|
-
const widthAxis = normalizeVector(rotateAroundAxis(normalizeVector(planar), n, angle));
|
|
98
|
-
const heightAxis = normalizeVector(crossVector(n, widthAxis));
|
|
99
|
-
return { x: widthAxis, y: heightAxis, z: n };
|
|
100
|
-
}
|
|
101
|
-
/** Points on a circle in the plane spanned by a reference rotation basis. */
|
|
102
|
-
export function basisCirclePoints(centerLocal, radius, segments, basis) {
|
|
103
|
-
const center = referenceOffset(centerLocal);
|
|
104
|
-
const points = [];
|
|
105
|
-
for (let i = 0; i < segments; i++) {
|
|
106
|
-
const angle = i / segments * Math.PI * 2;
|
|
107
|
-
const cos = Math.cos(angle) * radius;
|
|
108
|
-
const sin = Math.sin(angle) * radius;
|
|
109
|
-
points.push([
|
|
110
|
-
center[0] + basis.x[0] * cos + basis.y[0] * sin,
|
|
111
|
-
center[1] + basis.x[1] * cos + basis.y[1] * sin,
|
|
112
|
-
center[2] + basis.x[2] * cos + basis.y[2] * sin,
|
|
113
|
-
]);
|
|
114
|
-
}
|
|
115
|
-
return points;
|
|
116
|
-
}
|
|
117
|
-
export function createLayout(layout, baseY) {
|
|
118
|
-
const columnX = (column) => column * layout.columnSpacing + layout.columnOffset;
|
|
119
|
-
const rowSpacing = (column) => layout.perColumnSpacing?.[column] ?? layout.sampleSpacing;
|
|
120
|
-
const rowZ = (column, row) => layout.sampleStartZ - row * rowSpacing(column);
|
|
121
|
-
const at = (column, row) => {
|
|
122
|
-
const y = layout.columnY === undefined ? baseY : layout.columnY(column, row, baseY);
|
|
123
|
-
return referenceOffset([columnX(column), y, rowZ(column, row)]);
|
|
124
|
-
};
|
|
125
|
-
/** Local (untranslated) centre, for functions that must offset before the scene shift. */
|
|
126
|
-
const atLocal = (column, row) => {
|
|
127
|
-
const y = layout.columnY === undefined ? baseY : layout.columnY(column, row, baseY);
|
|
128
|
-
return [columnX(column), y, rowZ(column, row)];
|
|
129
|
-
};
|
|
130
|
-
return { columnX, rowZ, rowSpacing, at, atLocal };
|
|
131
|
-
}
|
|
132
|
-
/** Reference `circle.gd` layout: radius column uses 1.15 row spacing, the rest 0.82. */
|
|
133
|
-
export const CIRCLE_REFERENCE_LAYOUT = {
|
|
134
|
-
columnSpacing: 2,
|
|
135
|
-
columnOffset: 0.5,
|
|
136
|
-
sampleSpacing: 0.82,
|
|
137
|
-
sampleStartZ: -0.45,
|
|
138
|
-
perColumnSpacing: { 1: 1.15 },
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Per-scene layouts, copied from the constants at the top of each `examples/*.gd`.
|
|
142
|
-
*
|
|
143
|
-
* Every reference scene differs only in these numbers, so they are data here rather than
|
|
144
|
-
* duplicated coordinate math. `columnSpacing` is 2.0 everywhere except `axes` (2.2).
|
|
145
|
-
*/
|
|
146
|
-
export const SCENE_LAYOUTS = {
|
|
147
|
-
/** `index.gd`: absolute origin, its own row spacing, samples lifted to y = 0.55. */
|
|
148
|
-
index: { columnSpacing: 2, columnOffset: 1, sampleSpacing: 1.25, sampleStartZ: -1, baseY: 0.55 },
|
|
149
|
-
arrow: { columnSpacing: 2, columnOffset: 0.5, sampleSpacing: 0.78, sampleStartZ: -0.45, baseY: 0.1 },
|
|
150
|
-
axes: {
|
|
151
|
-
columnSpacing: 2.2,
|
|
152
|
-
columnOffset: 0.5,
|
|
153
|
-
sampleSpacing: 0.86,
|
|
154
|
-
sampleStartZ: -0.45,
|
|
155
|
-
baseY: 0.1,
|
|
156
|
-
perColumnSpacing: { 0: 1.05, 3: 1.05 },
|
|
157
|
-
},
|
|
158
|
-
grid: { columnSpacing: 2, columnOffset: 0.5, sampleSpacing: 0.72, sampleStartZ: -0.45, baseY: 0.06 },
|
|
159
|
-
rect: {
|
|
160
|
-
columnSpacing: 2,
|
|
161
|
-
columnOffset: 0.5,
|
|
162
|
-
sampleSpacing: 0.62,
|
|
163
|
-
sampleStartZ: -0.45,
|
|
164
|
-
baseY: 0.1,
|
|
165
|
-
perColumnSpacing: { 1: 0.9 },
|
|
166
|
-
},
|
|
167
|
-
box: {
|
|
168
|
-
columnSpacing: 2,
|
|
169
|
-
columnOffset: 0.5,
|
|
170
|
-
sampleSpacing: 0.82,
|
|
171
|
-
sampleStartZ: -0.45,
|
|
172
|
-
baseY: 0.08,
|
|
173
|
-
perColumnSpacing: { 1: 1.05 },
|
|
174
|
-
},
|
|
175
|
-
arc: {
|
|
176
|
-
columnSpacing: 2,
|
|
177
|
-
columnOffset: 0.5,
|
|
178
|
-
sampleSpacing: 0.92,
|
|
179
|
-
sampleStartZ: -0.45,
|
|
180
|
-
baseY: 0.1,
|
|
181
|
-
perColumnSpacing: { 1: 1.15, 2: 1.08 },
|
|
182
|
-
},
|
|
183
|
-
// `curve.gd`: rows start at EXAMPLE_START_Z = -2.0; the transform and closed
|
|
184
|
-
// columns widen their row spacing to 0.85x and 1.05x of SAMPLE_SPACING.
|
|
185
|
-
curve: {
|
|
186
|
-
columnSpacing: 2,
|
|
187
|
-
columnOffset: 0.5,
|
|
188
|
-
sampleSpacing: 0.82,
|
|
189
|
-
sampleStartZ: -2,
|
|
190
|
-
baseY: 0.1,
|
|
191
|
-
perColumnSpacing: { 2: 0.82 * 0.85, 4: 0.82 * 1.05 },
|
|
192
|
-
},
|
|
193
|
-
sphere: {
|
|
194
|
-
columnSpacing: 2,
|
|
195
|
-
columnOffset: 0.5,
|
|
196
|
-
sampleSpacing: 0.86,
|
|
197
|
-
sampleStartZ: -0.45,
|
|
198
|
-
baseY: 0.1,
|
|
199
|
-
perColumnSpacing: { 1: 1.08 },
|
|
200
|
-
},
|
|
201
|
-
cone: {
|
|
202
|
-
columnSpacing: 2,
|
|
203
|
-
columnOffset: 0.5,
|
|
204
|
-
sampleSpacing: 0.84,
|
|
205
|
-
sampleStartZ: -0.45,
|
|
206
|
-
baseY: 0.1,
|
|
207
|
-
perColumnSpacing: { 1: 1.05, 2: 1.08 },
|
|
208
|
-
},
|
|
209
|
-
cylinder: {
|
|
210
|
-
columnSpacing: 2,
|
|
211
|
-
columnOffset: 0.5,
|
|
212
|
-
sampleSpacing: 0.84,
|
|
213
|
-
sampleStartZ: -0.45,
|
|
214
|
-
baseY: 0.1,
|
|
215
|
-
perColumnSpacing: { 1: 1.05, 2: 1.08 },
|
|
216
|
-
},
|
|
217
|
-
capsule: {
|
|
218
|
-
columnSpacing: 2,
|
|
219
|
-
columnOffset: 0.5,
|
|
220
|
-
sampleSpacing: 0.86,
|
|
221
|
-
sampleStartZ: -0.45,
|
|
222
|
-
baseY: 0.1,
|
|
223
|
-
perColumnSpacing: { 1: 1.02, 2: 1.02 },
|
|
224
|
-
},
|
|
225
|
-
world_space_width: { columnSpacing: 2, columnOffset: 1, sampleSpacing: 1.25, sampleStartZ: -1, baseY: 0.55 },
|
|
226
|
-
};
|
package/dist/scene-examples.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export type ExampleColumn = {
|
|
2
|
-
readonly label: string;
|
|
3
|
-
readonly samples: readonly string[];
|
|
4
|
-
readonly implemented: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type SceneExample = {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly title: string;
|
|
9
|
-
readonly description: string;
|
|
10
|
-
readonly notes?: string;
|
|
11
|
-
readonly columns: readonly ExampleColumn[];
|
|
12
|
-
readonly implemented: boolean;
|
|
13
|
-
/** Which camera drives the page: the gallery's 3D orbit camera by default, or the 2D pan/zoom one. */
|
|
14
|
-
readonly family?: "2d" | "3d";
|
|
15
|
-
/**
|
|
16
|
-
* Sidebar grouping. Defaults to `family`, so the 2D pages land in "2D Graphics" and every 3D
|
|
17
|
-
* page in "3D Graphics"; the text pages name "text" explicitly, since they use the 3D camera
|
|
18
|
-
* without being 3D geometry pages.
|
|
19
|
-
*/
|
|
20
|
-
readonly group?: "3d" | "2d" | "text";
|
|
21
|
-
/**
|
|
22
|
-
* World-space extent the 2D camera fits to this page, in `world2d` units. Only read when
|
|
23
|
-
* `family` is "2d"; the page draws around the origin.
|
|
24
|
-
*/
|
|
25
|
-
readonly view2d?: {
|
|
26
|
-
readonly width: number;
|
|
27
|
-
readonly height: number;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Hide the infinite grid while this example is selected.
|
|
31
|
-
*
|
|
32
|
-
* A screen-space page is its own content in pixel space, so the grid is a world-space reference
|
|
33
|
-
* that can only cross it as diagonal lines, so those pages set `true`. A world-space page that
|
|
34
|
-
* wants the grid as its ground plane says `false` explicitly; leaving the flag unset keeps whatever
|
|
35
|
-
* the sidebar shows, which is what every other world-space example wants.
|
|
36
|
-
*/
|
|
37
|
-
readonly hideGrid?: boolean;
|
|
38
|
-
};
|
|
39
|
-
export declare const SCENE_EXAMPLES: readonly SceneExample[];
|