@vyr/engine 0.0.1
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/package.json +19 -0
- package/src/ArrayUtils.ts +65 -0
- package/src/AsyncTask.ts +72 -0
- package/src/Category.ts +119 -0
- package/src/Color.ts +111 -0
- package/src/Engine.ts +101 -0
- package/src/Generate.ts +40 -0
- package/src/InputSystem.ts +108 -0
- package/src/Listener.ts +59 -0
- package/src/ObjectPool.ts +84 -0
- package/src/ObjectUtils.ts +49 -0
- package/src/Scriptable.ts +27 -0
- package/src/Serialization.ts +49 -0
- package/src/Traverser.ts +39 -0
- package/src/actor/Actor.ts +28 -0
- package/src/actor/AnimationUnitActor.ts +289 -0
- package/src/actor/DivActor.ts +70 -0
- package/src/actor/FragmentActor.ts +56 -0
- package/src/actor/HTMActor.ts +166 -0
- package/src/actor/HTMServiceActor.ts +57 -0
- package/src/actor/HTMTransformControllerActor.ts +404 -0
- package/src/actor/StyleActor.ts +96 -0
- package/src/actor/index.ts +8 -0
- package/src/asset/Asset.ts +271 -0
- package/src/asset/AssetGraph.ts +246 -0
- package/src/asset/index.ts +2 -0
- package/src/descriptor/AnimationUnitDescriptor.ts +65 -0
- package/src/descriptor/CameraDescriptor.ts +12 -0
- package/src/descriptor/ControllerDescriptor.ts +16 -0
- package/src/descriptor/DatasetDescriptor.ts +92 -0
- package/src/descriptor/Descriptor.ts +415 -0
- package/src/descriptor/DivDescriptor.ts +18 -0
- package/src/descriptor/DynamicDescriptor.ts +27 -0
- package/src/descriptor/HTMLDescriptor.ts +87 -0
- package/src/descriptor/HTMLServiceDescriptor.ts +19 -0
- package/src/descriptor/HTMLTransformControllerDescriptor.ts +34 -0
- package/src/descriptor/NodeDescriptor.ts +32 -0
- package/src/descriptor/PrefabDescriptor.ts +53 -0
- package/src/descriptor/PrefabInstanceDescriptor.ts +32 -0
- package/src/descriptor/RoutineDescriptor.ts +54 -0
- package/src/descriptor/ServiceDescriptor.ts +32 -0
- package/src/descriptor/ServiceSchedulerDescriptor.ts +32 -0
- package/src/descriptor/StyleDescriptor.ts +213 -0
- package/src/descriptor/index.ts +17 -0
- package/src/graphics/Collection.ts +25 -0
- package/src/graphics/Compilation.ts +82 -0
- package/src/graphics/Graphics.ts +475 -0
- package/src/graphics/Observer.ts +36 -0
- package/src/graphics/Unit.ts +83 -0
- package/src/graphics/VariableProxy.ts +92 -0
- package/src/graphics/index.ts +5 -0
- package/src/index.ts +26 -0
- package/src/interpreter/AnimationUnitInterpreter.ts +53 -0
- package/src/interpreter/DatasetInterpreter.ts +11 -0
- package/src/interpreter/DivInterpreter.ts +44 -0
- package/src/interpreter/DynamicInterpreter.ts +207 -0
- package/src/interpreter/FragmentInterpreter.ts +34 -0
- package/src/interpreter/HTMLServiceInterpreter.ts +47 -0
- package/src/interpreter/HTMLTransformControllerInterpreter.ts +40 -0
- package/src/interpreter/Interpreter.ts +69 -0
- package/src/interpreter/PrefaInterpreter.ts +11 -0
- package/src/interpreter/PrefabInstanceInterpreter.ts +12 -0
- package/src/interpreter/RoutineInterpreter.ts +88 -0
- package/src/interpreter/ServiceInterpreter.ts +24 -0
- package/src/interpreter/ServiceSchedulerInterpreter.ts +42 -0
- package/src/interpreter/StyleInterpreter.ts +66 -0
- package/src/interpreter/index.ts +14 -0
- package/src/locale/Language.ts +10 -0
- package/src/locale/LanguageProvider.ts +48 -0
- package/src/locale/index.ts +2 -0
- package/src/math/Euler.ts +303 -0
- package/src/math/Matrix4.ts +1123 -0
- package/src/math/Quaternion.ts +737 -0
- package/src/math/Vector2.ts +680 -0
- package/src/math/Vector3.ts +1062 -0
- package/src/math/index.ts +5 -0
- package/src/math/utils.ts +17 -0
- package/src/preset/execute/dataset/index.ts +1 -0
- package/src/preset/execute/dataset/update.ts +52 -0
- package/src/preset/execute/graphics/index.ts +1 -0
- package/src/preset/execute/graphics/invoke.ts +49 -0
- package/src/preset/execute/index.ts +4 -0
- package/src/preset/execute/net/index.ts +1 -0
- package/src/preset/execute/net/request.ts +103 -0
- package/src/preset/execute/scheduler/index.ts +1 -0
- package/src/preset/execute/scheduler/switch.ts +46 -0
- package/src/preset/index.ts +7 -0
- package/src/preset/routine/graphics/index.ts +1 -0
- package/src/preset/routine/graphics/invoke.ts +27 -0
- package/src/preset/routine/index.ts +2 -0
- package/src/preset/routine/scheduler/index.ts +1 -0
- package/src/preset/routine/scheduler/switch.ts +27 -0
- package/src/setup/index.ts +17 -0
- package/src/utils/AssetProvider.ts +72 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps the given value between min and max.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} value - The value to clamp.
|
|
5
|
+
* @param {number} min - The min value.
|
|
6
|
+
* @param {number} max - The max value.
|
|
7
|
+
* @return {number} The clamped value.
|
|
8
|
+
*/
|
|
9
|
+
function clamp(value: number, min: number, max: number) {
|
|
10
|
+
|
|
11
|
+
return Math.max(min, Math.min(max, value));
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
clamp
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as update from './update'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { language } from "../../../locale";
|
|
2
|
+
import { Asset } from "../../../asset";
|
|
3
|
+
import { DatasetDescriptor, Descriptor, RoutineNode, UpdateArgs } from "../../../descriptor";
|
|
4
|
+
import { Graphics } from "../../../graphics";
|
|
5
|
+
import { Scriptable } from "../../../Scriptable";
|
|
6
|
+
import { Category } from "../../../Category";
|
|
7
|
+
|
|
8
|
+
const scriptable = Asset.createVirtualUrl('preset/dataset/update.ts')
|
|
9
|
+
class ExecuteScriptable extends Scriptable {
|
|
10
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
const { input, result } = args
|
|
13
|
+
const dataset = input?.user?.url.value ?? input.default.url.value
|
|
14
|
+
|
|
15
|
+
const previous = result.get(input.previous)
|
|
16
|
+
const datasetDescriptor = Asset.get<DatasetDescriptor>(dataset)
|
|
17
|
+
if (datasetDescriptor instanceof DatasetDescriptor) {
|
|
18
|
+
if (previous) datasetDescriptor.setData(previous)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
Asset.provider(scriptable, async () => ({ default: ExecuteScriptable }))
|
|
25
|
+
|
|
26
|
+
const createExecuteInput = (args: any = {}) => {
|
|
27
|
+
const input = {
|
|
28
|
+
url: { value: args.url ?? '', type: Category.dataset }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return input
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
35
|
+
const executeNode: RoutineNode = {
|
|
36
|
+
id: options.id,
|
|
37
|
+
label: language.get(scriptable as any),
|
|
38
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
39
|
+
routine: 'Execute',
|
|
40
|
+
url: scriptable,
|
|
41
|
+
input: createExecuteInput(options.input)
|
|
42
|
+
}
|
|
43
|
+
return executeNode
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
scriptable,
|
|
48
|
+
createExecuteInput,
|
|
49
|
+
createExecuteNode,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as invoke from './invoke'
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { language } from "../../../locale";
|
|
2
|
+
import { Asset } from "../../../asset";
|
|
3
|
+
import { Descriptor, RoutineNode, UpdateArgs } from "../../../descriptor";
|
|
4
|
+
import { Graphics } from "../../../graphics";
|
|
5
|
+
import { Scriptable } from "../../../Scriptable";
|
|
6
|
+
|
|
7
|
+
const scriptable = Asset.createVirtualUrl('preset/graphics/invoke.ts')
|
|
8
|
+
class ExecuteScriptable extends Scriptable {
|
|
9
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
10
|
+
//@ts-ignore
|
|
11
|
+
const { input } = args
|
|
12
|
+
const interaction = input?.user?.interaction.value ?? input.default.interaction.value
|
|
13
|
+
const target = input?.user?.target.value ?? input.default.target.value
|
|
14
|
+
const targetDescriptor = Descriptor.get<Descriptor>(target)
|
|
15
|
+
if (interaction && targetDescriptor) {
|
|
16
|
+
graphics.invoke(interaction, targetDescriptor)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
Asset.provider(scriptable, async () => ({ default: ExecuteScriptable }))
|
|
21
|
+
|
|
22
|
+
const createExecuteInput = (args: any = {}) => {
|
|
23
|
+
const input = {
|
|
24
|
+
target: { value: args.target ?? '' },
|
|
25
|
+
interaction: { value: args.interaction ?? '' },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return input
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
32
|
+
const executeNode: RoutineNode = {
|
|
33
|
+
id: options.id,
|
|
34
|
+
label: language.get(scriptable as any),
|
|
35
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
36
|
+
routine: 'Execute',
|
|
37
|
+
url: scriptable,
|
|
38
|
+
input: createExecuteInput(options.input)
|
|
39
|
+
}
|
|
40
|
+
return executeNode
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
scriptable,
|
|
45
|
+
createExecuteInput,
|
|
46
|
+
createExecuteNode,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as request from './request'
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { language } from "../../../locale";
|
|
2
|
+
import { Asset } from "../../../asset";
|
|
3
|
+
import { Descriptor, RoutineNode, UpdateArgs } from "../../../descriptor";
|
|
4
|
+
import { Graphics } from "../../../graphics";
|
|
5
|
+
import { Scriptable } from "../../../Scriptable";
|
|
6
|
+
|
|
7
|
+
enum RequestType {
|
|
8
|
+
GET = 'GET',
|
|
9
|
+
POST = 'POST',
|
|
10
|
+
PUT = 'PUT',
|
|
11
|
+
DELETE = 'DELETE',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const scriptable = Asset.createVirtualUrl('preset/net/request.ts')
|
|
15
|
+
class ExecuteScriptable extends Scriptable {
|
|
16
|
+
|
|
17
|
+
joinUrl(url: string, requestData: any) {
|
|
18
|
+
const urlObj = new URL(url);
|
|
19
|
+
|
|
20
|
+
// 直接将requestData添加到urlObj的searchParams中
|
|
21
|
+
Object.entries(requestData).forEach(([key, value]) => {
|
|
22
|
+
if (value !== null && value !== undefined) {
|
|
23
|
+
urlObj.searchParams.set(key, String(value));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return urlObj.toString()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
const { input, result } = args
|
|
33
|
+
let url = input?.user?.url.value ?? input.default.url.value
|
|
34
|
+
const type: string = input?.user?.type.value ?? input.default.type.value
|
|
35
|
+
const data: string = input?.user?.data.value ?? input.default.data.value
|
|
36
|
+
|
|
37
|
+
const requestData: { [k: string]: any } = {}
|
|
38
|
+
const keys: string[] = []
|
|
39
|
+
if (data.trim().length === 0) {
|
|
40
|
+
keys.push(...result.keys())
|
|
41
|
+
} else {
|
|
42
|
+
keys.push(...data.split(','))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (const key of keys) {
|
|
46
|
+
const value = result.get(key)
|
|
47
|
+
Object.assign(requestData, value ?? {})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
url = url.replace(/\${(\w+)}/g, (match: any, key: string) => {
|
|
51
|
+
return requestData.hasOwnProperty(key) ? requestData[key] : match;
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const config = {
|
|
55
|
+
method: type,
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
let res
|
|
61
|
+
if (type === RequestType.GET) {
|
|
62
|
+
res = await fetch(this.joinUrl(url, requestData), config)
|
|
63
|
+
} else {
|
|
64
|
+
res = await fetch(url, { ...config, body: JSON.stringify(requestData) })
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const json = await res.json()
|
|
68
|
+
|
|
69
|
+
return json
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
Asset.provider(scriptable, async () => ({ default: ExecuteScriptable }))
|
|
73
|
+
|
|
74
|
+
const createExecuteInput = (args: any = {}) => {
|
|
75
|
+
const input = {
|
|
76
|
+
url: { value: args.url ?? '' },
|
|
77
|
+
type: { value: args.type ?? '' },
|
|
78
|
+
data: { value: args.data ?? '' },
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return input
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
85
|
+
const executeNode: RoutineNode = {
|
|
86
|
+
id: options.id,
|
|
87
|
+
label: language.get(scriptable as any),
|
|
88
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
89
|
+
routine: 'Execute',
|
|
90
|
+
url: scriptable,
|
|
91
|
+
input: createExecuteInput(options.input)
|
|
92
|
+
}
|
|
93
|
+
return executeNode
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
scriptable,
|
|
98
|
+
RequestType,
|
|
99
|
+
createExecuteInput,
|
|
100
|
+
createExecuteNode,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as switch from './switch'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { language } from "../../../locale";
|
|
2
|
+
import { Asset } from "../../../asset";
|
|
3
|
+
import { Descriptor, RoutineNode, ServiceSchedulerDescriptor, UpdateArgs } from "../../../descriptor";
|
|
4
|
+
import { Graphics } from "../../../graphics";
|
|
5
|
+
import { Scriptable } from "../../../Scriptable";
|
|
6
|
+
|
|
7
|
+
const scriptable = Asset.createVirtualUrl('preset/scheduler/switch.ts')
|
|
8
|
+
class ExecuteScriptable extends Scriptable {
|
|
9
|
+
async execute(descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) {
|
|
10
|
+
//@ts-ignore
|
|
11
|
+
const scene = args.input?.user?.url.value
|
|
12
|
+
if (!scene) return
|
|
13
|
+
await Asset.loadAll(scene)
|
|
14
|
+
const scheduler = Asset.get<ServiceSchedulerDescriptor>(scene)
|
|
15
|
+
graphics.engine.switch(scheduler)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
Asset.provider(scriptable, async () => ({ default: ExecuteScriptable }))
|
|
19
|
+
|
|
20
|
+
const createExecuteInput = (args: any = {}) => {
|
|
21
|
+
const input = {
|
|
22
|
+
url: { value: args.url ?? '' },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return input
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
|
|
29
|
+
const executeNode: RoutineNode = {
|
|
30
|
+
id: options.id,
|
|
31
|
+
label: language.get(scriptable as any),
|
|
32
|
+
position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
|
|
33
|
+
routine: 'Execute',
|
|
34
|
+
url: scriptable,
|
|
35
|
+
input: createExecuteInput(options.input)
|
|
36
|
+
}
|
|
37
|
+
return executeNode
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
scriptable,
|
|
42
|
+
createExecuteInput,
|
|
43
|
+
createExecuteNode,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as invoke from "./invoke"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Asset } from "../../../asset";
|
|
2
|
+
import { RoutineDescriptor } from "../../../descriptor";
|
|
3
|
+
import { graphics } from "../../execute"
|
|
4
|
+
|
|
5
|
+
const url = Asset.createVirtualUrl('preset/graphics/invoke.routine.json')
|
|
6
|
+
const nodes = {
|
|
7
|
+
invoke: 'invoke'
|
|
8
|
+
}
|
|
9
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
10
|
+
const routineProvider = async () => {
|
|
11
|
+
if (_currentRoutine === null) {
|
|
12
|
+
_currentRoutine = new RoutineDescriptor()
|
|
13
|
+
const invokeNode = graphics.invoke.createExecuteNode({ id: nodes.invoke })
|
|
14
|
+
_currentRoutine.nodes.push(invokeNode)
|
|
15
|
+
_currentRoutine.roots.push(invokeNode.id)
|
|
16
|
+
}
|
|
17
|
+
return _currentRoutine
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Asset.provider(url, routineProvider)
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
url,
|
|
24
|
+
nodes,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as switch from "./switch"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Asset } from "../../../asset";
|
|
2
|
+
import { RoutineDescriptor } from "../../../descriptor";
|
|
3
|
+
import { scheduler } from "../../execute"
|
|
4
|
+
|
|
5
|
+
const url = Asset.createVirtualUrl('preset/scheduler/switch.routine.json')
|
|
6
|
+
const nodes = {
|
|
7
|
+
switch: 'switch',
|
|
8
|
+
}
|
|
9
|
+
let _currentRoutine: RoutineDescriptor | null = null
|
|
10
|
+
const routineProvider = async () => {
|
|
11
|
+
if (_currentRoutine === null) {
|
|
12
|
+
_currentRoutine = new RoutineDescriptor()
|
|
13
|
+
const switchNode = scheduler.switch.createExecuteNode({ id: nodes.switch })
|
|
14
|
+
_currentRoutine.nodes.push(switchNode)
|
|
15
|
+
_currentRoutine.roots.push(switchNode.id)
|
|
16
|
+
}
|
|
17
|
+
return _currentRoutine
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Asset.provider(url, routineProvider)
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
url,
|
|
24
|
+
nodes,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyleDescriptor } from "../descriptor"
|
|
2
|
+
import { StyleInterpreter } from "../interpreter"
|
|
3
|
+
import { StyleActor } from "../actor"
|
|
4
|
+
|
|
5
|
+
let needSetupStyle = false
|
|
6
|
+
const setupStyle = () => {
|
|
7
|
+
if (needSetupStyle === true) return
|
|
8
|
+
needSetupStyle = true
|
|
9
|
+
const actor = new StyleActor()
|
|
10
|
+
actor.update(StyleDescriptor.basicStyle, StyleDescriptor.basicName)
|
|
11
|
+
const styleValues = actor.getStyleValue()
|
|
12
|
+
StyleInterpreter.insertRule(styleValues)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
setupStyle
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Descriptor, DynamicDescriptor, PrefabInstanceDescriptor, RoutineDescriptor, HTMLDescriptor, StyleDescriptor, InteractionProperty, RoutineNode } from "../descriptor"
|
|
2
|
+
import { AssetGraph, Port } from "../asset"
|
|
3
|
+
import { Category } from "../Category"
|
|
4
|
+
|
|
5
|
+
const interactionExecutor = (interaction: InteractionProperty, path: string, port: Port) => {
|
|
6
|
+
const keys = Object.keys(interaction.inputs)
|
|
7
|
+
for (const key of keys) {
|
|
8
|
+
const input = interaction.inputs[key]
|
|
9
|
+
const params = Object.keys(input)
|
|
10
|
+
for (const param of params) {
|
|
11
|
+
const value = input[param]
|
|
12
|
+
if (value.type === undefined || Category.isDescriptor(value.type, 'category') === false) continue
|
|
13
|
+
if (value.value) port.edges.push({ key: `${path}.inputs.${key}.${param}.value`, category: value.type, asset: value.value })
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const routineNodeExecutor = (node: RoutineNode, path: string, port: Port) => {
|
|
18
|
+
const params = Object.keys(node.input)
|
|
19
|
+
for (const param of params) {
|
|
20
|
+
const value = node.input[param]
|
|
21
|
+
if (value.type === undefined || Category.isDescriptor(value.type, 'category') === false) continue
|
|
22
|
+
if (value.value) port.edges.push({ key: `${path}.input.${param}.value`, category: value.type, asset: value.value })
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const DescriptorProvider = (descriptor: Descriptor, port: Port) => {
|
|
27
|
+
if (descriptor.interactions.length > 0) {
|
|
28
|
+
for (let i = 0; i < descriptor.interactions.length; i++) {
|
|
29
|
+
const interaction = descriptor.interactions[i]
|
|
30
|
+
if (interaction.url) {
|
|
31
|
+
interactionExecutor(interaction, `interactions[${i}]`, port)
|
|
32
|
+
port.edges.push({ key: `interactions[${i}].url`, category: Category.routine, asset: interaction.url })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (descriptor.dataset) port.edges.push({ key: 'dataset', category: Category.dataset, asset: descriptor.dataset })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const StyleDescriptorProvider = (descriptor: StyleDescriptor, port: Port) => {
|
|
40
|
+
if (descriptor.inherit) port.edges.push({ key: 'inherit', category: Category.style, asset: descriptor.inherit })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const RoutineDescriptorProvider = (descriptor: RoutineDescriptor, port: Port) => {
|
|
44
|
+
if (descriptor.nodes.length > 0) {
|
|
45
|
+
for (let i = 0; i < descriptor.nodes.length; i++) {
|
|
46
|
+
const node = descriptor.nodes[i]
|
|
47
|
+
if (node.url) {
|
|
48
|
+
routineNodeExecutor(node, `nodes[${i}]`, port)
|
|
49
|
+
port.edges.push({ key: `nodes[${i}].url`, category: Category.ts, asset: node.url })
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const HTMLDescriptorProvider = (descriptor: HTMLDescriptor, port: Port) => {
|
|
56
|
+
if (descriptor.style) port.edges.push({ key: 'style', category: Category.style, asset: descriptor.style })
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const DynamicDescriptorProvider = (descriptor: DynamicDescriptor, port: Port) => {
|
|
60
|
+
if (descriptor.url) port.edges.push({ key: 'url', category: Category.prefab, asset: descriptor.url })
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const PrefabInstanceDescriptorProvider = (descriptor: PrefabInstanceDescriptor, port: Port) => {
|
|
64
|
+
if (descriptor.url) port.edges.push({ key: 'url', category: Category.prefab, asset: descriptor.url })
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
AssetGraph.register(Descriptor.type, DescriptorProvider)
|
|
68
|
+
AssetGraph.register(StyleDescriptor.type, StyleDescriptorProvider)
|
|
69
|
+
AssetGraph.register(RoutineDescriptor.type, RoutineDescriptorProvider)
|
|
70
|
+
AssetGraph.register(HTMLDescriptor.type, HTMLDescriptorProvider)
|
|
71
|
+
AssetGraph.register(DynamicDescriptor.type, DynamicDescriptorProvider)
|
|
72
|
+
AssetGraph.register(PrefabInstanceDescriptor.type, PrefabInstanceDescriptorProvider)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AssetProvider'
|