@vim3d/core 0.2.3 → 0.2.4
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 +7 -0
- package/compile.d.ts +6 -1
- package/compile.js +55 -51
- package/contexts.d.ts +5 -1
- package/contexts.js +45 -0
- package/esm/compile.js +57 -54
- package/esm/contexts.js +42 -0
- package/esm/evaluate.js +8 -2
- package/esm/index.js +1 -0
- package/esm/model.js +2 -1
- package/esm/storage.js +575 -0
- package/evaluate.js +8 -2
- package/index.d.ts +2 -0
- package/index.js +6 -1
- package/model.d.ts +20 -4
- package/model.js +4 -2
- package/package.json +3 -2
- package/storage.d.ts +36 -0
- package/storage.js +581 -0
package/model.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Expression } from './expression.js';
|
|
2
|
-
import type { Extensions } from './contexts.js';
|
|
2
|
+
import type { Extensions, ExtensionSource } from './contexts.js';
|
|
3
3
|
import type { ChannelOperatorDefinition } from './ch-operators.js';
|
|
4
4
|
import type { RampStop } from './ramp.js';
|
|
5
5
|
import { type CompiledScene, type GeometrySnapshot, type LightKind, type Matrix4, type ObjectKind, type SourceLocation, type Vec3 } from './types.js';
|
|
@@ -71,12 +71,17 @@ export type Driver = ActiveRange & ({
|
|
|
71
71
|
freq: number;
|
|
72
72
|
shift: number;
|
|
73
73
|
});
|
|
74
|
-
export
|
|
74
|
+
export type PathBinding = ActiveRange & {
|
|
75
75
|
curve: SceneObject;
|
|
76
|
-
freq: number;
|
|
77
76
|
shift: number;
|
|
78
77
|
offset: Vec3;
|
|
79
|
-
}
|
|
78
|
+
} & ({
|
|
79
|
+
freq: number;
|
|
80
|
+
position?: never;
|
|
81
|
+
} | {
|
|
82
|
+
freq?: never;
|
|
83
|
+
position: Expression;
|
|
84
|
+
});
|
|
80
85
|
export interface AimBinding extends ActiveRange {
|
|
81
86
|
target: SceneObject;
|
|
82
87
|
}
|
|
@@ -84,8 +89,16 @@ export type PropertyEdit = (state: Authored) => void;
|
|
|
84
89
|
export interface Event {
|
|
85
90
|
frame: number;
|
|
86
91
|
object: SceneObject;
|
|
92
|
+
command: string;
|
|
93
|
+
args: string[];
|
|
94
|
+
source: SourceLocation;
|
|
87
95
|
edit: PropertyEdit;
|
|
88
96
|
}
|
|
97
|
+
export interface ContextWire {
|
|
98
|
+
to: string;
|
|
99
|
+
input: string;
|
|
100
|
+
from: ExtensionSource;
|
|
101
|
+
}
|
|
89
102
|
export interface Plan {
|
|
90
103
|
extensions: Extensions;
|
|
91
104
|
audioChannels: ReadonlySet<string>;
|
|
@@ -94,6 +107,8 @@ export interface Plan {
|
|
|
94
107
|
drivers: Map<string, Driver[]>;
|
|
95
108
|
events: Event[];
|
|
96
109
|
order: string[];
|
|
110
|
+
inputs: Map<string, Set<string>>;
|
|
111
|
+
contextWires: ContextWire[];
|
|
97
112
|
}
|
|
98
113
|
export declare const plans: WeakMap<CompiledScene, Plan>;
|
|
99
114
|
export declare const objectPath: (object: SceneObject) => string;
|
|
@@ -108,6 +123,7 @@ export declare const copyState: (state: Authored) => Authored;
|
|
|
108
123
|
export declare const active: (f: number, range: ActiveRange) => boolean;
|
|
109
124
|
export declare const isColor: (param: string) => boolean;
|
|
110
125
|
export declare function defaults(kind: ObjectKind): Authored;
|
|
126
|
+
export declare const isNumberLiteral: (text: string) => boolean;
|
|
111
127
|
export declare function readNumber(text: string, source: SourceLocation): number;
|
|
112
128
|
export declare function readFrame(text: string, source: SourceLocation): number;
|
|
113
129
|
export declare function checkArity(command: string, args: string[], counts: readonly number[], source: SourceLocation): void;
|
package/model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.editCommands = exports.isColor = exports.active = exports.copyState = exports.vector = exports.scales = exports.rotations = exports.translations = exports.worldStep = exports.positionStep = exports.channelPath = exports.objectPath = exports.plans = void 0;
|
|
3
|
+
exports.editCommands = exports.isNumberLiteral = exports.isColor = exports.active = exports.copyState = exports.vector = exports.scales = exports.rotations = exports.translations = exports.worldStep = exports.positionStep = exports.channelPath = exports.objectPath = exports.plans = void 0;
|
|
4
4
|
exports.defaults = defaults;
|
|
5
5
|
exports.readNumber = readNumber;
|
|
6
6
|
exports.readFrame = readFrame;
|
|
@@ -42,8 +42,10 @@ function defaults(kind) {
|
|
|
42
42
|
Object.assign(parameters, { fovy: 45, znear: 0.1, zfar: 1000 });
|
|
43
43
|
return { parameters, up: math_js_1.worldUp, light: 'point', visible: true, enabled: true };
|
|
44
44
|
}
|
|
45
|
+
const isNumberLiteral = (text) => /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(text);
|
|
46
|
+
exports.isNumberLiteral = isNumberLiteral;
|
|
45
47
|
function readNumber(text, source) {
|
|
46
|
-
if (
|
|
48
|
+
if (!(0, exports.isNumberLiteral)(text)) {
|
|
47
49
|
(0, types_js_1.fail)('invalid-number', 'Expected a finite number, got ' + JSON.stringify(text), source);
|
|
48
50
|
}
|
|
49
51
|
return (0, types_js_1.finite)(Number(text), 'Number', source);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vim3d/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "A shared scene model for Vim3D.",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/pyramation/vim3d/tree/master/js/packages/core",
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
"url": "https://github.com/pyramation/vim3d/issues"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vim3d/parser": "^0.2.
|
|
24
|
+
"@vim3d/parser": "^0.2.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"ajv": "^8.20.0",
|
|
27
28
|
"makage": "^0.8.0"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
package/storage.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type CompiledScene, type CompileOptions, type GraphEdge, type GraphPortType, type Result } from './types.js';
|
|
2
|
+
export interface StorageProp {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly value?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export interface StorageNode {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly type: string;
|
|
9
|
+
readonly props?: readonly StorageProp[];
|
|
10
|
+
readonly nodes?: readonly StorageNode[];
|
|
11
|
+
readonly edges?: readonly GraphEdge[];
|
|
12
|
+
}
|
|
13
|
+
interface Declaration {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly type?: GraphPortType;
|
|
16
|
+
readonly multi?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface StorageDefinition {
|
|
19
|
+
readonly context: string;
|
|
20
|
+
readonly category: string;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly inputs?: readonly Declaration[];
|
|
23
|
+
readonly outputs?: readonly Declaration[];
|
|
24
|
+
readonly props?: readonly Omit<Declaration, 'multi'>[];
|
|
25
|
+
}
|
|
26
|
+
export interface StorageGraph {
|
|
27
|
+
readonly context: 'vim3d';
|
|
28
|
+
readonly nodes: readonly StorageNode[];
|
|
29
|
+
readonly edges: readonly GraphEdge[];
|
|
30
|
+
readonly definitions: readonly StorageDefinition[];
|
|
31
|
+
}
|
|
32
|
+
export declare function toStorageGraph(scene: CompiledScene): StorageGraph;
|
|
33
|
+
export declare function fromStorageGraph(graph: StorageGraph, options?: Pick<CompileOptions, 'contexts'>): Result<CompiledScene>;
|
|
34
|
+
export declare function serializeStorageGraph(graph: StorageGraph): string;
|
|
35
|
+
export declare function hashStorageGraph(graph: StorageGraph): Promise<string>;
|
|
36
|
+
export {};
|