@vyr/engine 0.0.33 → 0.0.34
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 +6 -3
- package/src/ArrayUtils.ts +63 -65
- package/src/AsyncTask.ts +67 -71
- package/src/Category.ts +69 -86
- package/src/Color.ts +3 -111
- package/src/Engine.ts +12 -24
- package/src/Executor.ts +109 -0
- package/src/Generate.ts +23 -40
- package/src/InputSystem.ts +106 -108
- package/src/Listener.ts +58 -59
- package/src/ObjectPool.ts +83 -84
- package/src/ObjectUtils.ts +97 -49
- package/src/Scriptable.ts +82 -0
- package/src/Serialization.ts +4 -6
- package/src/Traverser.ts +41 -39
- package/src/actor/Actor.ts +23 -27
- package/src/actor/AnimationUnitActor.ts +22 -36
- package/src/actor/DivActor.ts +21 -41
- package/src/actor/FragmentActor.ts +1 -5
- package/src/actor/HTMLActor.ts +81 -0
- package/src/actor/HTMLServiceActor.ts +49 -0
- package/src/actor/{HTMTransformControllerActor.ts → HTMLTransformControllerActor.ts} +178 -71
- package/src/actor/InputActor.ts +50 -0
- package/src/actor/TextActor.ts +51 -0
- package/src/actor/index.ts +6 -5
- package/src/asset/Asset.ts +23 -68
- package/src/asset/AssetGraph.ts +21 -28
- package/src/descriptor/AnimationUnit.ts +81 -0
- package/src/descriptor/Camera.ts +12 -0
- package/src/descriptor/Controller.ts +6 -0
- package/src/descriptor/Descriptor.ts +133 -113
- package/src/descriptor/Div.ts +29 -0
- package/src/descriptor/HTML.ts +22 -0
- package/src/descriptor/HTMLService.ts +42 -0
- package/src/descriptor/HTMLTransformController.ts +67 -0
- package/src/descriptor/Input.ts +29 -0
- package/src/descriptor/Interaction.ts +80 -0
- package/src/descriptor/Node.ts +98 -0
- package/src/descriptor/Scene.ts +110 -0
- package/src/descriptor/Service.ts +11 -0
- package/src/descriptor/Store.ts +136 -0
- package/src/descriptor/Text.ts +36 -0
- package/src/descriptor/index.ts +14 -15
- package/src/graphics/Collection.ts +1 -5
- package/src/graphics/Compilation.ts +15 -19
- package/src/graphics/Graphics.ts +41 -54
- package/src/graphics/Observer.ts +6 -14
- package/src/graphics/Unit.ts +3 -9
- package/src/graphics/VariableProxy.ts +11 -15
- package/src/index.ts +5 -5
- package/src/interpreter/AnimationUnitInterpreter.ts +7 -9
- package/src/interpreter/DivInterpreter.ts +10 -13
- package/src/interpreter/FragmentInterpreter.ts +2 -6
- package/src/interpreter/HTMLServiceInterpreter.ts +25 -15
- package/src/interpreter/HTMLTransformControllerInterpreter.ts +9 -12
- package/src/interpreter/InputInterpreter.ts +41 -0
- package/src/interpreter/Interpreter.ts +3 -4
- package/src/interpreter/SceneInterpreter.ts +93 -0
- package/src/interpreter/ServiceInterpreter.ts +8 -15
- package/src/interpreter/StoreInterpreter.ts +7 -0
- package/src/interpreter/TextInterpreter.ts +41 -0
- package/src/interpreter/index.ts +5 -7
- package/src/locale/Language.ts +1 -5
- package/src/locale/LanguageProvider.ts +164 -21
- package/src/math/Euler.ts +2 -5
- package/src/math/Matrix4.ts +2 -4
- package/src/math/Quaternion.ts +2 -4
- package/src/math/Vector2.ts +4 -4
- package/src/math/Vector3.ts +2 -4
- package/src/math/utils.ts +1 -5
- package/src/schema/AnimationUnit.ts +68 -0
- package/src/schema/Asset.ts +13 -0
- package/src/schema/Descriptor.ts +41 -0
- package/src/schema/HTML.ts +261 -0
- package/src/schema/Interaction.ts +50 -0
- package/src/schema/Scene.ts +138 -0
- package/src/schema/Store.ts +8 -0
- package/src/schema/index.ts +7 -0
- package/src/scripts/ConditionScriptable.ts +196 -0
- package/src/scripts/FetchScriptable.ts +51 -0
- package/src/scripts/FindScriptable.ts +23 -0
- package/src/scripts/InvokeScriptable.ts +13 -0
- package/src/scripts/SwitchSceneScriptable.ts +18 -0
- package/src/scripts/UpdateScriptable.ts +60 -0
- package/src/scripts/index.ts +6 -0
- package/src/utils/AssetProvider.ts +4 -77
- package/src/utils/DOM.ts +37 -0
- package/src/utils/HTML.ts +5 -0
- package/src/utils/Service.ts +40 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/http.ts +2 -21
- package/src/utils/index.ts +3 -1
- package/src/actor/HTMActor.ts +0 -169
- package/src/actor/HTMServiceActor.ts +0 -57
- package/src/actor/StyleActor.ts +0 -96
- package/src/descriptor/AnimationUnitDescriptor.ts +0 -65
- package/src/descriptor/CameraDescriptor.ts +0 -12
- package/src/descriptor/ControllerDescriptor.ts +0 -16
- package/src/descriptor/DatasetDescriptor.ts +0 -90
- package/src/descriptor/DivDescriptor.ts +0 -18
- package/src/descriptor/DynamicDescriptor.ts +0 -27
- package/src/descriptor/HTMLDescriptor.ts +0 -87
- package/src/descriptor/HTMLServiceDescriptor.ts +0 -19
- package/src/descriptor/HTMLTransformControllerDescriptor.ts +0 -34
- package/src/descriptor/NodeDescriptor.ts +0 -32
- package/src/descriptor/PrefabDescriptor.ts +0 -53
- package/src/descriptor/PrefabInstanceDescriptor.ts +0 -32
- package/src/descriptor/ServiceDescriptor.ts +0 -32
- package/src/descriptor/ServiceSchedulerDescriptor.ts +0 -32
- package/src/descriptor/StyleDescriptor.ts +0 -213
- package/src/interaction/InteractionDescriptor.ts +0 -96
- package/src/interaction/InteractionExecutor.ts +0 -84
- package/src/interaction/Scriptable.ts +0 -44
- package/src/interaction/index.ts +0 -3
- package/src/interpreter/DatasetInterpreter.ts +0 -11
- package/src/interpreter/DynamicInterpreter.ts +0 -207
- package/src/interpreter/PrefaInterpreter.ts +0 -11
- package/src/interpreter/PrefabInstanceInterpreter.ts +0 -12
- package/src/interpreter/ServiceSchedulerInterpreter.ts +0 -42
- package/src/interpreter/StyleInterpreter.ts +0 -66
- package/src/preset/execute/dataset/index.ts +0 -1
- package/src/preset/execute/dataset/update.ts +0 -51
- package/src/preset/execute/graphics/index.ts +0 -1
- package/src/preset/execute/graphics/invoke.ts +0 -48
- package/src/preset/execute/index.ts +0 -4
- package/src/preset/execute/net/http.ts +0 -52
- package/src/preset/execute/net/index.ts +0 -1
- package/src/preset/execute/scheduler/index.ts +0 -1
- package/src/preset/execute/scheduler/switch.ts +0 -46
- package/src/preset/index.ts +0 -7
- package/src/preset/interaction/graphics/index.ts +0 -1
- package/src/preset/interaction/graphics/invoke.ts +0 -27
- package/src/preset/interaction/index.ts +0 -2
- package/src/preset/interaction/scheduler/index.ts +0 -1
- package/src/preset/interaction/scheduler/switch.ts +0 -27
- package/src/setup/index.ts +0 -17
- package/src/utils/compile.ts +0 -50
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { Engine } from "../Engine";
|
|
2
2
|
import { Graphics, TickArgs } from "./Graphics";
|
|
3
3
|
import { Asset } from "../asset";
|
|
4
|
-
import {
|
|
4
|
+
import { AnimationUnit, Scene } from "../descriptor";
|
|
5
5
|
|
|
6
|
-
class Compilation {
|
|
6
|
+
export class Compilation {
|
|
7
7
|
private collection = new Map<string, Graphics>()
|
|
8
8
|
|
|
9
|
-
get(
|
|
10
|
-
return (this.collection.get(
|
|
9
|
+
get(scene: Scene) {
|
|
10
|
+
return (this.collection.get(scene.uuid) ?? null) as Graphics
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
delete(
|
|
14
|
-
const graphics = this.collection.get(
|
|
13
|
+
delete(scene: Scene) {
|
|
14
|
+
const graphics = this.collection.get(scene.uuid)
|
|
15
15
|
if (graphics === undefined) return
|
|
16
16
|
graphics.unlisten()
|
|
17
|
-
this.collection.delete(
|
|
17
|
+
this.collection.delete(scene.uuid)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
ensureExists(url: string,
|
|
21
|
-
let graphics = this.collection.get(
|
|
20
|
+
ensureExists(url: string, scene: Scene, engine: Engine) {
|
|
21
|
+
let graphics = this.collection.get(scene.uuid)
|
|
22
22
|
if (graphics === undefined) {
|
|
23
|
-
graphics = new Graphics(url,
|
|
24
|
-
this.collection.set(
|
|
23
|
+
graphics = new Graphics(url, scene, engine)
|
|
24
|
+
this.collection.set(scene.uuid, graphics)
|
|
25
25
|
}
|
|
26
26
|
return graphics
|
|
27
27
|
}
|
|
@@ -30,8 +30,8 @@ class Compilation {
|
|
|
30
30
|
graphics.listen()
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
unlisten(
|
|
34
|
-
this.delete(
|
|
33
|
+
unlisten(scene: Scene) {
|
|
34
|
+
this.delete(scene)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
foreach(executor: (graphics: Graphics) => void) {
|
|
@@ -50,7 +50,7 @@ class Compilation {
|
|
|
50
50
|
graphics.clear()
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
engine.trigger(
|
|
53
|
+
engine.trigger(AnimationUnit.type, args)
|
|
54
54
|
|
|
55
55
|
this.foreach((graphics) => graphics.beforeRender())
|
|
56
56
|
|
|
@@ -64,11 +64,7 @@ class Compilation {
|
|
|
64
64
|
clear() {
|
|
65
65
|
const collection = this.collection.values()
|
|
66
66
|
for (const graphics of collection) {
|
|
67
|
-
this.unlisten(graphics.
|
|
67
|
+
this.unlisten(graphics.scene)
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
Compilation
|
|
74
70
|
}
|
package/src/graphics/Graphics.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { language } from '../locale'
|
|
2
2
|
import { ArrayUtils } from "../ArrayUtils";
|
|
3
3
|
import { Asset, Dependencide } from "../asset";
|
|
4
|
-
import {
|
|
4
|
+
import { Descriptor, HTMLService, Service, Scene, Interaction } from "../descriptor";
|
|
5
5
|
import { privateState } from "../interpreter/Interpreter";
|
|
6
|
-
import { Interpreter, ServiceInterpreter,
|
|
6
|
+
import { Interpreter, ServiceInterpreter, SceneInterpreter } from "../interpreter";
|
|
7
7
|
import { observer, UpdateDepsWatcherArgs, UpdateWatcherArgs, WatcherArgs } from "./Observer";
|
|
8
8
|
import { Operation, Queue, Unit } from "./Unit";
|
|
9
9
|
import { Actor } from '../actor/Actor';
|
|
10
|
+
import { HTMLActor } from '../actor/HTMLActor';
|
|
10
11
|
import { UnitCollection } from "./Collection";
|
|
11
12
|
import { VariableProxy } from "./VariableProxy";
|
|
12
13
|
import { Engine } from '../Engine';
|
|
13
|
-
import {
|
|
14
|
+
import { isService, isHTML } from '../utils';
|
|
14
15
|
|
|
15
|
-
interface TickArgs {
|
|
16
|
+
export interface TickArgs {
|
|
16
17
|
delta: number
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
interface PickupObject {
|
|
20
|
+
export interface PickupObject {
|
|
20
21
|
[k: string]: any
|
|
21
22
|
uuid: string
|
|
22
|
-
generatedBy: string
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type OverrideUpdate = (descriptor: Descriptor, interpreter: Interpreter) => void
|
|
25
|
+
export type OverrideUpdate = (descriptor: Descriptor, interpreter: Interpreter) => void
|
|
26
26
|
|
|
27
|
-
class Graphics {
|
|
27
|
+
export class Graphics {
|
|
28
28
|
static createInterpreter<T extends Interpreter = Interpreter>(descriptor: Descriptor, graphics: Graphics) {
|
|
29
29
|
const Class = Interpreter.getClass(descriptor.type)
|
|
30
30
|
if (Class === null) throw new Error(language.get('graphics.interpreter.notRegister', { type: descriptor.type }))
|
|
@@ -43,7 +43,7 @@ class Graphics {
|
|
|
43
43
|
private readonly _assetCollection = new Map<string, Unit>()
|
|
44
44
|
private readonly _freeCollection = new Map<string, Unit>()
|
|
45
45
|
private readonly _dependencide = new Dependencide()
|
|
46
|
-
private readonly _services:
|
|
46
|
+
private readonly _services: Service[] = []
|
|
47
47
|
private readonly _freeQueue: Unit[] = []
|
|
48
48
|
private _currentCamera = ''
|
|
49
49
|
private _currentArgs: TickArgs = { delta: 0 }
|
|
@@ -55,12 +55,12 @@ class Graphics {
|
|
|
55
55
|
}
|
|
56
56
|
readonly unitCollection = new UnitCollection()
|
|
57
57
|
readonly variableProxy = new VariableProxy()
|
|
58
|
-
readonly
|
|
58
|
+
readonly scene: Scene
|
|
59
59
|
readonly engine: Engine
|
|
60
60
|
readonly url: string
|
|
61
61
|
|
|
62
|
-
constructor(url: string,
|
|
63
|
-
this.
|
|
62
|
+
constructor(url: string, scene: Scene, engine: Engine) {
|
|
63
|
+
this.scene = scene
|
|
64
64
|
this.engine = engine
|
|
65
65
|
this.url = url
|
|
66
66
|
}
|
|
@@ -83,17 +83,17 @@ class Graphics {
|
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
|
|
86
|
-
const descriptor = this.variableProxy.get<
|
|
87
|
-
const interpreter = this.getInterpreter<
|
|
86
|
+
const descriptor = this.variableProxy.get<Scene>(this.scene.uuid, this)
|
|
87
|
+
const interpreter = this.getInterpreter<SceneInterpreter>(descriptor)
|
|
88
88
|
interpreter.install(descriptor)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
unlisten() {
|
|
92
|
-
const descriptor = this.variableProxy.get<
|
|
93
|
-
const interpreter = this.getInterpreter<
|
|
92
|
+
const descriptor = this.variableProxy.get<Scene>(this.scene.uuid, this)
|
|
93
|
+
const interpreter = this.getInterpreter<SceneInterpreter>(descriptor)
|
|
94
94
|
interpreter.uninstall(descriptor)
|
|
95
95
|
|
|
96
|
-
const master = this.unitCollection.get(this.
|
|
96
|
+
const master = this.unitCollection.get(this.scene.uuid)
|
|
97
97
|
const assets = [...this._assetCollection.values()]
|
|
98
98
|
if (master !== undefined) assets.push(master)
|
|
99
99
|
|
|
@@ -152,7 +152,7 @@ class Graphics {
|
|
|
152
152
|
asset.queue.iterator(operation => this.do(operation))
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
const master = this.unitCollection.get(this.
|
|
155
|
+
const master = this.unitCollection.get(this.scene.uuid)
|
|
156
156
|
if (master === undefined) return
|
|
157
157
|
|
|
158
158
|
master.queue.iterator(operation => this.do(operation))
|
|
@@ -173,7 +173,7 @@ class Graphics {
|
|
|
173
173
|
|
|
174
174
|
clear() {
|
|
175
175
|
for (const service of this._services) {
|
|
176
|
-
const descriptor = this.variableProxy.get<
|
|
176
|
+
const descriptor = this.variableProxy.get<Service>(service.uuid, this)
|
|
177
177
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
178
178
|
interpreter.clear(descriptor)
|
|
179
179
|
}
|
|
@@ -181,7 +181,7 @@ class Graphics {
|
|
|
181
181
|
|
|
182
182
|
beforeRender() {
|
|
183
183
|
for (const service of this._services) {
|
|
184
|
-
const descriptor = this.variableProxy.get<
|
|
184
|
+
const descriptor = this.variableProxy.get<Service>(service.uuid, this)
|
|
185
185
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
186
186
|
interpreter.beforeRender(descriptor)
|
|
187
187
|
}
|
|
@@ -189,7 +189,7 @@ class Graphics {
|
|
|
189
189
|
|
|
190
190
|
render() {
|
|
191
191
|
for (const service of this._services) {
|
|
192
|
-
const descriptor = this.variableProxy.get<
|
|
192
|
+
const descriptor = this.variableProxy.get<Service>(service.uuid, this)
|
|
193
193
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
194
194
|
interpreter.render(descriptor)
|
|
195
195
|
}
|
|
@@ -197,7 +197,7 @@ class Graphics {
|
|
|
197
197
|
|
|
198
198
|
afterRender() {
|
|
199
199
|
for (const service of this._services) {
|
|
200
|
-
const descriptor = this.variableProxy.get<
|
|
200
|
+
const descriptor = this.variableProxy.get<Service>(service.uuid, this)
|
|
201
201
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
202
202
|
interpreter.afterRender(descriptor)
|
|
203
203
|
}
|
|
@@ -296,8 +296,8 @@ class Graphics {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
private updateStaticAsset() {
|
|
299
|
-
if (this.
|
|
300
|
-
const descriptor = Descriptor.get<Descriptor>(this.
|
|
299
|
+
if (this.scene.camera !== this._currentCamera) {
|
|
300
|
+
const descriptor = Descriptor.get<Descriptor>(this.scene.camera)
|
|
301
301
|
if (descriptor === null) return
|
|
302
302
|
const oldNode = this.unitCollection.get(this._currentCamera)
|
|
303
303
|
if (oldNode) {
|
|
@@ -308,7 +308,7 @@ class Graphics {
|
|
|
308
308
|
const newNode = new Unit(descriptor.uuid, '', new Queue(Asset.createVirtualUrl('graphics/camera.ts')))
|
|
309
309
|
this.unitCollection.set(newNode)
|
|
310
310
|
ArrayUtils.insert(this._staticAssetQueue, newNode)
|
|
311
|
-
this._currentCamera = this.
|
|
311
|
+
this._currentCamera = this.scene.camera
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
|
|
@@ -331,7 +331,7 @@ class Graphics {
|
|
|
331
331
|
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
|
|
332
332
|
const interpreter = this.getInterpreter(descriptor)
|
|
333
333
|
|
|
334
|
-
if (descriptor
|
|
334
|
+
if (isService(descriptor)) ArrayUtils.insert(this._services, descriptor)
|
|
335
335
|
|
|
336
336
|
interpreter.mount(descriptor, parentInterpreter, parentDescriptor)
|
|
337
337
|
}
|
|
@@ -343,7 +343,7 @@ class Graphics {
|
|
|
343
343
|
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
|
|
344
344
|
const interpreter = this.getInterpreter(descriptor)
|
|
345
345
|
|
|
346
|
-
if (descriptor
|
|
346
|
+
if (isService(descriptor)) ArrayUtils.remove(this._services, descriptor)
|
|
347
347
|
|
|
348
348
|
interpreter.unmount(descriptor, parentInterpreter, parentDescriptor)
|
|
349
349
|
}
|
|
@@ -408,26 +408,19 @@ class Graphics {
|
|
|
408
408
|
interpreter.pickup(target, result)
|
|
409
409
|
}
|
|
410
410
|
private _pickupScene(result: PickupObject[]) {
|
|
411
|
-
const master = this.unitCollection.get(this.
|
|
411
|
+
const master = this.unitCollection.get(this.scene.uuid)
|
|
412
412
|
if (master === undefined) return result
|
|
413
413
|
|
|
414
414
|
const units = this.unitCollection.values()
|
|
415
415
|
for (const unit of units) {
|
|
416
416
|
const descriptor = Descriptor.get<Descriptor>(unit.uuid)
|
|
417
|
-
if (descriptor
|
|
417
|
+
if (isHTML(descriptor)) continue
|
|
418
418
|
this._pickupItem(descriptor, result)
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const rect = event.target.getBoundingClientRect()
|
|
425
|
-
const mouse = { x: event.clientX - rect.left, y: event.clientY - rect.top }
|
|
426
|
-
return { mouse, rect }
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
traceService(target: Descriptor): ServiceDescriptor | null {
|
|
430
|
-
if (target instanceof ServiceDescriptor) return target
|
|
422
|
+
traceService(target: Descriptor): Service | null {
|
|
423
|
+
if (isService(target)) return target
|
|
431
424
|
|
|
432
425
|
const parent = this.getParent(target.uuid)
|
|
433
426
|
if (parent === null) return null
|
|
@@ -435,19 +428,18 @@ class Graphics {
|
|
|
435
428
|
return this.traceService(parent)
|
|
436
429
|
}
|
|
437
430
|
|
|
438
|
-
pickup(
|
|
431
|
+
pickup(x: number, y: number, trigger: Element) {
|
|
439
432
|
const result: PickupObject[] = []
|
|
440
|
-
|
|
441
|
-
const isElement = event.target instanceof Element
|
|
442
|
-
if (isElement === false) return result
|
|
443
|
-
const uuid = event.target.getAttribute('data-vyr-uuid')
|
|
433
|
+
const uuid = trigger.getAttribute(HTMLActor.uuidKey)
|
|
444
434
|
if (uuid === null) return result
|
|
445
435
|
|
|
446
|
-
|
|
436
|
+
//@ts-ignore
|
|
437
|
+
const rect = trigger.getBoundingClientRect()
|
|
438
|
+
const mouse = { x: x - rect.left, y: y - rect.top }
|
|
447
439
|
const target = Descriptor.get<Descriptor>(uuid)
|
|
448
|
-
|
|
449
|
-
if (target
|
|
450
|
-
if (target instanceof
|
|
440
|
+
|
|
441
|
+
if (isService(target)) {
|
|
442
|
+
if (target instanceof HTMLService) {
|
|
451
443
|
this._pickupItem(target, result)
|
|
452
444
|
} else {
|
|
453
445
|
const interpreter = this.getInterpreter<ServiceInterpreter>(target)
|
|
@@ -466,8 +458,8 @@ class Graphics {
|
|
|
466
458
|
if (descriptor.interactions.length === 0) return
|
|
467
459
|
for (const inter of descriptor.interactions) {
|
|
468
460
|
if (inter.type === interaction) {
|
|
469
|
-
const current = Asset.get<
|
|
470
|
-
if (current !== null) await current.execute(inter.
|
|
461
|
+
const current = Asset.get<Interaction>(inter.url)
|
|
462
|
+
if (current !== null) await current.execute(inter.nodes, this, descriptor.uuid)
|
|
471
463
|
break
|
|
472
464
|
}
|
|
473
465
|
}
|
|
@@ -481,8 +473,3 @@ class Graphics {
|
|
|
481
473
|
}
|
|
482
474
|
}
|
|
483
475
|
|
|
484
|
-
export {
|
|
485
|
-
PickupObject,
|
|
486
|
-
TickArgs,
|
|
487
|
-
Graphics,
|
|
488
|
-
}
|
package/src/graphics/Observer.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Listener } from "../Listener"
|
|
2
2
|
|
|
3
|
-
interface WatcherArgs {
|
|
3
|
+
export interface WatcherArgs {
|
|
4
4
|
self: string
|
|
5
5
|
puid: string
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
interface UpdateWatcherArgs {
|
|
8
|
+
export interface UpdateWatcherArgs {
|
|
9
9
|
self: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
interface UpdateDepsWatcherArgs {
|
|
12
|
+
export interface UpdateDepsWatcherArgs {
|
|
13
13
|
self: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
interface FreeWatcherArgs {
|
|
16
|
+
export interface FreeWatcherArgs {
|
|
17
17
|
self: string
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
interface Observer {
|
|
20
|
+
export interface Observer {
|
|
21
21
|
add(args: WatcherArgs): void
|
|
22
22
|
remove(args: WatcherArgs): void
|
|
23
23
|
update(args: UpdateWatcherArgs): void
|
|
@@ -25,12 +25,4 @@ interface Observer {
|
|
|
25
25
|
free(args: FreeWatcherArgs): void
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const observer = new Listener<Observer>()
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
WatcherArgs,
|
|
32
|
-
UpdateWatcherArgs,
|
|
33
|
-
UpdateDepsWatcherArgs,
|
|
34
|
-
FreeWatcherArgs,
|
|
35
|
-
observer,
|
|
36
|
-
}
|
|
28
|
+
export const observer = new Listener<Observer>()
|
package/src/graphics/Unit.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ArrayUtils } from "../ArrayUtils"
|
|
2
2
|
|
|
3
|
-
interface Operation {
|
|
3
|
+
export interface Operation {
|
|
4
4
|
type: number
|
|
5
5
|
unit: Unit
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
class Queue {
|
|
8
|
+
export class Queue {
|
|
9
9
|
static readonly Add = 1
|
|
10
10
|
static readonly Remove = 2
|
|
11
11
|
static readonly Update = 3
|
|
@@ -50,7 +50,7 @@ class Queue {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
class Unit {
|
|
53
|
+
export class Unit {
|
|
54
54
|
uuid: string
|
|
55
55
|
parent: string
|
|
56
56
|
queue: Queue
|
|
@@ -74,10 +74,4 @@ class Unit {
|
|
|
74
74
|
break
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export {
|
|
80
|
-
Operation,
|
|
81
|
-
Queue,
|
|
82
|
-
Unit,
|
|
83
77
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { VariabConfig } from "../schema";
|
|
1
2
|
import { ObjectUtils } from "../ObjectUtils";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Data, DatasetDescriptor, Descriptor, VariabConfig } from "../descriptor";
|
|
3
|
+
import { Scriptable } from "../Scriptable";
|
|
4
|
+
import { Data, Store, Descriptor } from "../descriptor";
|
|
5
5
|
import { Graphics } from "./Graphics";
|
|
6
6
|
|
|
7
7
|
interface ActorCollection { [k: string]: any }
|
|
8
8
|
|
|
9
|
-
interface Variables { [k: string]: any }
|
|
9
|
+
export interface Variables { [k: string]: any }
|
|
10
10
|
|
|
11
|
-
class VariableProxy {
|
|
11
|
+
export class VariableProxy {
|
|
12
12
|
private readonly proxyCollection = new Map<Descriptor, any>()
|
|
13
13
|
private readonly variablesCollection = new Map<Descriptor, Variables>()
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ class VariableProxy {
|
|
|
26
26
|
|
|
27
27
|
const value = Reflect.get(target, prop)
|
|
28
28
|
|
|
29
|
-
if (value
|
|
29
|
+
if (ObjectUtils.isObject(value) && !Array.isArray(value)) {
|
|
30
30
|
return this.createNestedProxy(value, root, fullPath)
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -38,10 +38,9 @@ class VariableProxy {
|
|
|
38
38
|
if (config.type === 'key') {
|
|
39
39
|
return ObjectUtils.getValueByKey(data, config.value)
|
|
40
40
|
} else if (config.type === 'custom') {
|
|
41
|
-
const scriptable =
|
|
41
|
+
const scriptable = Scriptable.use(config.value)
|
|
42
42
|
if (scriptable === null) return
|
|
43
|
-
|
|
44
|
-
return scriptable.execute(graphics, currentArgs)
|
|
43
|
+
return scriptable.execute(graphics, descriptor.uuid, { key, config, data })
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -56,14 +55,15 @@ class VariableProxy {
|
|
|
56
55
|
variables = Object.create(null) as Variables
|
|
57
56
|
variables.version = 0
|
|
58
57
|
|
|
59
|
-
const data =
|
|
58
|
+
const data = Store.getData(descriptor.store)
|
|
60
59
|
|
|
61
60
|
if (data !== null) {
|
|
62
61
|
const keys = Object.keys(descriptor.variables)
|
|
63
62
|
for (const key of keys) {
|
|
64
63
|
const variable = descriptor.variables[key]
|
|
65
64
|
if (variable.enabled === false) continue
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
const value = this.getVariableValue(descriptor, descriptor, key, variable, graphics)
|
|
67
67
|
if (value === undefined) continue
|
|
68
68
|
variables[key] = value
|
|
69
69
|
}
|
|
@@ -86,7 +86,3 @@ class VariableProxy {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
export {
|
|
90
|
-
Variables,
|
|
91
|
-
VariableProxy
|
|
92
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -6,22 +6,22 @@ export * from './locale'
|
|
|
6
6
|
export * from './math'
|
|
7
7
|
export * from './Color'
|
|
8
8
|
export * from './Serialization'
|
|
9
|
-
export { Category } from './Category'
|
|
9
|
+
export { Category, Suffix } from './Category'
|
|
10
10
|
export { ArrayUtils } from './ArrayUtils'
|
|
11
11
|
export { ObjectUtils } from './ObjectUtils'
|
|
12
12
|
export { Generate } from './Generate'
|
|
13
13
|
export { Traverser } from './Traverser'
|
|
14
14
|
export { Listener } from './Listener'
|
|
15
15
|
export { InputSystem } from './InputSystem'
|
|
16
|
-
export { destroyInstance } from './ObjectPool'
|
|
16
|
+
export { ObjectPool, destroyInstance } from './ObjectPool'
|
|
17
17
|
export * from './AsyncTask'
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './interaction'
|
|
18
|
+
export * from './schema'
|
|
20
19
|
export * from './descriptor'
|
|
21
20
|
export * from './interpreter'
|
|
21
|
+
export * from './Scriptable'
|
|
22
|
+
export * from './scripts'
|
|
22
23
|
export * from './utils'
|
|
23
24
|
export * from './actor'
|
|
24
25
|
export * from './graphics'
|
|
25
26
|
export * from './asset'
|
|
26
|
-
export * from './preset'
|
|
27
27
|
export * from './Engine'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnimationUnit, Descriptor } from '../descriptor';
|
|
2
2
|
import { ArrayUtils } from '../ArrayUtils';
|
|
3
3
|
import { Interpreter } from './Interpreter'
|
|
4
4
|
import { AnimationUnitActor } from "../actor";
|
|
@@ -7,8 +7,8 @@ const privateState = {
|
|
|
7
7
|
collection: [] as AnimationUnitActor[],
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
class AnimationUnitInterpreter extends Interpreter {
|
|
11
|
-
static type =
|
|
10
|
+
export class AnimationUnitInterpreter extends Interpreter {
|
|
11
|
+
static type = AnimationUnit.type
|
|
12
12
|
static enabled = true
|
|
13
13
|
static reset(time = 0) {
|
|
14
14
|
const enabled = AnimationUnitInterpreter.enabled
|
|
@@ -29,12 +29,12 @@ class AnimationUnitInterpreter extends Interpreter {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
update(descriptor:
|
|
32
|
+
update(descriptor: AnimationUnit) {
|
|
33
33
|
super.update(descriptor)
|
|
34
34
|
|
|
35
35
|
this.freeUnit()
|
|
36
36
|
|
|
37
|
-
const parentDescriptor =
|
|
37
|
+
const parentDescriptor = AnimationUnit.get<AnimationUnit>(this.unit.parent)
|
|
38
38
|
if (parentDescriptor === null) return
|
|
39
39
|
|
|
40
40
|
this.animationUnit = AnimationUnitActor.parse(descriptor)
|
|
@@ -43,11 +43,9 @@ class AnimationUnitInterpreter extends Interpreter {
|
|
|
43
43
|
this.animationUnit.listen(this.graphics)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
unmount(descriptor:
|
|
46
|
+
unmount(descriptor: AnimationUnit, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
|
|
47
47
|
this.freeUnit()
|
|
48
48
|
super.unmount(descriptor, parentInterpreter, parentDescriptor)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
Interpreter.register(AnimationUnitInterpreter)
|
|
52
|
-
|
|
53
|
-
export { AnimationUnitInterpreter }
|
|
51
|
+
Interpreter.register(AnimationUnitInterpreter)
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Descriptor,
|
|
1
|
+
import { Descriptor, Div } from "../descriptor"
|
|
2
2
|
import { Interpreter } from "./Interpreter"
|
|
3
3
|
import { DivActor, HTMLActor } from "../actor"
|
|
4
4
|
import { PickupObject } from "../graphics"
|
|
5
5
|
|
|
6
|
-
class DivInterpreter extends Interpreter {
|
|
7
|
-
static type =
|
|
6
|
+
export class DivInterpreter extends Interpreter {
|
|
7
|
+
static type = Div.type
|
|
8
8
|
|
|
9
|
-
protected createActor(descriptor:
|
|
9
|
+
protected createActor(descriptor: Div) {
|
|
10
10
|
return new DivActor(descriptor.uuid)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
update(descriptor:
|
|
13
|
+
update(descriptor: Div) {
|
|
14
14
|
super.update(descriptor)
|
|
15
15
|
const actor = this.getActor<DivActor>(descriptor)
|
|
16
16
|
actor.update(descriptor)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
mount(descriptor:
|
|
19
|
+
mount(descriptor: Div, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
|
|
20
20
|
super.mount(descriptor, parentInterpreter, parentDescriptor)
|
|
21
21
|
const actor = this.getActor<DivActor>(descriptor)
|
|
22
22
|
|
|
@@ -24,9 +24,8 @@ class DivInterpreter extends Interpreter {
|
|
|
24
24
|
parenActor.add(actor)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
unmount(descriptor:
|
|
27
|
+
unmount(descriptor: Div, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
|
|
28
28
|
const actor = this.getActor<DivActor>(descriptor)
|
|
29
|
-
actor.clearStyleClass(actor.DOM)
|
|
30
29
|
actor.cleanInteraction()
|
|
31
30
|
|
|
32
31
|
const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
|
|
@@ -35,10 +34,8 @@ class DivInterpreter extends Interpreter {
|
|
|
35
34
|
super.unmount(descriptor, parentInterpreter, parentDescriptor)
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
pickup(descriptor:
|
|
39
|
-
result.push({ uuid: descriptor.uuid
|
|
37
|
+
pickup(descriptor: Div, result: PickupObject[]) {
|
|
38
|
+
result.push({ uuid: descriptor.uuid })
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
Interpreter.register(DivInterpreter)
|
|
43
|
-
|
|
44
|
-
export { DivInterpreter }
|
|
41
|
+
Interpreter.register(DivInterpreter)
|
|
@@ -2,7 +2,7 @@ import { FragmentActor } from "../actor";
|
|
|
2
2
|
import { Descriptor } from "../descriptor";
|
|
3
3
|
import { Interpreter } from "./Interpreter";
|
|
4
4
|
|
|
5
|
-
class FragmentInterpreter extends Interpreter {
|
|
5
|
+
export class FragmentInterpreter extends Interpreter {
|
|
6
6
|
static type = Descriptor.type
|
|
7
7
|
|
|
8
8
|
protected createActor(descriptor: Descriptor) {
|
|
@@ -27,8 +27,4 @@ class FragmentInterpreter extends Interpreter {
|
|
|
27
27
|
super.free(descriptor)
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
Interpreter.register(FragmentInterpreter)
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
FragmentInterpreter
|
|
34
|
-
}
|
|
30
|
+
Interpreter.register(FragmentInterpreter)
|