@kiberon-labs/behave-graph-scene 1.0.0 → 2.0.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/.storybook/main.ts +18 -0
- package/.storybook/preview.ts +16 -0
- package/.storybook/vscode.css +822 -0
- package/.turbo/turbo-build.log +8 -0
- package/CHANGELOG.md +84 -0
- package/LICENSE +6 -0
- package/README.md +13 -0
- package/dist/Abstractions/Drivers/DummyScene.d.ts +64 -0
- package/dist/Abstractions/Drivers/DummyScene.d.ts.map +1 -0
- package/dist/Abstractions/Drivers/DummyScene.js +115 -0
- package/dist/Abstractions/Drivers/DummyScene.js.map +1 -0
- package/dist/Abstractions/IScene.d.ts +75 -0
- package/dist/Abstractions/IScene.d.ts.map +1 -0
- package/dist/Abstractions/IScene.js +19 -0
- package/dist/Abstractions/IScene.js.map +1 -0
- package/dist/GLTFJson.d.ts +33 -0
- package/dist/GLTFJson.d.ts.map +1 -0
- package/dist/Nodes/Actions/AddLight.d.ts +21 -0
- package/dist/Nodes/Actions/AddLight.d.ts.map +1 -0
- package/dist/Nodes/Actions/AddLight.js +38 -0
- package/dist/Nodes/Actions/AddLight.js.map +1 -0
- package/dist/Nodes/Actions/CloneMesh.d.ts +16 -0
- package/dist/Nodes/Actions/CloneMesh.d.ts.map +1 -0
- package/dist/Nodes/Actions/CloneMesh.js +28 -0
- package/dist/Nodes/Actions/CloneMesh.js.map +1 -0
- package/dist/Nodes/Actions/CreateMesh.d.ts +22 -0
- package/dist/Nodes/Actions/CreateMesh.d.ts.map +1 -0
- package/dist/Nodes/Actions/CreateMesh.js +44 -0
- package/dist/Nodes/Actions/CreateMesh.js.map +1 -0
- package/dist/Nodes/Actions/DeleteMesh.d.ts +15 -0
- package/dist/Nodes/Actions/DeleteMesh.d.ts.map +1 -0
- package/dist/Nodes/Actions/DeleteMesh.js +27 -0
- package/dist/Nodes/Actions/DeleteMesh.js.map +1 -0
- package/dist/Nodes/Actions/EaseSceneProperty.d.ts +23 -0
- package/dist/Nodes/Actions/EaseSceneProperty.d.ts.map +1 -0
- package/dist/Nodes/Actions/EaseSceneProperty.js +73 -0
- package/dist/Nodes/Actions/EaseSceneProperty.js.map +1 -0
- package/dist/Nodes/Actions/LookAt.d.ts +16 -0
- package/dist/Nodes/Actions/LookAt.d.ts.map +1 -0
- package/dist/Nodes/Actions/LookAt.js +35 -0
- package/dist/Nodes/Actions/LookAt.js.map +1 -0
- package/dist/Nodes/Actions/MoveTowards.d.ts +21 -0
- package/dist/Nodes/Actions/MoveTowards.d.ts.map +1 -0
- package/dist/Nodes/Actions/MoveTowards.js +46 -0
- package/dist/Nodes/Actions/MoveTowards.js.map +1 -0
- package/dist/Nodes/Actions/RemoveLight.d.ts +15 -0
- package/dist/Nodes/Actions/RemoveLight.d.ts.map +1 -0
- package/dist/Nodes/Actions/RemoveLight.js +27 -0
- package/dist/Nodes/Actions/RemoveLight.js.map +1 -0
- package/dist/Nodes/Actions/SetLightProperty.d.ts +25 -0
- package/dist/Nodes/Actions/SetLightProperty.d.ts.map +1 -0
- package/dist/Nodes/Actions/SetLightProperty.js +64 -0
- package/dist/Nodes/Actions/SetLightProperty.js.map +1 -0
- package/dist/Nodes/Actions/SetMaterialProperty.d.ts +25 -0
- package/dist/Nodes/Actions/SetMaterialProperty.d.ts.map +1 -0
- package/dist/Nodes/Actions/SetMaterialProperty.js +69 -0
- package/dist/Nodes/Actions/SetMaterialProperty.js.map +1 -0
- package/dist/Nodes/Actions/SetMeshPosition.d.ts +18 -0
- package/dist/Nodes/Actions/SetMeshPosition.d.ts.map +1 -0
- package/dist/Nodes/Actions/SetMeshPosition.js +34 -0
- package/dist/Nodes/Actions/SetMeshPosition.js.map +1 -0
- package/dist/Nodes/Actions/SetMeshVisible.d.ts +16 -0
- package/dist/Nodes/Actions/SetMeshVisible.d.ts.map +1 -0
- package/dist/Nodes/Actions/SetMeshVisible.js +28 -0
- package/dist/Nodes/Actions/SetMeshVisible.js.map +1 -0
- package/dist/Nodes/Actions/SetSceneProperty.d.ts +16 -0
- package/dist/Nodes/Actions/SetSceneProperty.d.ts.map +1 -0
- package/dist/Nodes/Actions/SetSceneProperty.js +28 -0
- package/dist/Nodes/Actions/SetSceneProperty.js.map +1 -0
- package/dist/Nodes/Events/OnAnyMeshClicked.d.ts +13 -0
- package/dist/Nodes/Events/OnAnyMeshClicked.d.ts.map +1 -0
- package/dist/Nodes/Events/OnAnyMeshClicked.js +34 -0
- package/dist/Nodes/Events/OnAnyMeshClicked.js.map +1 -0
- package/dist/Nodes/Events/OnSceneChanged.d.ts +12 -0
- package/dist/Nodes/Events/OnSceneChanged.d.ts.map +1 -0
- package/dist/Nodes/Events/OnSceneChanged.js +28 -0
- package/dist/Nodes/Events/OnSceneChanged.js.map +1 -0
- package/dist/Nodes/Events/OnSceneNodeClick.d.ts +18 -0
- package/dist/Nodes/Events/OnSceneNodeClick.d.ts.map +1 -0
- package/dist/Nodes/Events/OnSceneNodeClick.js +39 -0
- package/dist/Nodes/Events/OnSceneNodeClick.js.map +1 -0
- package/dist/Nodes/Logic/ColorNodes.d.ts +23 -0
- package/dist/Nodes/Logic/ColorNodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/ColorNodes.js +137 -0
- package/dist/Nodes/Logic/ColorNodes.js.map +1 -0
- package/dist/Nodes/Logic/EulerNodes.d.ts +22 -0
- package/dist/Nodes/Logic/EulerNodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/EulerNodes.js +132 -0
- package/dist/Nodes/Logic/EulerNodes.js.map +1 -0
- package/dist/Nodes/Logic/Mat3Nodes.d.ts +31 -0
- package/dist/Nodes/Logic/Mat3Nodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/Mat3Nodes.js +199 -0
- package/dist/Nodes/Logic/Mat3Nodes.js.map +1 -0
- package/dist/Nodes/Logic/Mat4Nodes.d.ts +38 -0
- package/dist/Nodes/Logic/Mat4Nodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/Mat4Nodes.js +267 -0
- package/dist/Nodes/Logic/Mat4Nodes.js.map +1 -0
- package/dist/Nodes/Logic/QuatNodes.d.ts +28 -0
- package/dist/Nodes/Logic/QuatNodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/QuatNodes.js +173 -0
- package/dist/Nodes/Logic/QuatNodes.js.map +1 -0
- package/dist/Nodes/Logic/Vec2Nodes.d.ts +22 -0
- package/dist/Nodes/Logic/Vec2Nodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/Vec2Nodes.js +115 -0
- package/dist/Nodes/Logic/Vec2Nodes.js.map +1 -0
- package/dist/Nodes/Logic/Vec3Nodes.d.ts +23 -0
- package/dist/Nodes/Logic/Vec3Nodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/Vec3Nodes.js +137 -0
- package/dist/Nodes/Logic/Vec3Nodes.js.map +1 -0
- package/dist/Nodes/Logic/Vec4Nodes.d.ts +22 -0
- package/dist/Nodes/Logic/Vec4Nodes.d.ts.map +1 -0
- package/dist/Nodes/Logic/Vec4Nodes.js +132 -0
- package/dist/Nodes/Logic/Vec4Nodes.js.map +1 -0
- package/dist/Nodes/Logic/VecElements.d.ts +9 -0
- package/dist/Nodes/Logic/VecElements.d.ts.map +1 -0
- package/dist/Nodes/Logic/VecElements.js +22 -0
- package/dist/Nodes/Logic/VecElements.js.map +1 -0
- package/dist/Nodes/Queries/GetDistanceBetween.d.ts +18 -0
- package/dist/Nodes/Queries/GetDistanceBetween.d.ts.map +1 -0
- package/dist/Nodes/Queries/GetDistanceBetween.js +30 -0
- package/dist/Nodes/Queries/GetDistanceBetween.js.map +1 -0
- package/dist/Nodes/Queries/GetLightProperty.d.ts +23 -0
- package/dist/Nodes/Queries/GetLightProperty.d.ts.map +1 -0
- package/dist/Nodes/Queries/GetLightProperty.js +68 -0
- package/dist/Nodes/Queries/GetLightProperty.js.map +1 -0
- package/dist/Nodes/Queries/GetMaterialProperty.d.ts +23 -0
- package/dist/Nodes/Queries/GetMaterialProperty.d.ts.map +1 -0
- package/dist/Nodes/Queries/GetMaterialProperty.js +69 -0
- package/dist/Nodes/Queries/GetMaterialProperty.js.map +1 -0
- package/dist/Nodes/Queries/GetMeshPosition.d.ts +16 -0
- package/dist/Nodes/Queries/GetMeshPosition.d.ts.map +1 -0
- package/dist/Nodes/Queries/GetMeshPosition.js +29 -0
- package/dist/Nodes/Queries/GetMeshPosition.js.map +1 -0
- package/dist/Nodes/Queries/GetSceneProperty.d.ts +14 -0
- package/dist/Nodes/Queries/GetSceneProperty.d.ts.map +1 -0
- package/dist/Nodes/Queries/GetSceneProperty.js +23 -0
- package/dist/Nodes/Queries/GetSceneProperty.js.map +1 -0
- package/dist/Values/ColorValue.d.ts +7 -0
- package/dist/Values/ColorValue.d.ts.map +1 -0
- package/dist/Values/ColorValue.js +20 -0
- package/dist/Values/ColorValue.js.map +1 -0
- package/dist/Values/EulerValue.d.ts +7 -0
- package/dist/Values/EulerValue.d.ts.map +1 -0
- package/dist/Values/EulerValue.js +20 -0
- package/dist/Values/EulerValue.js.map +1 -0
- package/dist/Values/Internal/Mat3.d.ts +43 -0
- package/dist/Values/Internal/Mat3.d.ts.map +1 -0
- package/dist/Values/Internal/Mat3.js +276 -0
- package/dist/Values/Internal/Mat3.js.map +1 -0
- package/dist/Values/Internal/Mat4.d.ts +53 -0
- package/dist/Values/Internal/Mat4.d.ts.map +1 -0
- package/dist/Values/Internal/Mat4.js +443 -0
- package/dist/Values/Internal/Mat4.js.map +1 -0
- package/dist/Values/Internal/Vec2.d.ts +25 -0
- package/dist/Values/Internal/Vec2.d.ts.map +1 -0
- package/dist/Values/Internal/Vec2.js +64 -0
- package/dist/Values/Internal/Vec2.js.map +1 -0
- package/dist/Values/Internal/Vec3.d.ts +38 -0
- package/dist/Values/Internal/Vec3.d.ts.map +1 -0
- package/dist/Values/Internal/Vec3.js +157 -0
- package/dist/Values/Internal/Vec3.js.map +1 -0
- package/dist/Values/Internal/Vec4.d.ts +49 -0
- package/dist/Values/Internal/Vec4.d.ts.map +1 -0
- package/dist/Values/Internal/Vec4.js +190 -0
- package/dist/Values/Internal/Vec4.js.map +1 -0
- package/dist/Values/Mat3Value.d.ts +7 -0
- package/dist/Values/Mat3Value.d.ts.map +1 -0
- package/dist/Values/Mat3Value.js +16 -0
- package/dist/Values/Mat3Value.js.map +1 -0
- package/dist/Values/Mat4Value.d.ts +7 -0
- package/dist/Values/Mat4Value.d.ts.map +1 -0
- package/dist/Values/Mat4Value.js +16 -0
- package/dist/Values/Mat4Value.js.map +1 -0
- package/dist/Values/QuatValue.d.ts +7 -0
- package/dist/Values/QuatValue.d.ts.map +1 -0
- package/dist/Values/QuatValue.js +21 -0
- package/dist/Values/QuatValue.js.map +1 -0
- package/dist/Values/Vec2Value.d.ts +7 -0
- package/dist/Values/Vec2Value.d.ts.map +1 -0
- package/dist/Values/Vec2Value.js +16 -0
- package/dist/Values/Vec2Value.js.map +1 -0
- package/dist/Values/Vec3Value.d.ts +7 -0
- package/dist/Values/Vec3Value.d.ts.map +1 -0
- package/dist/Values/Vec3Value.js +20 -0
- package/dist/Values/Vec3Value.js.map +1 -0
- package/dist/Values/Vec4Value.d.ts +7 -0
- package/dist/Values/Vec4Value.d.ts.map +1 -0
- package/dist/Values/Vec4Value.js +21 -0
- package/dist/Values/Vec4Value.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.js +35 -0
- package/dist/behave-graph.manifest.json +6082 -0
- package/dist/buildScene.d.ts +74 -0
- package/dist/buildScene.d.ts.map +1 -0
- package/dist/buildScene.js +304 -0
- package/dist/buildScene.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/manifest.source.d.ts +7 -0
- package/dist/manifest.source.d.ts.map +1 -0
- package/dist/manifest.source.js +54 -0
- package/dist/manifest.source.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.development.js +207 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.production.js +40 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react.development.js +766 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react.development.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react.production.js +367 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react.production.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/index.js +15 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/index.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/jsx-runtime.js +15 -0
- package/dist/node_modules/.pnpm/react@19.2.3/node_modules/react/jsx-runtime.js.map +1 -0
- package/dist/packages/nodes/scene/package.js +7 -0
- package/dist/packages/nodes/scene/package.js.map +1 -0
- package/dist/registerSceneProfile.d.ts +10 -0
- package/dist/registerSceneProfile.d.ts.map +1 -0
- package/dist/registerSceneProfile.js +112 -0
- package/dist/registerSceneProfile.js.map +1 -0
- package/dist/ui/controls/vec3.d.ts +9 -0
- package/dist/ui/controls/vec3.d.ts.map +1 -0
- package/dist/ui/controls/vec3.js +99 -0
- package/dist/ui/controls/vec3.js.map +1 -0
- package/package.json +42 -13
- package/src/Abstractions/Drivers/DummyScene.ts +110 -2
- package/src/Abstractions/IScene.ts +74 -3
- package/src/Nodes/Actions/AddLight.ts +46 -0
- package/src/Nodes/Actions/CloneMesh.ts +31 -0
- package/src/Nodes/Actions/CreateMesh.ts +47 -0
- package/src/Nodes/Actions/DeleteMesh.ts +29 -0
- package/src/Nodes/Actions/EaseSceneProperty.ts +6 -2
- package/src/Nodes/Actions/LookAt.ts +34 -0
- package/src/Nodes/Actions/MoveTowards.ts +55 -0
- package/src/Nodes/Actions/RemoveLight.ts +29 -0
- package/src/Nodes/Actions/SetLightProperty.ts +60 -0
- package/src/Nodes/Actions/SetMaterialProperty.ts +62 -0
- package/src/Nodes/Actions/SetMeshPosition.ts +37 -0
- package/src/Nodes/Actions/SetMeshVisible.ts +31 -0
- package/src/Nodes/Actions/SetSceneProperty.ts +3 -5
- package/src/Nodes/Events/OnAnyMeshClicked.ts +48 -0
- package/src/Nodes/Events/OnSceneChanged.ts +43 -0
- package/src/Nodes/Events/OnSceneNodeClick.ts +3 -3
- package/src/Nodes/Logic/Mat3Nodes.ts +0 -10
- package/src/Nodes/Logic/QuatNodes.ts +11 -11
- package/src/Nodes/Queries/GetDistanceBetween.ts +37 -0
- package/src/Nodes/Queries/GetLightProperty.ts +53 -0
- package/src/Nodes/Queries/GetMaterialProperty.ts +55 -0
- package/src/Nodes/Queries/GetMeshPosition.ts +32 -0
- package/src/Nodes/Queries/GetSceneProperty.ts +4 -5
- package/src/Values/Internal/Mat3.ts +3 -3
- package/src/Values/Internal/Mat4.ts +5 -4
- package/src/Values/Internal/Vec3.ts +5 -4
- package/src/Values/Internal/Vec4.ts +3 -2
- package/src/buildScene.ts +36 -2
- package/src/index.ts +26 -2
- package/src/manifest.source.ts +61 -0
- package/src/registerSceneProfile.ts +41 -4
- package/src/ui/controls/vec3.tsx +69 -0
- package/stories/click.stories.tsx +112 -0
- package/stories/components/DemoScene.ts +610 -0
- package/stories/components/SceneViewer.tsx +204 -0
- package/stories/components/SceneViewerPanel.tsx +41 -0
- package/stories/data/clickDemo.json +94 -0
- package/stories/data/rotate.json +402 -0
- package/stories/index.stories.tsx +90 -0
- package/stories/plugin/sceneViewerPlugin.tsx +88 -0
- package/tests/graphs/logic/Color.json +53 -53
- package/tests/graphs/logic/Euler.json +53 -53
- package/tests/graphs/logic/Quaternion.json +56 -56
- package/tests/graphs/logic/Vector2.json +50 -50
- package/tests/graphs/logic/Vector3.json +53 -53
- package/tests/graphs/logic/Vector4.json +56 -56
- package/tests/manifest.test.ts +65 -0
- package/tests/readSceneGraphs.test.ts +8 -1
- package/tests/registerSceneProfile.test.ts +6 -5
- package/tests/tsconfig.json +10 -10
- package/tsconfig.json +61 -54
- package/tsdown.config.ts +5 -1
- package/vite.config.js +7 -0
- package/src/Values/Internal/Mat2.ts +0 -214
- package/src/loadScene.ts +0 -81
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IScene } from "./Abstractions/IScene.js";
|
|
2
|
+
import { GLTFJson } from "./GLTFJson.js";
|
|
3
|
+
import { Choices } from "@kiberon-labs/behave-graph";
|
|
4
|
+
import { Material, Object3D } from "three";
|
|
5
|
+
import { GLTF } from "three-stdlib";
|
|
6
|
+
|
|
7
|
+
//#region src/buildScene.d.ts
|
|
8
|
+
declare const Resource: {
|
|
9
|
+
readonly nodes: "nodes";
|
|
10
|
+
readonly materials: "materials";
|
|
11
|
+
readonly animations: "animations";
|
|
12
|
+
};
|
|
13
|
+
type Resource = (typeof Resource)[keyof typeof Resource];
|
|
14
|
+
declare type ObjectMap = {
|
|
15
|
+
nodes: {
|
|
16
|
+
[name: string]: Object3D;
|
|
17
|
+
};
|
|
18
|
+
materials: {
|
|
19
|
+
[name: string]: Material;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type Optional<T> = { [K in keyof T]: T[K] | undefined };
|
|
23
|
+
type Path = {
|
|
24
|
+
resource: Resource;
|
|
25
|
+
index: number;
|
|
26
|
+
property: string;
|
|
27
|
+
};
|
|
28
|
+
declare function toJsonPathString({
|
|
29
|
+
index,
|
|
30
|
+
property,
|
|
31
|
+
resource: resourceType
|
|
32
|
+
}: Optional<Path>, short: boolean): string | undefined;
|
|
33
|
+
declare function parseJsonPath(jsonPath: string, short?: boolean): Path;
|
|
34
|
+
declare function applyPropertyToModel({
|
|
35
|
+
resource,
|
|
36
|
+
index,
|
|
37
|
+
property
|
|
38
|
+
}: Path, gltf: GLTF & ObjectMap, value: any, properties: Properties, setActiveAnimations: ((animation: string, active: boolean) => void) | undefined): void;
|
|
39
|
+
type ResourceOption = {
|
|
40
|
+
name: string;
|
|
41
|
+
index: number;
|
|
42
|
+
};
|
|
43
|
+
type ResourceProperties = {
|
|
44
|
+
options: ResourceOption[];
|
|
45
|
+
properties: string[];
|
|
46
|
+
};
|
|
47
|
+
type Properties = { [key in Resource]?: ResourceProperties };
|
|
48
|
+
type ParsableScene = GLTF & ObjectMap & {
|
|
49
|
+
json?: GLTFJson;
|
|
50
|
+
};
|
|
51
|
+
declare const extractProperties: (gltf: ParsableScene) => Properties;
|
|
52
|
+
declare function generateSettableChoices(properties: Properties): Choices;
|
|
53
|
+
declare function generateRaycastableChoices(properties: Properties): Choices;
|
|
54
|
+
type OnClickCallback = (jsonPath: string) => void;
|
|
55
|
+
type OnClickListener = {
|
|
56
|
+
path: Path;
|
|
57
|
+
elementName: string;
|
|
58
|
+
callbacks: OnClickCallback[];
|
|
59
|
+
};
|
|
60
|
+
type OnClickListeners = {
|
|
61
|
+
[jsonPath: string]: OnClickListener;
|
|
62
|
+
};
|
|
63
|
+
declare const buildScene: ({
|
|
64
|
+
gltf,
|
|
65
|
+
setOnClickListeners,
|
|
66
|
+
setActiveAnimations
|
|
67
|
+
}: {
|
|
68
|
+
gltf: GLTF & ObjectMap;
|
|
69
|
+
setOnClickListeners: ((cb: (existing: OnClickListeners) => OnClickListeners) => void) | undefined;
|
|
70
|
+
setActiveAnimations: ((animation: string, active: boolean) => void) | undefined;
|
|
71
|
+
}) => IScene;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ObjectMap, OnClickCallback, OnClickListener, OnClickListeners, Optional, ParsableScene, Path, ResourceOption, ResourceProperties, applyPropertyToModel, buildScene, extractProperties, generateRaycastableChoices, generateSettableChoices, parseJsonPath, toJsonPathString };
|
|
74
|
+
//# sourceMappingURL=buildScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildScene.d.ts","names":[],"sources":["../src/buildScene.ts"],"sources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U,KAAA,EAAA,MAAA;AAyIxB,CAAA;AAKY,KAAA,kBAAA,GAAkB;EAKzB,OAAA,EAJM,cAII,EAAA;EAIH,UAAA,EAAA,MAAa,EAAA;CAAG;KAJvB,UAAA,GAKH,UAJQ,QAKC,IALW,kBAKX,EAAQ;AAGN,KALD,aAAA,GAAgB,IAkD3B,GAjDC,SAIsC,GAAA;EA2ExB,IAAA,CAAA,EA9EL,QA8EK;AAUhB,CAAA;AAaY,cAlGC,iBAkGc,EAAA,CAAA,IAAA,EAlGa,aAkGb,EAAA,GAlG6B,UAkG7B;AAEf,iBAzBI,uBAAA,CA4BH,UAAe,EA5BwB,UA4BxB,CAAA,EA5BqC,OA4BrC;AAGhB,iBArBI,0BAAA,CAsBM,UAAe,EAtBkB,UAsBlB,CAAA,EAtB+B,OAsB/B;AAGxB,KAZD,eAAA,GA4KX,CAAA,QAAA,EAAA,MAAA,EAAA,GAAA,IAAA;AAhK0B,KAVf,eAAA,GAUe;EAAA,IAAA,EATnB,IASmB;EAAA,WAAA,EAAA,MAAA;EAKnB,SAAA,EAZK,eAYL,EAAA;CAAO;AAEQ,KAXX,gBAAA,GAWW;EAAqB,CAAA,QAAA,EAAA,MAAA,CAAA,EAVtB,eAUsB;CAK3C;AAoJA,cAhKY,UAgKZ,EAAA,CAAA;EAAA,IAAA;EAAA,mBAAA;EAAA;CAAA,EAAA;QA3JO,OAAO;wCAEQ,qBAAqB;;MAK3C"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { Vec3 } from "./Values/Internal/Vec3.js";
|
|
2
|
+
import { Vec4 } from "./Values/Internal/Vec4.js";
|
|
3
|
+
import { EventEmitter } from "@kiberon-labs/behave-graph";
|
|
4
|
+
import { Material, Object3D } from "three";
|
|
5
|
+
|
|
6
|
+
//#region src/buildScene.ts
|
|
7
|
+
const Resource = {
|
|
8
|
+
nodes: "nodes",
|
|
9
|
+
materials: "materials",
|
|
10
|
+
animations: "animations"
|
|
11
|
+
};
|
|
12
|
+
function toVec3(value) {
|
|
13
|
+
return new Vec3(value.x, value.y, value.z);
|
|
14
|
+
}
|
|
15
|
+
function toVec4(value) {
|
|
16
|
+
return new Vec4(value.x, value.y, value.z, value.w);
|
|
17
|
+
}
|
|
18
|
+
const shortPathRegEx = /^\/?(?<resource>[^/]+)\/(?<index>\d+)$/;
|
|
19
|
+
const jsonPathRegEx = /^\/?(?<resource>[^/]+)\/(?<index>\d+)\/(?<property>[^/]+)$/;
|
|
20
|
+
function toJsonPathString({ index, property, resource: resourceType }, short) {
|
|
21
|
+
if (short) {
|
|
22
|
+
if (!resourceType || index === void 0) return;
|
|
23
|
+
return `${resourceType}/${index}`;
|
|
24
|
+
} else {
|
|
25
|
+
if (!resourceType || index === void 0 || !property) return;
|
|
26
|
+
return `${resourceType}/${index}/${property}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function parseJsonPath(jsonPath, short = false) {
|
|
30
|
+
const matches = (short ? shortPathRegEx : jsonPathRegEx).exec(jsonPath);
|
|
31
|
+
if (matches === null) throw new Error(`can not parse jsonPath: ${jsonPath}`);
|
|
32
|
+
if (matches.groups === void 0) throw new Error(`can not parse jsonPath (no groups): ${jsonPath}`);
|
|
33
|
+
return {
|
|
34
|
+
resource: matches.groups.resource,
|
|
35
|
+
index: +matches.groups.index,
|
|
36
|
+
property: matches.groups.property
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function applyPropertyToModel({ resource, index, property }, gltf, value, properties, setActiveAnimations) {
|
|
40
|
+
const nodeName = getResourceName({
|
|
41
|
+
resource,
|
|
42
|
+
index
|
|
43
|
+
}, properties);
|
|
44
|
+
if (!nodeName) throw new Error(`could not get node at index ${index}`);
|
|
45
|
+
if (resource === Resource.nodes) {
|
|
46
|
+
const node = gltf.nodes[nodeName];
|
|
47
|
+
if (!node) {
|
|
48
|
+
console.error(`no node at path ${nodeName}`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
applyNodeModifier(property, node, value);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (resource === Resource.materials) {
|
|
55
|
+
const node = gltf.materials[nodeName];
|
|
56
|
+
if (!node) {
|
|
57
|
+
console.error(`no node at path ${nodeName}`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
applyMaterialModifier(property, node, value);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (resource === Resource.animations) {
|
|
64
|
+
if (!setActiveAnimations) {
|
|
65
|
+
console.error("cannot apply animation property without setActiveAnimations");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setActiveAnimations(nodeName, value);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.error(`unknown resource type ${resource}`);
|
|
72
|
+
}
|
|
73
|
+
const getResourceName = ({ resource, index }, properties) => {
|
|
74
|
+
return properties[resource]?.options[index]?.name;
|
|
75
|
+
};
|
|
76
|
+
const getPropertyFromModel = ({ resource, index, property }, gltf, properties) => {
|
|
77
|
+
if (resource === Resource.nodes) {
|
|
78
|
+
const nodeName = getResourceName({
|
|
79
|
+
resource,
|
|
80
|
+
index
|
|
81
|
+
}, properties);
|
|
82
|
+
if (!nodeName) throw new Error(`could not get node at index ${index}`);
|
|
83
|
+
const node = gltf.nodes[nodeName];
|
|
84
|
+
if (!node) {
|
|
85
|
+
console.error(`no node at path ${nodeName}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
getPropertyValue(property, node);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
function applyNodeModifier(property, objectRef, value) {
|
|
93
|
+
switch (property) {
|
|
94
|
+
case "visible":
|
|
95
|
+
objectRef.visible = value;
|
|
96
|
+
break;
|
|
97
|
+
case "translation": {
|
|
98
|
+
const v = value;
|
|
99
|
+
objectRef.position.set(v.x, v.y, v.z);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case "scale": {
|
|
103
|
+
const v = value;
|
|
104
|
+
objectRef.scale.set(v.x, v.y, v.z);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "rotation": {
|
|
108
|
+
const v = value;
|
|
109
|
+
objectRef.quaternion.set(v.x, v.y, v.z, v.w);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function applyMaterialModifier(property, materialRef, value) {
|
|
115
|
+
switch (property) {
|
|
116
|
+
case "color": {
|
|
117
|
+
const basic = materialRef;
|
|
118
|
+
if (basic.color) {
|
|
119
|
+
const v = value;
|
|
120
|
+
basic.color.setRGB(v.x, v.y, v.z);
|
|
121
|
+
basic.needsUpdate = true;
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getPropertyValue(property, objectRef) {
|
|
128
|
+
switch (property) {
|
|
129
|
+
case "visible": return objectRef.visible;
|
|
130
|
+
case "translation": return toVec3(objectRef.position);
|
|
131
|
+
case "scale": return toVec3(objectRef.scale);
|
|
132
|
+
case "rotation": return toVec4(objectRef.quaternion);
|
|
133
|
+
default: throw new Error(`unrecognized property: ${property}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const extractProperties = (gltf) => {
|
|
137
|
+
const nodeProperties = [
|
|
138
|
+
"visible",
|
|
139
|
+
"translation",
|
|
140
|
+
"scale",
|
|
141
|
+
"rotation",
|
|
142
|
+
"color"
|
|
143
|
+
];
|
|
144
|
+
const animationProperties = ["playing"];
|
|
145
|
+
const materialProperties = ["color"];
|
|
146
|
+
const gltfJson = gltf.parser.json;
|
|
147
|
+
const nodeOptions = gltfJson.nodes?.map(({ name }, index) => ({
|
|
148
|
+
name: name || index.toString(),
|
|
149
|
+
index
|
|
150
|
+
}));
|
|
151
|
+
const materialOptions = gltfJson.materials?.map(({ name }, index) => ({
|
|
152
|
+
name: name || index.toString(),
|
|
153
|
+
index
|
|
154
|
+
}));
|
|
155
|
+
const animationOptions = gltf.animations?.map(({ name }, index) => ({
|
|
156
|
+
name: name || index.toString(),
|
|
157
|
+
index
|
|
158
|
+
}));
|
|
159
|
+
const properties = {};
|
|
160
|
+
properties.nodes = {
|
|
161
|
+
options: nodeOptions,
|
|
162
|
+
properties: nodeProperties
|
|
163
|
+
};
|
|
164
|
+
if (materialOptions) properties.materials = {
|
|
165
|
+
options: materialOptions,
|
|
166
|
+
properties: materialProperties
|
|
167
|
+
};
|
|
168
|
+
if (animationOptions) properties.animations = {
|
|
169
|
+
options: animationOptions,
|
|
170
|
+
properties: animationProperties
|
|
171
|
+
};
|
|
172
|
+
return properties;
|
|
173
|
+
};
|
|
174
|
+
function createPropertyChoice(resource, name, property, index) {
|
|
175
|
+
return {
|
|
176
|
+
text: `${resource}/${name}/${property}`,
|
|
177
|
+
value: `${resource}/${index}/${property}`
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function generateChoicesForProperty(property, resource) {
|
|
181
|
+
if (!property) return [];
|
|
182
|
+
const choices = [];
|
|
183
|
+
property.options.forEach(({ index, name }) => {
|
|
184
|
+
property.properties.forEach((property$1) => {
|
|
185
|
+
choices.push(createPropertyChoice(resource, name, property$1, index));
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
return choices;
|
|
189
|
+
}
|
|
190
|
+
function generateSettableChoices(properties) {
|
|
191
|
+
return [
|
|
192
|
+
...generateChoicesForProperty(properties.nodes, Resource.nodes),
|
|
193
|
+
...generateChoicesForProperty(properties.materials, Resource.materials),
|
|
194
|
+
...generateChoicesForProperty(properties.animations, Resource.animations)
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
function generateRaycastableChoices(properties) {
|
|
198
|
+
const choices = [];
|
|
199
|
+
properties.nodes?.options.forEach(({ index, name }) => {
|
|
200
|
+
choices.push({
|
|
201
|
+
text: `nodes/${name}`,
|
|
202
|
+
value: `nodes/${index}`
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
return choices;
|
|
206
|
+
}
|
|
207
|
+
const buildScene = ({ gltf, setOnClickListeners, setActiveAnimations }) => {
|
|
208
|
+
const properties = extractProperties(gltf);
|
|
209
|
+
const onSceneChanged = new EventEmitter();
|
|
210
|
+
const addOnClickedListener = (jsonPath, callback) => {
|
|
211
|
+
if (!setOnClickListeners) return;
|
|
212
|
+
const path = parseJsonPath(jsonPath, true);
|
|
213
|
+
setOnClickListeners((existing) => {
|
|
214
|
+
const listenersForPath = existing[jsonPath] || {
|
|
215
|
+
path,
|
|
216
|
+
elementName: getResourceName({
|
|
217
|
+
resource: path.resource,
|
|
218
|
+
index: path.index
|
|
219
|
+
}, properties),
|
|
220
|
+
callbacks: []
|
|
221
|
+
};
|
|
222
|
+
const updatedListeners = {
|
|
223
|
+
...listenersForPath,
|
|
224
|
+
callbacks: [...listenersForPath.callbacks, callback]
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
...existing,
|
|
228
|
+
[jsonPath]: updatedListeners
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
const removeOnClickedListener = (jsonPath, callback) => {
|
|
233
|
+
if (!setOnClickListeners) return;
|
|
234
|
+
setOnClickListeners((existing) => {
|
|
235
|
+
const listenersForPath = existing[jsonPath];
|
|
236
|
+
if (!listenersForPath) return existing;
|
|
237
|
+
const updatedCallbacks = listenersForPath.callbacks.filter((x) => x !== callback);
|
|
238
|
+
if (updatedCallbacks.length > 0) {
|
|
239
|
+
const updatedListeners = {
|
|
240
|
+
...listenersForPath,
|
|
241
|
+
callback: updatedCallbacks
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
...existing,
|
|
245
|
+
[jsonPath]: updatedListeners
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const result = { ...existing };
|
|
249
|
+
delete result[jsonPath];
|
|
250
|
+
return result;
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
const getProperty = (jsonPath, _valueTypeName) => {
|
|
254
|
+
return getPropertyFromModel(parseJsonPath(jsonPath), gltf, properties);
|
|
255
|
+
};
|
|
256
|
+
const setProperty = (jsonPath, valueTypeName, value) => {
|
|
257
|
+
applyPropertyToModel(parseJsonPath(jsonPath), gltf, value, properties, setActiveAnimations);
|
|
258
|
+
onSceneChanged.emit();
|
|
259
|
+
};
|
|
260
|
+
const settableChoices = generateSettableChoices(properties);
|
|
261
|
+
const raycastableChoices = generateRaycastableChoices(properties);
|
|
262
|
+
const addOnSceneChangedListener = (listener) => {
|
|
263
|
+
onSceneChanged.addListener(listener);
|
|
264
|
+
};
|
|
265
|
+
const removeOnSceneChangedListener = (listener) => {
|
|
266
|
+
onSceneChanged.removeListener(listener);
|
|
267
|
+
};
|
|
268
|
+
const notSupported = (op) => {
|
|
269
|
+
throw new Error(`The glTF-backed scene does not support "${op}". Use a scene backend that implements the procedural mesh/light API (e.g. the demo scene) for that operation.`);
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
getProperty,
|
|
273
|
+
setProperty,
|
|
274
|
+
getProperties: () => settableChoices,
|
|
275
|
+
getRaycastableProperties: () => raycastableChoices,
|
|
276
|
+
addOnClickedListener,
|
|
277
|
+
removeOnClickedListener,
|
|
278
|
+
addOnSceneChangedListener,
|
|
279
|
+
removeOnSceneChangedListener,
|
|
280
|
+
createMesh: () => notSupported("createMesh"),
|
|
281
|
+
deleteMesh: () => notSupported("deleteMesh"),
|
|
282
|
+
getMeshNames: () => [],
|
|
283
|
+
addLight: () => notSupported("addLight"),
|
|
284
|
+
removeLight: () => notSupported("removeLight"),
|
|
285
|
+
setLightProperty: () => notSupported("setLightProperty"),
|
|
286
|
+
getLightProperty: () => notSupported("getLightProperty"),
|
|
287
|
+
getLightNames: () => [],
|
|
288
|
+
setMaterialProperty: () => notSupported("setMaterialProperty"),
|
|
289
|
+
getMaterialProperty: () => notSupported("getMaterialProperty"),
|
|
290
|
+
addOnAnyMeshClickedListener: () => notSupported("addOnAnyMeshClickedListener"),
|
|
291
|
+
removeOnAnyMeshClickedListener: () => notSupported("removeOnAnyMeshClickedListener"),
|
|
292
|
+
getMeshPosition: () => notSupported("getMeshPosition"),
|
|
293
|
+
setMeshPosition: () => notSupported("setMeshPosition"),
|
|
294
|
+
getDistanceBetween: () => notSupported("getDistanceBetween"),
|
|
295
|
+
lookAt: () => notSupported("lookAt"),
|
|
296
|
+
moveTowards: () => notSupported("moveTowards"),
|
|
297
|
+
cloneMesh: () => notSupported("cloneMesh"),
|
|
298
|
+
setMeshVisible: () => notSupported("setMeshVisible")
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
export { applyPropertyToModel, buildScene, extractProperties, generateRaycastableChoices, generateSettableChoices, parseJsonPath, toJsonPathString };
|
|
304
|
+
//# sourceMappingURL=buildScene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildScene.js","names":["properties: Properties","choices: { text: string; value: any }[]","property","updatedListeners: OnClickListener","addOnSceneChangedListener: IScene['addOnSceneChangedListener']","removeOnSceneChangedListener: IScene['removeOnSceneChangedListener']"],"sources":["../src/buildScene.ts"],"sourcesContent":["import { type Choices, EventEmitter } from '@kiberon-labs/behave-graph';\nimport {\n type Event,\n Material,\n MeshBasicMaterial,\n Object3D,\n Quaternion,\n Vector3,\n Vector4\n} from 'three';\nimport type { GLTF } from 'three-stdlib';\n\nimport type { IScene } from './Abstractions/IScene.js';\nimport type { GLTFJson } from './GLTFJson.js';\nimport { Vec3 } from './Values/Internal/Vec3.js';\nimport { Vec4 } from './Values/Internal/Vec4.js';\n\nconst Resource = {\n nodes: 'nodes',\n materials: 'materials',\n animations: 'animations'\n} as const;\n\ntype Resource = (typeof Resource)[keyof typeof Resource];\n\nfunction toVec3(value: Vector3): Vec3 {\n return new Vec3(value.x, value.y, value.z);\n}\nfunction toVec4(value: Vector4 | Quaternion): Vec4 {\n return new Vec4(value.x, value.y, value.z, value.w);\n}\n\nexport declare type ObjectMap = {\n nodes: {\n [name: string]: Object3D;\n };\n materials: {\n [name: string]: Material;\n };\n};\n\nconst shortPathRegEx = /^\\/?(?<resource>[^/]+)\\/(?<index>\\d+)$/;\nconst jsonPathRegEx =\n /^\\/?(?<resource>[^/]+)\\/(?<index>\\d+)\\/(?<property>[^/]+)$/;\n\nexport type Optional<T> = {\n [K in keyof T]: T[K] | undefined;\n};\n\nexport type Path = {\n resource: Resource;\n index: number;\n property: string;\n};\n\nexport function toJsonPathString(\n { index, property, resource: resourceType }: Optional<Path>,\n short: boolean\n) {\n if (short) {\n if (!resourceType || index === undefined) return;\n return `${resourceType}/${index}`;\n } else {\n if (!resourceType || index === undefined || !property) return;\n return `${resourceType}/${index}/${property}`;\n }\n}\n\nexport function parseJsonPath(jsonPath: string, short = false): Path {\n // hack = for now we see if there are 2 segments to know if its short\n const regex = short ? shortPathRegEx : jsonPathRegEx;\n const matches = regex.exec(jsonPath);\n if (matches === null) throw new Error(`can not parse jsonPath: ${jsonPath}`);\n if (matches.groups === undefined)\n throw new Error(`can not parse jsonPath (no groups): ${jsonPath}`);\n return {\n resource: matches.groups.resource as Resource,\n index: +matches.groups.index!,\n property: matches.groups.property!\n };\n}\n\nexport function applyPropertyToModel(\n { resource, index, property }: Path,\n gltf: GLTF & ObjectMap,\n value: any,\n properties: Properties,\n setActiveAnimations:\n | ((animation: string, active: boolean) => void)\n | undefined\n) {\n const nodeName = getResourceName({ resource, index }, properties);\n if (!nodeName) throw new Error(`could not get node at index ${index}`);\n if (resource === Resource.nodes) {\n const node = gltf.nodes[nodeName] as unknown as Object3D | undefined;\n\n if (!node) {\n console.error(`no node at path ${nodeName}`);\n return;\n }\n\n applyNodeModifier(property, node, value);\n\n return;\n }\n if (resource === Resource.materials) {\n const node = gltf.materials[nodeName] as unknown as Material | undefined;\n\n if (!node) {\n console.error(`no node at path ${nodeName}`);\n return;\n }\n\n applyMaterialModifier(property, node, value);\n\n return;\n }\n\n if (resource === Resource.animations) {\n if (!setActiveAnimations) {\n console.error(\n 'cannot apply animation property without setActiveAnimations'\n );\n return;\n }\n\n setActiveAnimations(nodeName, value as boolean);\n return;\n }\n\n console.error(`unknown resource type ${resource}`);\n}\n\nconst getResourceName = (\n { resource, index }: Pick<Path, 'resource' | 'index'>,\n properties: Properties\n) => {\n return properties[resource]?.options[index]?.name;\n};\n\nconst getPropertyFromModel = (\n { resource, index, property }: Path,\n gltf: GLTF & ObjectMap,\n properties: Properties\n) => {\n if (resource === Resource.nodes) {\n const nodeName = getResourceName({ resource, index }, properties);\n if (!nodeName) throw new Error(`could not get node at index ${index}`);\n const node = gltf.nodes[nodeName] as unknown as Object3D | undefined;\n\n if (!node) {\n console.error(`no node at path ${nodeName}`);\n return;\n }\n\n getPropertyValue(property, node);\n\n return;\n }\n};\n\nfunction applyNodeModifier(property: string, objectRef: Object3D, value: any) {\n switch (property) {\n case 'visible': {\n objectRef.visible = value as boolean;\n break;\n }\n case 'translation': {\n const v = value as Vec3;\n objectRef.position.set(v.x, v.y, v.z);\n break;\n }\n case 'scale': {\n const v = value as Vec3;\n objectRef.scale.set(v.x, v.y, v.z);\n break;\n }\n case 'rotation': {\n const v = value as Vec4;\n objectRef.quaternion.set(v.x, v.y, v.z, v.w);\n break;\n }\n }\n}\n\nfunction applyMaterialModifier(\n property: string,\n materialRef: Material,\n value: any\n) {\n switch (property) {\n case 'color': {\n const basic = materialRef as MeshBasicMaterial;\n\n if (basic.color) {\n const v = value as Vec3;\n basic.color.setRGB(v.x, v.y, v.z);\n basic.needsUpdate = true;\n }\n break;\n }\n }\n}\n\nfunction getPropertyValue(property: string, objectRef: Object3D<Event>) {\n switch (property) {\n case 'visible': {\n return objectRef.visible;\n }\n case 'translation': {\n return toVec3(objectRef.position);\n }\n case 'scale': {\n return toVec3(objectRef.scale);\n }\n case 'rotation': {\n return toVec4(objectRef.quaternion);\n }\n default:\n throw new Error(`unrecognized property: ${property}`);\n }\n}\n\nexport type ResourceOption = {\n name: string;\n index: number;\n};\n\nexport type ResourceProperties = {\n options: ResourceOption[];\n properties: string[];\n};\n\ntype Properties = {\n [key in Resource]?: ResourceProperties;\n};\n\nexport type ParsableScene = GLTF &\n ObjectMap & {\n json?: GLTFJson;\n };\n\nexport const extractProperties = (gltf: ParsableScene): Properties => {\n const nodeProperties = [\n 'visible',\n 'translation',\n 'scale',\n 'rotation',\n 'color'\n ];\n const animationProperties = ['playing'];\n const materialProperties = ['color'];\n\n const gltfJson = gltf.parser.json as GLTFJson;\n\n const nodeOptions = gltfJson.nodes?.map(({ name }, index) => ({\n name: name || index.toString(),\n index\n }));\n const materialOptions = gltfJson.materials?.map(({ name }, index) => ({\n name: name || index.toString(),\n index\n }));\n const animationOptions = gltf.animations?.map(({ name }, index) => ({\n name: name || index.toString(),\n index\n }));\n\n const properties: Properties = {};\n\n properties.nodes = { options: nodeOptions, properties: nodeProperties };\n\n if (materialOptions) {\n properties.materials = {\n options: materialOptions,\n properties: materialProperties\n };\n }\n\n if (animationOptions) {\n properties.animations = {\n options: animationOptions,\n properties: animationProperties\n };\n }\n\n return properties;\n};\n\nfunction createPropertyChoice(\n resource: string,\n name: string,\n property: string,\n index: number\n): { text: string; value: any } {\n return {\n text: `${resource}/${name}/${property}`,\n value: `${resource}/${index}/${property}`\n };\n}\n\nfunction generateChoicesForProperty(\n property: ResourceProperties | undefined,\n resource: Resource\n) {\n if (!property) return [];\n const choices: { text: string; value: any }[] = [];\n\n property.options.forEach(({ index, name }) => {\n property.properties.forEach((property) => {\n choices.push(createPropertyChoice(resource, name, property, index));\n });\n });\n\n return choices;\n}\n\nexport function generateSettableChoices(properties: Properties): Choices {\n const choices: { text: string; value: any }[] = [\n ...generateChoicesForProperty(properties.nodes, Resource.nodes),\n ...generateChoicesForProperty(properties.materials, Resource.materials),\n ...generateChoicesForProperty(properties.animations, Resource.animations)\n ];\n\n return choices;\n}\n\nexport function generateRaycastableChoices(properties: Properties): Choices {\n const choices: { text: string; value: any }[] = [];\n\n properties.nodes?.options.forEach(({ index, name }) => {\n choices.push({\n text: `nodes/${name}`,\n value: `nodes/${index}`\n });\n });\n\n return choices;\n}\n\nexport type OnClickCallback = (jsonPath: string) => void;\n\nexport type OnClickListener = {\n path: Path;\n elementName: string;\n callbacks: OnClickCallback[];\n};\n\nexport type OnClickListeners = {\n [jsonPath: string]: OnClickListener;\n};\n\nexport const buildScene = ({\n gltf,\n setOnClickListeners,\n setActiveAnimations\n}: {\n gltf: GLTF & ObjectMap;\n setOnClickListeners:\n | ((cb: (existing: OnClickListeners) => OnClickListeners) => void)\n | undefined;\n setActiveAnimations:\n | ((animation: string, active: boolean) => void)\n | undefined;\n}) => {\n const properties = extractProperties(gltf);\n\n const onSceneChanged = new EventEmitter<void>();\n\n const addOnClickedListener = (\n jsonPath: string,\n callback: (jsonPath: string) => void\n ) => {\n if (!setOnClickListeners) return;\n const path = parseJsonPath(jsonPath, true);\n\n setOnClickListeners((existing) => {\n const listenersForPath = existing[jsonPath] || {\n path,\n elementName: getResourceName(\n { resource: path.resource, index: path.index },\n properties\n )!,\n callbacks: []\n };\n\n const updatedListeners: OnClickListener = {\n ...listenersForPath,\n callbacks: [...listenersForPath.callbacks, callback]\n };\n\n const result: OnClickListeners = {\n ...existing,\n [jsonPath]: updatedListeners\n };\n\n return result;\n });\n };\n\n const removeOnClickedListener = (\n jsonPath: string,\n callback: (jsonPath: string) => void\n ) => {\n if (!setOnClickListeners) return;\n setOnClickListeners((existing) => {\n const listenersForPath = existing[jsonPath];\n\n if (!listenersForPath) return existing;\n\n const updatedCallbacks = listenersForPath.callbacks.filter(\n (x) => x !== callback\n );\n\n if (updatedCallbacks.length > 0) {\n const updatedListeners = {\n ...listenersForPath,\n callback: updatedCallbacks\n };\n\n return {\n ...existing,\n [jsonPath]: updatedListeners\n };\n }\n\n const result = {\n ...existing\n };\n\n delete result[jsonPath];\n\n return result;\n });\n };\n\n const getProperty = (jsonPath: string, _valueTypeName: string) => {\n const path = parseJsonPath(jsonPath);\n\n return getPropertyFromModel(path, gltf, properties);\n };\n\n const setProperty = (jsonPath: string, valueTypeName: string, value: any) => {\n const path = parseJsonPath(jsonPath);\n\n applyPropertyToModel(path, gltf, value, properties, setActiveAnimations);\n\n onSceneChanged.emit();\n };\n\n const settableChoices = generateSettableChoices(properties);\n const raycastableChoices = generateRaycastableChoices(properties);\n\n const addOnSceneChangedListener: IScene['addOnSceneChangedListener'] = (\n listener\n ) => {\n onSceneChanged.addListener(listener);\n };\n\n const removeOnSceneChangedListener: IScene['removeOnSceneChangedListener'] = (\n listener\n ) => {\n onSceneChanged.removeListener(listener);\n };\n\n // This scene is backed by a loaded glTF model and exposes it through the\n // json-path property API (getProperty/setProperty/...). The procedural\n // mesh/light/material API (added to IScene for scene backends like the demo\n // scene) is not supported here, so those operations fail loudly rather than\n // silently doing the wrong thing. Name-enumeration getters return empty so\n // generic choice UIs degrade gracefully instead of throwing.\n const notSupported = (op: string): never => {\n throw new Error(\n `The glTF-backed scene does not support \"${op}\". Use a scene backend that implements the procedural mesh/light API (e.g. the demo scene) for that operation.`\n );\n };\n\n const scene: IScene = {\n getProperty,\n setProperty,\n getProperties: () => settableChoices,\n getRaycastableProperties: () => raycastableChoices,\n addOnClickedListener,\n removeOnClickedListener,\n addOnSceneChangedListener,\n removeOnSceneChangedListener,\n\n // --- procedural mesh/light/material API: unsupported on a glTF scene ---\n createMesh: () => notSupported('createMesh'),\n deleteMesh: () => notSupported('deleteMesh'),\n getMeshNames: () => [],\n addLight: () => notSupported('addLight'),\n removeLight: () => notSupported('removeLight'),\n setLightProperty: () => notSupported('setLightProperty'),\n getLightProperty: () => notSupported('getLightProperty'),\n getLightNames: () => [],\n setMaterialProperty: () => notSupported('setMaterialProperty'),\n getMaterialProperty: () => notSupported('getMaterialProperty'),\n addOnAnyMeshClickedListener: () =>\n notSupported('addOnAnyMeshClickedListener'),\n removeOnAnyMeshClickedListener: () =>\n notSupported('removeOnAnyMeshClickedListener'),\n getMeshPosition: () => notSupported('getMeshPosition'),\n setMeshPosition: () => notSupported('setMeshPosition'),\n getDistanceBetween: () => notSupported('getDistanceBetween'),\n lookAt: () => notSupported('lookAt'),\n moveTowards: () => notSupported('moveTowards'),\n cloneMesh: () => notSupported('cloneMesh'),\n setMeshVisible: () => notSupported('setMeshVisible')\n };\n\n return scene;\n};\n"],"mappings":";;;;;;AAiBA,MAAM,WAAW;CACf,OAAO;CACP,WAAW;CACX,YAAY;CACb;AAID,SAAS,OAAO,OAAsB;AACpC,QAAO,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;;AAE5C,SAAS,OAAO,OAAmC;AACjD,QAAO,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;;AAYrD,MAAM,iBAAiB;AACvB,MAAM,gBACJ;AAYF,SAAgB,iBACd,EAAE,OAAO,UAAU,UAAU,gBAC7B,OACA;AACA,KAAI,OAAO;AACT,MAAI,CAAC,gBAAgB,UAAU,OAAW;AAC1C,SAAO,GAAG,aAAa,GAAG;QACrB;AACL,MAAI,CAAC,gBAAgB,UAAU,UAAa,CAAC,SAAU;AACvD,SAAO,GAAG,aAAa,GAAG,MAAM,GAAG;;;AAIvC,SAAgB,cAAc,UAAkB,QAAQ,OAAa;CAGnE,MAAM,WADQ,QAAQ,iBAAiB,eACjB,KAAK,SAAS;AACpC,KAAI,YAAY,KAAM,OAAM,IAAI,MAAM,2BAA2B,WAAW;AAC5E,KAAI,QAAQ,WAAW,OACrB,OAAM,IAAI,MAAM,uCAAuC,WAAW;AACpE,QAAO;EACL,UAAU,QAAQ,OAAO;EACzB,OAAO,CAAC,QAAQ,OAAO;EACvB,UAAU,QAAQ,OAAO;EAC1B;;AAGH,SAAgB,qBACd,EAAE,UAAU,OAAO,YACnB,MACA,OACA,YACA,qBAGA;CACA,MAAM,WAAW,gBAAgB;EAAE;EAAU;EAAO,EAAE,WAAW;AACjE,KAAI,CAAC,SAAU,OAAM,IAAI,MAAM,+BAA+B,QAAQ;AACtE,KAAI,aAAa,SAAS,OAAO;EAC/B,MAAM,OAA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AAiC;EAChD,uBAAuB,aAAa,kBAAkB;EACtD,uBAAuB,aAAa,kBAAkB;EACtD,0BAA0B,aAAa,qBAAqB;EAC5D,cAAc,aAAa,SAAS;EACpC,mBAAmB,aAAa,cAAc;EAC9C,iBAAiB,aAAa,YAAY;EAC1C,sBAAsB,aAAa,iBAAiB;EACrD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GeometryType, IScene, LightType } from "./Abstractions/IScene.js";
|
|
2
|
+
import { DummyScene } from "./Abstractions/Drivers/DummyScene.js";
|
|
3
|
+
import { Vec2, Vec2JSON, vec2Add, vec2Dot, vec2Equals, vec2FromArray, vec2Length, vec2Mix, vec2MultiplyByScalar, vec2Negate, vec2Normalize, vec2Parse, vec2Subtract, vec2ToArray, vec2ToString } from "./Values/Internal/Vec2.js";
|
|
4
|
+
import { Vec4, Vec4JSON, angleAxisToQuat, eulerToQuat, mat3ToQuat, mat4ToQuat, quatConjugate, quatExp, quatLn, quatMultiply, quatPow, quatSlerp, quatToAngleAxis, vec4Add, vec4Dot, vec4Equals, vec4FromArray, vec4Length, vec4Mix, vec4MultiplyByScalar, vec4Negate, vec4Normalize, vec4Parse, vec4Subtract, vec4ToArray, vec4ToString } from "./Values/Internal/Vec4.js";
|
|
5
|
+
import { Vec3, Vec3JSON, hexToRGB, hslToRGB, mat3ToEuler, mat4ToEuler, quatToEuler, rgbToHSL, rgbToHex, vec3Add, vec3Cross, vec3Dot, vec3Equals, vec3FromArray, vec3Length, vec3Mix, vec3MultiplyByScalar, vec3Negate, vec3Normalize, vec3Parse, vec3Subtract, vec3ToArray, vec3ToString } from "./Values/Internal/Vec3.js";
|
|
6
|
+
import { Mat4, Mat4JSON, column4ToMat4, eulerToMat4, mat3ToMat4, mat4Add, mat4Adjoint, mat4Determinant, mat4Equals, mat4FromArray, mat4Inverse, mat4LookAt, mat4Mix, mat4Multiply, mat4MultiplyByScalar, mat4Negate, mat4Orthogonal, mat4OrthogonalSimple, mat4Parse, mat4Perspective, mat4PerspectiveFov, mat4RotateByEuler, mat4RotateByQuat, mat4Scale, mat4SetColumn4, mat4SetRow4, mat4Subtract, mat4ToArray, mat4ToScale3, mat4ToString, mat4ToTranslation3, mat4TransformNormal3, mat4TransformPoint3, mat4Translate, mat4Transpose, quatToMat4, scale3ToMat4, translation3ToMat4 } from "./Values/Internal/Mat4.js";
|
|
7
|
+
import { Mat3, Mat3JSON, column3ToMat3, eulerToMat3, mat3Add, mat3Determinant, mat3Equals, mat3FromArray, mat3Inverse, mat3Mix, mat3Multiply, mat3MultiplyByScalar, mat3Negate, mat3Parse, mat3SetColumn3, mat3SetRow3, mat3Subtract, mat3ToArray, mat3ToScale2, mat3ToScale3, mat3ToString, mat3ToTranslation2, mat3Transpose, mat4ToMat3, quatToMat3, scale2ToMat3, scale3ToMat3, translation2ToMat3 } from "./Values/Internal/Mat3.js";
|
|
8
|
+
import { ColorValue } from "./Values/ColorValue.js";
|
|
9
|
+
import { EulerValue } from "./Values/EulerValue.js";
|
|
10
|
+
import { Mat3Value } from "./Values/Mat3Value.js";
|
|
11
|
+
import { Mat4Value } from "./Values/Mat4Value.js";
|
|
12
|
+
import { Vec2Value } from "./Values/Vec2Value.js";
|
|
13
|
+
import { Vec3Value } from "./Values/Vec3Value.js";
|
|
14
|
+
import { Vec4Value } from "./Values/Vec4Value.js";
|
|
15
|
+
import { QuatValue } from "./Values/QuatValue.js";
|
|
16
|
+
import { AddLight } from "./Nodes/Actions/AddLight.js";
|
|
17
|
+
import { CloneMesh } from "./Nodes/Actions/CloneMesh.js";
|
|
18
|
+
import { CreateMesh } from "./Nodes/Actions/CreateMesh.js";
|
|
19
|
+
import { DeleteMesh } from "./Nodes/Actions/DeleteMesh.js";
|
|
20
|
+
import { EaseSceneProperty } from "./Nodes/Actions/EaseSceneProperty.js";
|
|
21
|
+
import { LookAt } from "./Nodes/Actions/LookAt.js";
|
|
22
|
+
import { MoveTowards } from "./Nodes/Actions/MoveTowards.js";
|
|
23
|
+
import { RemoveLight } from "./Nodes/Actions/RemoveLight.js";
|
|
24
|
+
import { SetLightProperty } from "./Nodes/Actions/SetLightProperty.js";
|
|
25
|
+
import { SetMaterialProperty } from "./Nodes/Actions/SetMaterialProperty.js";
|
|
26
|
+
import { SetMeshPosition } from "./Nodes/Actions/SetMeshPosition.js";
|
|
27
|
+
import { SetMeshVisible } from "./Nodes/Actions/SetMeshVisible.js";
|
|
28
|
+
import { SetSceneProperty } from "./Nodes/Actions/SetSceneProperty.js";
|
|
29
|
+
import { OnAnyMeshClicked } from "./Nodes/Events/OnAnyMeshClicked.js";
|
|
30
|
+
import { OnSceneChanged } from "./Nodes/Events/OnSceneChanged.js";
|
|
31
|
+
import { OnSceneNodeClick } from "./Nodes/Events/OnSceneNodeClick.js";
|
|
32
|
+
import { ColorNodes_d_exports } from "./Nodes/Logic/ColorNodes.js";
|
|
33
|
+
import { EulerNodes_d_exports } from "./Nodes/Logic/EulerNodes.js";
|
|
34
|
+
import { Mat3Nodes_d_exports } from "./Nodes/Logic/Mat3Nodes.js";
|
|
35
|
+
import { Mat4Nodes_d_exports } from "./Nodes/Logic/Mat4Nodes.js";
|
|
36
|
+
import { Vec2Nodes_d_exports } from "./Nodes/Logic/Vec2Nodes.js";
|
|
37
|
+
import { Vec3Nodes_d_exports } from "./Nodes/Logic/Vec3Nodes.js";
|
|
38
|
+
import { Vec4Nodes_d_exports } from "./Nodes/Logic/Vec4Nodes.js";
|
|
39
|
+
import { QuatNodes_d_exports } from "./Nodes/Logic/QuatNodes.js";
|
|
40
|
+
import { VecElements } from "./Nodes/Logic/VecElements.js";
|
|
41
|
+
import { GetDistanceBetween } from "./Nodes/Queries/GetDistanceBetween.js";
|
|
42
|
+
import { GetLightProperty } from "./Nodes/Queries/GetLightProperty.js";
|
|
43
|
+
import { GetMaterialProperty } from "./Nodes/Queries/GetMaterialProperty.js";
|
|
44
|
+
import { GetMeshPosition } from "./Nodes/Queries/GetMeshPosition.js";
|
|
45
|
+
import { GetSceneProperty } from "./Nodes/Queries/GetSceneProperty.js";
|
|
46
|
+
import { getSceneNodesMap, getSceneStringConversions, getSceneValuesMap, registerSceneProfile } from "./registerSceneProfile.js";
|
|
47
|
+
import { ObjectMap, OnClickCallback, OnClickListener, OnClickListeners, Optional, ParsableScene, Path, ResourceOption, ResourceProperties, applyPropertyToModel, buildScene, extractProperties, generateRaycastableChoices, generateSettableChoices, parseJsonPath, toJsonPathString } from "./buildScene.js";
|
|
48
|
+
|
|
49
|
+
//#region src/index.d.ts
|
|
50
|
+
declare module '@kiberon-labs/behave-graph' {
|
|
51
|
+
interface Dependencies {
|
|
52
|
+
IScene: IScene;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { AddLight, CloneMesh, ColorNodes_d_exports as ColorNodes, ColorValue, CreateMesh, DeleteMesh, DummyScene, EaseSceneProperty, EulerNodes_d_exports as EulerNodes, EulerValue, GeometryType, GetDistanceBetween, GetLightProperty, GetMaterialProperty, GetMeshPosition, GetSceneProperty, IScene, LightType, LookAt, Mat3, Mat3JSON, Mat3Nodes_d_exports as Mat3Nodes, Mat3Value, Mat4, Mat4JSON, Mat4Nodes_d_exports as Mat4Nodes, Mat4Value, MoveTowards, ObjectMap, OnAnyMeshClicked, OnClickCallback, OnClickListener, OnClickListeners, OnSceneChanged, OnSceneNodeClick, Optional, ParsableScene, Path, QuatNodes_d_exports as QuatNodes, QuatValue, RemoveLight, ResourceOption, ResourceProperties, SetLightProperty, SetMaterialProperty, SetMeshPosition, SetMeshVisible, SetSceneProperty, Vec2, Vec2JSON, Vec2Nodes_d_exports as Vec2Nodes, Vec2Value, Vec3, Vec3JSON, Vec3Nodes_d_exports as Vec3Nodes, Vec3Value, Vec4, Vec4JSON, Vec4Nodes_d_exports as Vec4Nodes, Vec4Value, VecElements, angleAxisToQuat, applyPropertyToModel, buildScene, column3ToMat3, column4ToMat4, eulerToMat3, eulerToMat4, eulerToQuat, extractProperties, generateRaycastableChoices, generateSettableChoices, getSceneNodesMap, getSceneStringConversions, getSceneValuesMap, hexToRGB, hslToRGB, mat3Add, mat3Determinant, mat3Equals, mat3FromArray, mat3Inverse, mat3Mix, mat3Multiply, mat3MultiplyByScalar, mat3Negate, mat3Parse, mat3SetColumn3, mat3SetRow3, mat3Subtract, mat3ToArray, mat3ToEuler, mat3ToMat4, mat3ToQuat, mat3ToScale2, mat3ToScale3, mat3ToString, mat3ToTranslation2, mat3Transpose, mat4Add, mat4Adjoint, mat4Determinant, mat4Equals, mat4FromArray, mat4Inverse, mat4LookAt, mat4Mix, mat4Multiply, mat4MultiplyByScalar, mat4Negate, mat4Orthogonal, mat4OrthogonalSimple, mat4Parse, mat4Perspective, mat4PerspectiveFov, mat4RotateByEuler, mat4RotateByQuat, mat4Scale, mat4SetColumn4, mat4SetRow4, mat4Subtract, mat4ToArray, mat4ToEuler, mat4ToMat3, mat4ToQuat, mat4ToScale3, mat4ToString, mat4ToTranslation3, mat4TransformNormal3, mat4TransformPoint3, mat4Translate, mat4Transpose, parseJsonPath, quatConjugate, quatExp, quatLn, quatMultiply, quatPow, quatSlerp, quatToAngleAxis, quatToEuler, quatToMat3, quatToMat4, registerSceneProfile, rgbToHSL, rgbToHex, scale2ToMat3, scale3ToMat3, scale3ToMat4, toJsonPathString, translation2ToMat3, translation3ToMat4, vec2Add, vec2Dot, vec2Equals, vec2FromArray, vec2Length, vec2Mix, vec2MultiplyByScalar, vec2Negate, vec2Normalize, vec2Parse, vec2Subtract, vec2ToArray, vec2ToString, vec3Add, vec3Cross, vec3Dot, vec3Equals, vec3FromArray, vec3Length, vec3Mix, vec3MultiplyByScalar, vec3Negate, vec3Normalize, vec3Parse, vec3Subtract, vec3ToArray, vec3ToString, vec4Add, vec4Dot, vec4Equals, vec4FromArray, vec4Length, vec4Mix, vec4MultiplyByScalar, vec4Negate, vec4Normalize, vec4Parse, vec4Subtract, vec4ToArray, vec4ToString };
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAIY"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { GeometryType, LightType } from "./Abstractions/IScene.js";
|
|
2
|
+
import { Vec2, vec2Add, vec2Dot, vec2Equals, vec2FromArray, vec2Length, vec2Mix, vec2MultiplyByScalar, vec2Negate, vec2Normalize, vec2Parse, vec2Subtract, vec2ToArray, vec2ToString } from "./Values/Internal/Vec2.js";
|
|
3
|
+
import { Mat3, column3ToMat3, eulerToMat3, mat3Add, mat3Determinant, mat3Equals, mat3FromArray, mat3Inverse, mat3Mix, mat3Multiply, mat3MultiplyByScalar, mat3Negate, mat3Parse, mat3SetColumn3, mat3SetRow3, mat3Subtract, mat3ToArray, mat3ToScale2, mat3ToScale3, mat3ToString, mat3ToTranslation2, mat3Transpose, mat4ToMat3, quatToMat3, scale2ToMat3, scale3ToMat3, translation2ToMat3 } from "./Values/Internal/Mat3.js";
|
|
4
|
+
import { Vec3, hexToRGB, hslToRGB, mat3ToEuler, mat4ToEuler, quatToEuler, rgbToHSL, rgbToHex, vec3Add, vec3Cross, vec3Dot, vec3Equals, vec3FromArray, vec3Length, vec3Mix, vec3MultiplyByScalar, vec3Negate, vec3Normalize, vec3Parse, vec3Subtract, vec3ToArray, vec3ToString } from "./Values/Internal/Vec3.js";
|
|
5
|
+
import { ColorValue } from "./Values/ColorValue.js";
|
|
6
|
+
import { EulerValue } from "./Values/EulerValue.js";
|
|
7
|
+
import { Vec4, angleAxisToQuat, eulerToQuat, mat3ToQuat, mat4ToQuat, quatConjugate, quatExp, quatLn, quatMultiply, quatPow, quatSlerp, quatToAngleAxis, vec4Add, vec4Dot, vec4Equals, vec4FromArray, vec4Length, vec4Mix, vec4MultiplyByScalar, vec4Negate, vec4Normalize, vec4Parse, vec4Subtract, vec4ToArray, vec4ToString } from "./Values/Internal/Vec4.js";
|
|
8
|
+
import { QuatValue } from "./Values/QuatValue.js";
|
|
9
|
+
import { Vec2Value } from "./Values/Vec2Value.js";
|
|
10
|
+
import { Vec3Value } from "./Values/Vec3Value.js";
|
|
11
|
+
import { Vec4Value } from "./Values/Vec4Value.js";
|
|
12
|
+
import { DummyScene } from "./Abstractions/Drivers/DummyScene.js";
|
|
13
|
+
import { Mat4, column4ToMat4, eulerToMat4, mat3ToMat4, mat4Add, mat4Adjoint, mat4Determinant, mat4Equals, mat4FromArray, mat4Inverse, mat4LookAt, mat4Mix, mat4Multiply, mat4MultiplyByScalar, mat4Negate, mat4Orthogonal, mat4OrthogonalSimple, mat4Parse, mat4Perspective, mat4PerspectiveFov, mat4RotateByEuler, mat4RotateByQuat, mat4Scale, mat4SetColumn4, mat4SetRow4, mat4Subtract, mat4ToArray, mat4ToScale3, mat4ToString, mat4ToTranslation3, mat4TransformNormal3, mat4TransformPoint3, mat4Translate, mat4Transpose, quatToMat4, scale3ToMat4, translation3ToMat4 } from "./Values/Internal/Mat4.js";
|
|
14
|
+
import { Mat3Value } from "./Values/Mat3Value.js";
|
|
15
|
+
import { Mat4Value } from "./Values/Mat4Value.js";
|
|
16
|
+
import { AddLight } from "./Nodes/Actions/AddLight.js";
|
|
17
|
+
import { CloneMesh } from "./Nodes/Actions/CloneMesh.js";
|
|
18
|
+
import { CreateMesh } from "./Nodes/Actions/CreateMesh.js";
|
|
19
|
+
import { DeleteMesh } from "./Nodes/Actions/DeleteMesh.js";
|
|
20
|
+
import { EaseSceneProperty } from "./Nodes/Actions/EaseSceneProperty.js";
|
|
21
|
+
import { LookAt } from "./Nodes/Actions/LookAt.js";
|
|
22
|
+
import { MoveTowards } from "./Nodes/Actions/MoveTowards.js";
|
|
23
|
+
import { RemoveLight } from "./Nodes/Actions/RemoveLight.js";
|
|
24
|
+
import { SetLightProperty } from "./Nodes/Actions/SetLightProperty.js";
|
|
25
|
+
import { SetMaterialProperty } from "./Nodes/Actions/SetMaterialProperty.js";
|
|
26
|
+
import { SetMeshPosition } from "./Nodes/Actions/SetMeshPosition.js";
|
|
27
|
+
import { SetMeshVisible } from "./Nodes/Actions/SetMeshVisible.js";
|
|
28
|
+
import { SetSceneProperty } from "./Nodes/Actions/SetSceneProperty.js";
|
|
29
|
+
import { OnAnyMeshClicked } from "./Nodes/Events/OnAnyMeshClicked.js";
|
|
30
|
+
import { OnSceneChanged } from "./Nodes/Events/OnSceneChanged.js";
|
|
31
|
+
import { OnSceneNodeClick } from "./Nodes/Events/OnSceneNodeClick.js";
|
|
32
|
+
import { ColorNodes_exports } from "./Nodes/Logic/ColorNodes.js";
|
|
33
|
+
import { EulerNodes_exports } from "./Nodes/Logic/EulerNodes.js";
|
|
34
|
+
import { Mat3Nodes_exports } from "./Nodes/Logic/Mat3Nodes.js";
|
|
35
|
+
import { Mat4Nodes_exports } from "./Nodes/Logic/Mat4Nodes.js";
|
|
36
|
+
import { Vec2Nodes_exports } from "./Nodes/Logic/Vec2Nodes.js";
|
|
37
|
+
import { Vec3Nodes_exports } from "./Nodes/Logic/Vec3Nodes.js";
|
|
38
|
+
import { Vec4Nodes_exports } from "./Nodes/Logic/Vec4Nodes.js";
|
|
39
|
+
import { QuatNodes_exports } from "./Nodes/Logic/QuatNodes.js";
|
|
40
|
+
import { VecElements } from "./Nodes/Logic/VecElements.js";
|
|
41
|
+
import { GetDistanceBetween } from "./Nodes/Queries/GetDistanceBetween.js";
|
|
42
|
+
import { GetLightProperty } from "./Nodes/Queries/GetLightProperty.js";
|
|
43
|
+
import { GetMaterialProperty } from "./Nodes/Queries/GetMaterialProperty.js";
|
|
44
|
+
import { GetMeshPosition } from "./Nodes/Queries/GetMeshPosition.js";
|
|
45
|
+
import { GetSceneProperty } from "./Nodes/Queries/GetSceneProperty.js";
|
|
46
|
+
import { getSceneNodesMap, getSceneStringConversions, getSceneValuesMap, registerSceneProfile } from "./registerSceneProfile.js";
|
|
47
|
+
import { applyPropertyToModel, buildScene, extractProperties, generateRaycastableChoices, generateSettableChoices, parseJsonPath, toJsonPathString } from "./buildScene.js";
|
|
48
|
+
|
|
49
|
+
export { AddLight, CloneMesh, ColorNodes_exports as ColorNodes, ColorValue, CreateMesh, DeleteMesh, DummyScene, EaseSceneProperty, EulerNodes_exports as EulerNodes, EulerValue, GeometryType, GetDistanceBetween, GetLightProperty, GetMaterialProperty, GetMeshPosition, GetSceneProperty, LightType, LookAt, Mat3, Mat3Nodes_exports as Mat3Nodes, Mat3Value, Mat4, Mat4Nodes_exports as Mat4Nodes, Mat4Value, MoveTowards, OnAnyMeshClicked, OnSceneChanged, OnSceneNodeClick, QuatNodes_exports as QuatNodes, QuatValue, RemoveLight, SetLightProperty, SetMaterialProperty, SetMeshPosition, SetMeshVisible, SetSceneProperty, Vec2, Vec2Nodes_exports as Vec2Nodes, Vec2Value, Vec3, Vec3Nodes_exports as Vec3Nodes, Vec3Value, Vec4, Vec4Nodes_exports as Vec4Nodes, Vec4Value, VecElements, angleAxisToQuat, applyPropertyToModel, buildScene, column3ToMat3, column4ToMat4, eulerToMat3, eulerToMat4, eulerToQuat, extractProperties, generateRaycastableChoices, generateSettableChoices, getSceneNodesMap, getSceneStringConversions, getSceneValuesMap, hexToRGB, hslToRGB, mat3Add, mat3Determinant, mat3Equals, mat3FromArray, mat3Inverse, mat3Mix, mat3Multiply, mat3MultiplyByScalar, mat3Negate, mat3Parse, mat3SetColumn3, mat3SetRow3, mat3Subtract, mat3ToArray, mat3ToEuler, mat3ToMat4, mat3ToQuat, mat3ToScale2, mat3ToScale3, mat3ToString, mat3ToTranslation2, mat3Transpose, mat4Add, mat4Adjoint, mat4Determinant, mat4Equals, mat4FromArray, mat4Inverse, mat4LookAt, mat4Mix, mat4Multiply, mat4MultiplyByScalar, mat4Negate, mat4Orthogonal, mat4OrthogonalSimple, mat4Parse, mat4Perspective, mat4PerspectiveFov, mat4RotateByEuler, mat4RotateByQuat, mat4Scale, mat4SetColumn4, mat4SetRow4, mat4Subtract, mat4ToArray, mat4ToEuler, mat4ToMat3, mat4ToQuat, mat4ToScale3, mat4ToString, mat4ToTranslation3, mat4TransformNormal3, mat4TransformPoint3, mat4Translate, mat4Transpose, parseJsonPath, quatConjugate, quatExp, quatLn, quatMultiply, quatPow, quatSlerp, quatToAngleAxis, quatToEuler, quatToMat3, quatToMat4, registerSceneProfile, rgbToHSL, rgbToHex, scale2ToMat3, scale3ToMat3, scale3ToMat4, toJsonPathString, translation2ToMat3, translation3ToMat4, vec2Add, vec2Dot, vec2Equals, vec2FromArray, vec2Length, vec2Mix, vec2MultiplyByScalar, vec2Negate, vec2Normalize, vec2Parse, vec2Subtract, vec2ToArray, vec2ToString, vec3Add, vec3Cross, vec3Dot, vec3Equals, vec3FromArray, vec3Length, vec3Mix, vec3MultiplyByScalar, vec3Negate, vec3Normalize, vec3Parse, vec3Subtract, vec3ToArray, vec3ToString, vec4Add, vec4Dot, vec4Equals, vec4FromArray, vec4Length, vec4Mix, vec4MultiplyByScalar, vec4Negate, vec4Normalize, vec4Parse, vec4Subtract, vec4ToArray, vec4ToString };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _kiberon_labs_behave_graph0 from "@kiberon-labs/behave-graph";
|
|
2
|
+
|
|
3
|
+
//#region src/manifest.source.d.ts
|
|
4
|
+
declare const _default: _kiberon_labs_behave_graph0.ManifestSource;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { _default as default };
|
|
7
|
+
//# sourceMappingURL=manifest.source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.source.d.ts","names":[],"sources":["../src/manifest.source.ts"],"sourcesContent":[],"mappings":""}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DummyScene } from "./Abstractions/Drivers/DummyScene.js";
|
|
2
|
+
import { getSceneNodesMap, getSceneValuesMap } from "./registerSceneProfile.js";
|
|
3
|
+
import { name, version } from "./packages/nodes/scene/package.js";
|
|
4
|
+
import { ContributionKind, PackageCategory, defineManifestSource } from "@kiberon-labs/behave-graph";
|
|
5
|
+
|
|
6
|
+
//#region src/manifest.source.ts
|
|
7
|
+
/**
|
|
8
|
+
* Build-time manifest source for the scene package.
|
|
9
|
+
*
|
|
10
|
+
* The registry projects scene's own nodes + value types into static specs
|
|
11
|
+
* (instantiation only — nodes are never run, no IScene driver needed). The
|
|
12
|
+
* executable profile (`registerSceneProfile`) lives behind the `runtime` entry,
|
|
13
|
+
* loaded only by a runner. Contributions point into the built `dist`: the vec3
|
|
14
|
+
* input control, plus each scene value type so a trusted host can swap the
|
|
15
|
+
* editor's pass-through implementations for the real serializers.
|
|
16
|
+
*/
|
|
17
|
+
const valueTypeContributions = [
|
|
18
|
+
["Vec2Value", "vec2"],
|
|
19
|
+
["Vec3Value", "vec3"],
|
|
20
|
+
["Vec4Value", "vec4"],
|
|
21
|
+
["ColorValue", "color"],
|
|
22
|
+
["EulerValue", "euler"],
|
|
23
|
+
["QuatValue", "quat"],
|
|
24
|
+
["Mat3Value", "mat3"],
|
|
25
|
+
["Mat4Value", "mat4"]
|
|
26
|
+
].map(([exportName, valueType]) => ({
|
|
27
|
+
id: `${valueType}-value`,
|
|
28
|
+
kind: ContributionKind.ValueType,
|
|
29
|
+
export: `./Values/${exportName}.js#${exportName}`,
|
|
30
|
+
bind: { valueType }
|
|
31
|
+
}));
|
|
32
|
+
var manifest_source_default = defineManifestSource({
|
|
33
|
+
package: {
|
|
34
|
+
name,
|
|
35
|
+
version
|
|
36
|
+
},
|
|
37
|
+
registry: () => ({
|
|
38
|
+
nodes: getSceneNodesMap(),
|
|
39
|
+
values: getSceneValuesMap(),
|
|
40
|
+
dependencies: { IScene: new DummyScene() }
|
|
41
|
+
}),
|
|
42
|
+
runtime: "./index.js",
|
|
43
|
+
categories: [PackageCategory.Effect],
|
|
44
|
+
contributions: [{
|
|
45
|
+
id: "vec3-control",
|
|
46
|
+
kind: ContributionKind.Control,
|
|
47
|
+
export: "./ui/controls/vec3.js#Vec3Control",
|
|
48
|
+
bind: { controlName: "vec3" }
|
|
49
|
+
}, ...valueTypeContributions]
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { manifest_source_default as default };
|
|
54
|
+
//# sourceMappingURL=manifest.source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.source.js","names":["valueTypeContributions: ContributionSpec[]","pkg.name","pkg.version"],"sources":["../src/manifest.source.ts"],"sourcesContent":["import {\n ContributionKind,\n PackageCategory,\n defineManifestSource,\n type ContributionSpec,\n type Dependencies\n} from '@kiberon-labs/behave-graph';\nimport { getSceneNodesMap, getSceneValuesMap } from './registerSceneProfile.js';\nimport { DummyScene } from './Abstractions/Drivers/DummyScene.js';\nimport pkg from '../package.json' with { type: 'json' };\n\n/**\n * Build-time manifest source for the scene package.\n *\n * The registry projects scene's own nodes + value types into static specs\n * (instantiation only — nodes are never run, no IScene driver needed). The\n * executable profile (`registerSceneProfile`) lives behind the `runtime` entry,\n * loaded only by a runner. Contributions point into the built `dist`: the vec3\n * input control, plus each scene value type so a trusted host can swap the\n * editor's pass-through implementations for the real serializers.\n */\n\n// (file, export, valueType name) for each scene value type.\nconst valueTypeContributions: ContributionSpec[] = [\n ['Vec2Value', 'vec2'],\n ['Vec3Value', 'vec3'],\n ['Vec4Value', 'vec4'],\n ['ColorValue', 'color'],\n ['EulerValue', 'euler'],\n ['QuatValue', 'quat'],\n ['Mat3Value', 'mat3'],\n ['Mat4Value', 'mat4']\n].map(([exportName, valueType]) => ({\n id: `${valueType}-value`,\n kind: ContributionKind.ValueType,\n export: `./Values/${exportName}.js#${exportName}`,\n bind: { valueType }\n}));\n\nexport default defineManifestSource({\n package: { name: pkg.name, version: pkg.version },\n registry: () => ({\n nodes: getSceneNodesMap(),\n values: getSceneValuesMap(),\n // The DummyScene driver satisfies IScene-dependent nodes during spec\n // generation (it never runs them); the real driver is host-provided at run\n // time. Without it, scene-property nodes log \"IScene not registered\".\n dependencies: { IScene: new DummyScene() } as unknown as Dependencies\n }),\n runtime: './index.js',\n categories: [PackageCategory.Effect],\n contributions: [\n {\n id: 'vec3-control',\n kind: ContributionKind.Control,\n export: './ui/controls/vec3.js#Vec3Control',\n bind: { controlName: 'vec3' }\n },\n ...valueTypeContributions\n ]\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAMA,yBAA6C;CACjD,CAAC,aAAa,OAAO;CACrB,CAAC,aAAa,OAAO;CACrB,CAAC,aAAa,OAAO;CACrB,CAAC,cAAc,QAAQ;CACvB,CAAC,cAAc,QAAQ;CACvB,CAAC,aAAa,OAAO;CACrB,CAAC,aAAa,OAAO;CACrB,CAAC,aAAa,OAAO;CACtB,CAAC,KAAK,CAAC,YAAY,gBAAgB;CAClC,IAAI,GAAG,UAAU;CACjB,MAAM,iBAAiB;CACvB,QAAQ,YAAY,WAAW,MAAM;CACrC,MAAM,EAAE,WAAW;CACpB,EAAE;AAEH,8BAAe,qBAAqB;CAClC,SAAS;EAAQC;EAAmBC;EAAa;CACjD,iBAAiB;EACf,OAAO,kBAAkB;EACzB,QAAQ,mBAAmB;EAI3B,cAAc,EAAE,QAAQ,IAAI,YAAY,EAAE;EAC3C;CACD,SAAS;CACT,YAAY,CAAC,gBAAgB,OAAO;CACpC,eAAe,CACb;EACE,IAAI;EACJ,MAAM,iBAAiB;EACvB,QAAQ;EACR,MAAM,EAAE,aAAa,QAAQ;EAC9B,EACD,GAAG,uBACJ;CACF,CAAC"}
|