@vyr/engine 0.0.19 → 0.0.20
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 +2 -2
- package/src/asset/Asset.ts +2 -9
- package/src/interaction/Scriptable.ts +4 -0
- package/src/preset/execute/dataset/update.ts +1 -1
- package/src/preset/execute/graphics/invoke.ts +2 -2
- package/src/preset/execute/net/http.ts +3 -3
- package/src/preset/execute/scheduler/switch.ts +1 -1
- package/src/utils/AssetProvider.ts +19 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyr/engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@vyr/locale": "0.0.
|
|
9
|
+
"@vyr/locale": "0.0.20",
|
|
10
10
|
"tinycolor2": "1.6.0"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
package/src/asset/Asset.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { language } from "../locale"
|
|
2
2
|
import { Category } from "../Category"
|
|
3
3
|
import { AsyncTask } from "../AsyncTask"
|
|
4
|
-
import {
|
|
4
|
+
import { Descriptor, ServiceSchedulerDescriptor } from "../descriptor"
|
|
5
5
|
import { InteractionDescriptor, Scriptable, ScriptableArgs } from "../interaction"
|
|
6
6
|
import { AssetGraph } from "./AssetGraph"
|
|
7
7
|
import { Engine } from "../Engine"
|
|
@@ -239,14 +239,7 @@ Asset.register(Category.texture, factoryDescriptor)
|
|
|
239
239
|
Asset.register(Category.prefab, factoryDescriptor)
|
|
240
240
|
Asset.register(Category.interaction, factoryDescriptor)
|
|
241
241
|
Asset.register(Category.scene, factoryDescriptor)
|
|
242
|
-
|
|
243
|
-
const factoryDataset = async (url: string) => {
|
|
244
|
-
const asset = await factoryDescriptor(url) as DatasetDescriptor
|
|
245
|
-
// if (asset.auto) await asset.fetch()
|
|
246
|
-
|
|
247
|
-
return asset
|
|
248
|
-
}
|
|
249
|
-
Asset.register(Category.dataset, factoryDataset)
|
|
242
|
+
Asset.register(Category.dataset, factoryDescriptor)
|
|
250
243
|
|
|
251
244
|
const factoryJson = async (url: string) => {
|
|
252
245
|
const res = await Asset.fetch(Asset.joinUrl(url))
|
|
@@ -28,6 +28,10 @@ class Scriptable<T extends ScriptableArgs<any, any, any> = ScriptableArgs> {
|
|
|
28
28
|
this.uuid = url
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
getInputValue(key: string, input: ScriptableInput) {
|
|
32
|
+
return input?.user?.[key]?.value ?? input.default[key].value
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
/**脚本的准备事件,该方法在脚本被实例化后立即执行
|
|
32
36
|
*
|
|
33
37
|
* 一般在该事件中进行脚本的准备工作,如从服务端获取资源或数据
|
|
@@ -9,7 +9,7 @@ const scriptable = Asset.createVirtualUrl('preset/dataset/update.ts')
|
|
|
9
9
|
class ExecuteScriptable extends Scriptable {
|
|
10
10
|
async execute(graphics: Graphics, args: ScriptableArgs) {
|
|
11
11
|
const { input, result } = args
|
|
12
|
-
const dataset =
|
|
12
|
+
const dataset = this.getInputValue('dataset', input)
|
|
13
13
|
|
|
14
14
|
const previous = result.get(input.previous)
|
|
15
15
|
const datasetDescriptor = Asset.get<DatasetDescriptor>(dataset)
|
|
@@ -8,8 +8,8 @@ const scriptable = Asset.createVirtualUrl('preset/graphics/invoke.ts')
|
|
|
8
8
|
class ExecuteScriptable extends Scriptable {
|
|
9
9
|
async execute(graphics: Graphics, args: ScriptableArgs) {
|
|
10
10
|
const { input } = args
|
|
11
|
-
const interaction =
|
|
12
|
-
const target =
|
|
11
|
+
const interaction = this.getInputValue('interaction', input)
|
|
12
|
+
const target = this.getInputValue('target', input)
|
|
13
13
|
const targetDescriptor = Descriptor.get<Descriptor>(target)
|
|
14
14
|
if (interaction && targetDescriptor) {
|
|
15
15
|
graphics.invoke(interaction, targetDescriptor)
|
|
@@ -22,9 +22,9 @@ class ExecuteScriptable extends Scriptable {
|
|
|
22
22
|
|
|
23
23
|
async execute(graphics: Graphics, args: ScriptableArgs) {
|
|
24
24
|
const { input, result } = args
|
|
25
|
-
let url =
|
|
26
|
-
const type
|
|
27
|
-
const data
|
|
25
|
+
let url = this.getInputValue('url', input)
|
|
26
|
+
const type = this.getInputValue('type', input)
|
|
27
|
+
const data = this.getInputValue('data', input)
|
|
28
28
|
|
|
29
29
|
const requestData: { [k: string]: any } = {}
|
|
30
30
|
const keys: string[] = []
|
|
@@ -7,7 +7,7 @@ import { Graphics } from "../../../graphics";
|
|
|
7
7
|
const scriptable = Asset.createVirtualUrl('preset/scheduler/switch.ts')
|
|
8
8
|
class ExecuteScriptable extends Scriptable {
|
|
9
9
|
async execute(graphics: Graphics, args: ScriptableArgs) {
|
|
10
|
-
const scene = args.input
|
|
10
|
+
const scene = this.getInputValue('scene', args.input)
|
|
11
11
|
if (!scene) return
|
|
12
12
|
await Asset.loadAll(scene)
|
|
13
13
|
await Asset.compileDataset(scene, graphics.engine)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionDescriptor, InteractionNode, InteractionProperty } from "../interaction"
|
|
2
|
-
import { Descriptor, DynamicDescriptor, PrefabInstanceDescriptor, HTMLDescriptor, StyleDescriptor } from "../descriptor"
|
|
2
|
+
import { Descriptor, DynamicDescriptor, PrefabInstanceDescriptor, HTMLDescriptor, StyleDescriptor, DatasetDescriptor, DivDescriptor } from "../descriptor"
|
|
3
3
|
import { AssetGraph, Port } from "../asset"
|
|
4
4
|
import { Category } from "../Category"
|
|
5
5
|
|
|
@@ -37,6 +37,18 @@ const DescriptorProvider = (descriptor: Descriptor, port: Port) => {
|
|
|
37
37
|
if (descriptor.dataset) port.edges.push({ key: 'dataset', category: Category.dataset, asset: descriptor.dataset })
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
const DatasetDescriptorProvider = (descriptor: DatasetDescriptor, port: Port) => {
|
|
41
|
+
if (descriptor.dataConfigs.length > 0) {
|
|
42
|
+
for (let i = 0; i < descriptor.dataConfigs.length; i++) {
|
|
43
|
+
const dataConfig = descriptor.dataConfigs[i]
|
|
44
|
+
if (dataConfig.url && dataConfig.url.startsWith('/') && dataConfig.url.endsWith('.json')) {
|
|
45
|
+
port.edges.push({ key: `dataConfig[${i}].url`, category: Category.json, asset: dataConfig.url })
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (descriptor.dataset) port.edges.push({ key: 'dataset', category: Category.dataset, asset: descriptor.dataset })
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
const StyleDescriptorProvider = (descriptor: StyleDescriptor, port: Port) => {
|
|
41
53
|
if (descriptor.inherit) port.edges.push({ key: 'inherit', category: Category.style, asset: descriptor.inherit })
|
|
42
54
|
}
|
|
@@ -57,6 +69,10 @@ const HTMLDescriptorProvider = (descriptor: HTMLDescriptor, port: Port) => {
|
|
|
57
69
|
if (descriptor.style) port.edges.push({ key: 'style', category: Category.style, asset: descriptor.style })
|
|
58
70
|
}
|
|
59
71
|
|
|
72
|
+
const DivDescriptorProvider = (descriptor: DivDescriptor, port: Port) => {
|
|
73
|
+
if (descriptor.backroundIamge) port.edges.push({ key: 'backroundIamge', category: Category.image, asset: descriptor.backroundIamge })
|
|
74
|
+
}
|
|
75
|
+
|
|
60
76
|
const DynamicDescriptorProvider = (descriptor: DynamicDescriptor, port: Port) => {
|
|
61
77
|
if (descriptor.url) port.edges.push({ key: 'url', category: Category.prefab, asset: descriptor.url })
|
|
62
78
|
}
|
|
@@ -66,8 +82,10 @@ const PrefabInstanceDescriptorProvider = (descriptor: PrefabInstanceDescriptor,
|
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
AssetGraph.register(Descriptor.type, DescriptorProvider)
|
|
85
|
+
AssetGraph.register(DatasetDescriptor.type, DatasetDescriptorProvider)
|
|
69
86
|
AssetGraph.register(StyleDescriptor.type, StyleDescriptorProvider)
|
|
70
87
|
AssetGraph.register(InteractionDescriptor.type, InteractionDescriptorProvider)
|
|
71
88
|
AssetGraph.register(HTMLDescriptor.type, HTMLDescriptorProvider)
|
|
89
|
+
AssetGraph.register(DivDescriptor.type, DivDescriptorProvider)
|
|
72
90
|
AssetGraph.register(DynamicDescriptor.type, DynamicDescriptorProvider)
|
|
73
91
|
AssetGraph.register(PrefabInstanceDescriptor.type, PrefabInstanceDescriptorProvider)
|