@vyr/engine 0.0.33 → 0.0.35

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.
Files changed (137) hide show
  1. package/package.json +6 -3
  2. package/src/ArrayUtils.ts +63 -65
  3. package/src/AsyncTask.ts +67 -71
  4. package/src/Category.ts +69 -86
  5. package/src/Color.ts +3 -111
  6. package/src/Engine.ts +12 -24
  7. package/src/Executor.ts +109 -0
  8. package/src/Generate.ts +23 -40
  9. package/src/InputSystem.ts +106 -108
  10. package/src/Listener.ts +58 -59
  11. package/src/ObjectPool.ts +83 -84
  12. package/src/ObjectUtils.ts +97 -49
  13. package/src/Scriptable.ts +82 -0
  14. package/src/Serialization.ts +4 -6
  15. package/src/Traverser.ts +41 -39
  16. package/src/actor/Actor.ts +23 -27
  17. package/src/actor/AnimationUnitActor.ts +22 -36
  18. package/src/actor/DivActor.ts +21 -41
  19. package/src/actor/FragmentActor.ts +1 -5
  20. package/src/actor/HTMLActor.ts +81 -0
  21. package/src/actor/HTMLServiceActor.ts +49 -0
  22. package/src/actor/{HTMTransformControllerActor.ts → HTMLTransformControllerActor.ts} +178 -71
  23. package/src/actor/InputActor.ts +50 -0
  24. package/src/actor/TextActor.ts +51 -0
  25. package/src/actor/index.ts +6 -5
  26. package/src/asset/Asset.ts +23 -68
  27. package/src/asset/AssetGraph.ts +21 -28
  28. package/src/descriptor/AnimationUnit.ts +81 -0
  29. package/src/descriptor/Camera.ts +12 -0
  30. package/src/descriptor/Controller.ts +6 -0
  31. package/src/descriptor/Descriptor.ts +133 -113
  32. package/src/descriptor/Div.ts +29 -0
  33. package/src/descriptor/HTML.ts +22 -0
  34. package/src/descriptor/HTMLService.ts +42 -0
  35. package/src/descriptor/HTMLTransformController.ts +67 -0
  36. package/src/descriptor/Input.ts +29 -0
  37. package/src/descriptor/Interaction.ts +80 -0
  38. package/src/descriptor/Node.ts +98 -0
  39. package/src/descriptor/Scene.ts +110 -0
  40. package/src/descriptor/Service.ts +11 -0
  41. package/src/descriptor/Store.ts +136 -0
  42. package/src/descriptor/Text.ts +36 -0
  43. package/src/descriptor/index.ts +14 -15
  44. package/src/graphics/Collection.ts +1 -5
  45. package/src/graphics/Compilation.ts +15 -19
  46. package/src/graphics/Graphics.ts +41 -54
  47. package/src/graphics/Observer.ts +6 -14
  48. package/src/graphics/Unit.ts +3 -9
  49. package/src/graphics/VariableProxy.ts +11 -15
  50. package/src/index.ts +5 -5
  51. package/src/interpreter/AnimationUnitInterpreter.ts +7 -9
  52. package/src/interpreter/DivInterpreter.ts +10 -13
  53. package/src/interpreter/FragmentInterpreter.ts +2 -6
  54. package/src/interpreter/HTMLServiceInterpreter.ts +25 -15
  55. package/src/interpreter/HTMLTransformControllerInterpreter.ts +9 -12
  56. package/src/interpreter/InputInterpreter.ts +41 -0
  57. package/src/interpreter/Interpreter.ts +3 -4
  58. package/src/interpreter/SceneInterpreter.ts +93 -0
  59. package/src/interpreter/ServiceInterpreter.ts +8 -15
  60. package/src/interpreter/StoreInterpreter.ts +7 -0
  61. package/src/interpreter/TextInterpreter.ts +41 -0
  62. package/src/interpreter/index.ts +5 -7
  63. package/src/locale/Language.ts +1 -5
  64. package/src/locale/LanguageProvider.ts +164 -21
  65. package/src/math/Euler.ts +2 -5
  66. package/src/math/Matrix4.ts +2 -4
  67. package/src/math/Quaternion.ts +2 -4
  68. package/src/math/Vector2.ts +4 -4
  69. package/src/math/Vector3.ts +2 -4
  70. package/src/math/utils.ts +1 -5
  71. package/src/schema/AnimationUnit.ts +68 -0
  72. package/src/schema/Asset.ts +13 -0
  73. package/src/schema/Descriptor.ts +41 -0
  74. package/src/schema/HTML.ts +261 -0
  75. package/src/schema/Interaction.ts +50 -0
  76. package/src/schema/Scene.ts +138 -0
  77. package/src/schema/Store.ts +8 -0
  78. package/src/schema/index.ts +7 -0
  79. package/src/scripts/ConditionScriptable.ts +196 -0
  80. package/src/scripts/FetchScriptable.ts +51 -0
  81. package/src/scripts/FindScriptable.ts +23 -0
  82. package/src/scripts/InvokeScriptable.ts +13 -0
  83. package/src/scripts/SwitchSceneScriptable.ts +18 -0
  84. package/src/scripts/UpdateScriptable.ts +60 -0
  85. package/src/scripts/index.ts +6 -0
  86. package/src/utils/AssetProvider.ts +4 -77
  87. package/src/utils/DOM.ts +37 -0
  88. package/src/utils/HTML.ts +5 -0
  89. package/src/utils/Service.ts +40 -0
  90. package/src/utils/constants.ts +1 -5
  91. package/src/utils/http.ts +2 -21
  92. package/src/utils/index.ts +3 -1
  93. package/src/actor/HTMActor.ts +0 -169
  94. package/src/actor/HTMServiceActor.ts +0 -57
  95. package/src/actor/StyleActor.ts +0 -96
  96. package/src/descriptor/AnimationUnitDescriptor.ts +0 -65
  97. package/src/descriptor/CameraDescriptor.ts +0 -12
  98. package/src/descriptor/ControllerDescriptor.ts +0 -16
  99. package/src/descriptor/DatasetDescriptor.ts +0 -90
  100. package/src/descriptor/DivDescriptor.ts +0 -18
  101. package/src/descriptor/DynamicDescriptor.ts +0 -27
  102. package/src/descriptor/HTMLDescriptor.ts +0 -87
  103. package/src/descriptor/HTMLServiceDescriptor.ts +0 -19
  104. package/src/descriptor/HTMLTransformControllerDescriptor.ts +0 -34
  105. package/src/descriptor/NodeDescriptor.ts +0 -32
  106. package/src/descriptor/PrefabDescriptor.ts +0 -53
  107. package/src/descriptor/PrefabInstanceDescriptor.ts +0 -32
  108. package/src/descriptor/ServiceDescriptor.ts +0 -32
  109. package/src/descriptor/ServiceSchedulerDescriptor.ts +0 -32
  110. package/src/descriptor/StyleDescriptor.ts +0 -213
  111. package/src/interaction/InteractionDescriptor.ts +0 -96
  112. package/src/interaction/InteractionExecutor.ts +0 -84
  113. package/src/interaction/Scriptable.ts +0 -44
  114. package/src/interaction/index.ts +0 -3
  115. package/src/interpreter/DatasetInterpreter.ts +0 -11
  116. package/src/interpreter/DynamicInterpreter.ts +0 -207
  117. package/src/interpreter/PrefaInterpreter.ts +0 -11
  118. package/src/interpreter/PrefabInstanceInterpreter.ts +0 -12
  119. package/src/interpreter/ServiceSchedulerInterpreter.ts +0 -42
  120. package/src/interpreter/StyleInterpreter.ts +0 -66
  121. package/src/preset/execute/dataset/index.ts +0 -1
  122. package/src/preset/execute/dataset/update.ts +0 -51
  123. package/src/preset/execute/graphics/index.ts +0 -1
  124. package/src/preset/execute/graphics/invoke.ts +0 -48
  125. package/src/preset/execute/index.ts +0 -4
  126. package/src/preset/execute/net/http.ts +0 -52
  127. package/src/preset/execute/net/index.ts +0 -1
  128. package/src/preset/execute/scheduler/index.ts +0 -1
  129. package/src/preset/execute/scheduler/switch.ts +0 -46
  130. package/src/preset/index.ts +0 -7
  131. package/src/preset/interaction/graphics/index.ts +0 -1
  132. package/src/preset/interaction/graphics/invoke.ts +0 -27
  133. package/src/preset/interaction/index.ts +0 -2
  134. package/src/preset/interaction/scheduler/index.ts +0 -1
  135. package/src/preset/interaction/scheduler/switch.ts +0 -27
  136. package/src/setup/index.ts +0 -17
  137. package/src/utils/compile.ts +0 -50
@@ -1,25 +1,26 @@
1
- import { Descriptor, HTMLServiceDescriptor } from "../descriptor"
2
- import { Interpreter, ServiceInterpreter } from "."
1
+ import { Descriptor, HTMLService, Service } from "../descriptor"
2
+ import { Interpreter, ServiceInterpreter } from "./index"
3
3
  import { HTMLActor, HTMLServiceActor } from "../actor"
4
4
  import { PickupObject } from "../graphics"
5
5
 
6
- class HTMLServiceInterpreter extends ServiceInterpreter {
7
- static type = HTMLServiceDescriptor.type
6
+ export class HTMLServiceInterpreter extends Interpreter implements ServiceInterpreter {
7
+ static type = HTMLService.type
8
8
 
9
- protected createActor(descriptor: HTMLServiceDescriptor) {
9
+ protected createActor(descriptor: HTMLService) {
10
10
  const actor = new HTMLServiceActor(descriptor.uuid)
11
- actor.DOM.addEventListener('pointerdown', e => e.stopPropagation())
11
+ const DOM = actor.getDOM()
12
+ DOM.addEventListener('pointerdown', e => e.stopPropagation())
12
13
  return actor
13
14
  }
14
15
 
15
- update(descriptor: HTMLServiceDescriptor) {
16
+ update(descriptor: HTMLService) {
16
17
  super.update(descriptor)
17
18
 
18
19
  const actor = this.getActor<HTMLServiceActor>(descriptor)
19
20
  actor.update(descriptor)
20
21
  }
21
22
 
22
- mount(descriptor: HTMLServiceDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
23
+ mount(descriptor: HTMLService, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
23
24
  super.mount(descriptor, parentInterpreter, parentDescriptor)
24
25
  const actor = this.getActor<HTMLServiceActor>(descriptor)
25
26
 
@@ -27,9 +28,8 @@ class HTMLServiceInterpreter extends ServiceInterpreter {
27
28
  parenActor.add(actor)
28
29
  }
29
30
 
30
- unmount(descriptor: HTMLServiceDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
31
+ unmount(descriptor: HTMLService, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
31
32
  const actor = this.getActor<HTMLServiceActor>(descriptor)
32
- actor.clearStyleClass(actor.DOM)
33
33
  actor.cleanInteraction()
34
34
 
35
35
  const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
@@ -38,10 +38,20 @@ class HTMLServiceInterpreter extends ServiceInterpreter {
38
38
  super.unmount(descriptor, parentInterpreter, parentDescriptor)
39
39
  }
40
40
 
41
- pickup(descriptor: HTMLServiceDescriptor, result: PickupObject[]) {
42
- result.push({ uuid: descriptor.uuid, generatedBy: descriptor.generatedBy })
41
+ pickup(descriptor: HTMLService, result: PickupObject[]) {
42
+ result.push({ uuid: descriptor.uuid })
43
43
  }
44
- }
45
- ServiceInterpreter.register(HTMLServiceInterpreter)
46
44
 
47
- export { HTMLServiceInterpreter }
45
+ clear(service: Service) { }
46
+
47
+ beforeRender(service: Service) { }
48
+
49
+ render(service: Service) { }
50
+
51
+ afterRender(service: Service) { }
52
+
53
+ beforePickup(mouse: { x: number; y: number }, rect: DOMRect) { }
54
+
55
+ orderBy(result: PickupObject[]) { }
56
+ }
57
+ Interpreter.register(HTMLServiceInterpreter)
@@ -1,40 +1,37 @@
1
- import { Descriptor, HTMLTransformControllerDescriptor } from "../descriptor"
1
+ import { Descriptor, HTMLTransformController } from "../descriptor"
2
2
  import { HTMLTransformControllerActor } from "../actor"
3
3
  import { Interpreter } from "./Interpreter"
4
4
 
5
- class HTMLTransformControllerInterpreter extends Interpreter {
6
- static type = HTMLTransformControllerDescriptor.type
5
+ export class HTMLTransformControllerInterpreter extends Interpreter {
6
+ static type = HTMLTransformController.type
7
7
 
8
- protected createActor(descriptor: HTMLTransformControllerDescriptor) {
8
+ protected createActor(descriptor: HTMLTransformController) {
9
9
  const actor = new HTMLTransformControllerActor()
10
10
  return actor
11
11
  }
12
12
 
13
- update(descriptor: HTMLTransformControllerDescriptor) {
13
+ update(descriptor: HTMLTransformController) {
14
14
  super.update(descriptor)
15
15
  const actor = this.getActor<HTMLTransformControllerActor>(descriptor)
16
16
  actor.update(descriptor)
17
17
  }
18
18
 
19
- mount(descriptor: HTMLTransformControllerDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
19
+ mount(descriptor: HTMLTransformController, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
20
  super.mount(descriptor, parentInterpreter, parentDescriptor)
21
21
  this.getActor<HTMLTransformControllerActor>(descriptor)
22
22
  }
23
23
 
24
- unmount(descriptor: HTMLTransformControllerDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
24
+ unmount(descriptor: HTMLTransformController, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
25
25
  const actor = this.getActor<HTMLTransformControllerActor>(descriptor)
26
26
  actor.unlisten()
27
27
 
28
28
  super.unmount(descriptor, parentInterpreter, parentDescriptor)
29
29
  }
30
30
 
31
- free(descriptor: HTMLTransformControllerDescriptor) {
31
+ free(descriptor: HTMLTransformController) {
32
32
  const actor = this.getActor<HTMLTransformControllerActor>(descriptor)
33
33
  actor.dispose()
34
34
  super.free(descriptor)
35
35
  }
36
36
  }
37
- Interpreter.register(HTMLTransformControllerInterpreter)
38
-
39
-
40
- export { HTMLTransformControllerInterpreter }
37
+ Interpreter.register(HTMLTransformControllerInterpreter)
@@ -0,0 +1,41 @@
1
+ import { Descriptor, Input } from "../descriptor"
2
+ import { Interpreter } from "./Interpreter"
3
+ import { InputActor, HTMLActor } from "../actor"
4
+ import { PickupObject } from "../graphics"
5
+
6
+ export class InputInterpreter extends Interpreter {
7
+ static type = Input.type
8
+
9
+ protected createActor(descriptor: Input) {
10
+ return new InputActor(descriptor.uuid)
11
+ }
12
+
13
+ update(descriptor: Input) {
14
+ super.update(descriptor)
15
+ const actor = this.getActor<InputActor>(descriptor)
16
+ actor.update(descriptor)
17
+ }
18
+
19
+ mount(descriptor: Input, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
21
+ const actor = this.getActor<InputActor>(descriptor)
22
+
23
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
24
+ parenActor.add(actor)
25
+ }
26
+
27
+ unmount(descriptor: Input, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
28
+ const actor = this.getActor<InputActor>(descriptor)
29
+ actor.cleanInteraction()
30
+
31
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
32
+ parenActor.remove(actor)
33
+
34
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
35
+ }
36
+
37
+ pickup(descriptor: Input, result: PickupObject[]) {
38
+ result.push({ uuid: descriptor.uuid })
39
+ }
40
+ }
41
+ Interpreter.register(InputInterpreter)
@@ -3,7 +3,7 @@ import { Actor } from '../actor'
3
3
  import { Unit, PickupObject, Graphics } from "../graphics"
4
4
  import { Descriptor } from "../descriptor"
5
5
 
6
- const privateState = {
6
+ export const privateState = {
7
7
  factory: false,
8
8
  classCollection: new Map<string, typeof Interpreter>(),
9
9
  actorCollection: new Map<Interpreter, Actor>(),
@@ -14,7 +14,7 @@ const privateState = {
14
14
  *
15
15
  * 警告:解释器在实现时不能对自身的描述器直接进行引用,从而导致描述器始终存在引用而无法被垃圾回收机制回收。
16
16
  */
17
- class Interpreter {
17
+ export class Interpreter {
18
18
  static type = 'Interpreter'
19
19
  static register(DerivedClass: typeof Interpreter) {
20
20
  privateState.classCollection.set(DerivedClass.type, DerivedClass)
@@ -28,7 +28,7 @@ class Interpreter {
28
28
  readonly graphics
29
29
 
30
30
  constructor(unit: Unit, graphics: Graphics) {
31
- if (privateState.factory === false) throw new Error(language.get('interpreter.new.fail'))
31
+ if (privateState.factory === false) throw new Error(language.get('interpreter.new.failed'))
32
32
  this.unit = unit
33
33
  this.graphics = graphics
34
34
  }
@@ -66,4 +66,3 @@ class Interpreter {
66
66
  pickup(descriptor: Descriptor, result: PickupObject[]) { }
67
67
  }
68
68
 
69
- export { Interpreter, privateState }
@@ -0,0 +1,93 @@
1
+ import decamelizeKeys from 'decamelize-keys'
2
+ import { Descriptor, Scene } from "../descriptor"
3
+ import { Interpreter } from "./Interpreter"
4
+ import { DivActor } from "../actor"
5
+
6
+ export class SceneInterpreter extends Interpreter {
7
+ static type = Scene.type
8
+ readonly style = document.createElement('style')
9
+
10
+ protected createActor(descriptor: Descriptor) {
11
+ const actor = new DivActor(descriptor.uuid)
12
+ return actor
13
+ }
14
+
15
+ private resize = () => { }
16
+ private unresize = () => { }
17
+
18
+ /**
19
+ * 生成CSS规则
20
+ * @param style Style描述符
21
+ * @returns 生成的CSS规则字符串
22
+ */
23
+ generateCSSRules(descriptor: Scene): string {
24
+ let css = Scene.useGlobalStyle()
25
+
26
+ // 生成基础样式和状态样式
27
+ if (descriptor?.sharedCSSStyle?.classNames) {
28
+ // 遍历每个类名
29
+ for (const [className, states] of Object.entries(descriptor.sharedCSSStyle.classNames)) {
30
+ css += `${className} {\n`
31
+ css += this.generateCSSProperties(states)
32
+ css += `}\n\n`
33
+ }
34
+ }
35
+
36
+ // 生成动画
37
+ if (descriptor?.sharedCSSStyle?.animations) {
38
+ for (const [animationName, animation] of Object.entries(descriptor.sharedCSSStyle.animations)) {
39
+ css += `@keyframes ${animationName} {\n`
40
+ const keys = Object.keys(animation)
41
+ for (const keyframe of keys) {
42
+ css += ` ${keyframe} {\n`
43
+ css += this.generateCSSProperties(animation[keyframe])
44
+ css += ` }\n`
45
+ }
46
+ css += `}\n\n`
47
+ }
48
+ }
49
+
50
+ return css
51
+ }
52
+
53
+ /**
54
+ * 生成CSS属性字符串
55
+ * @param properties CSS属性对象
56
+ * @returns 生成的CSS属性字符串
57
+ */
58
+ generateCSSProperties(properties: Record<string, string>): string {
59
+ let css = ''
60
+ for (const [property, value] of Object.entries(decamelizeKeys(properties, { separator: '-' }))) {
61
+ css += ` ${(property)}: ${value};\n`
62
+ }
63
+ return css
64
+ }
65
+
66
+ install(descriptor: Scene) {
67
+ const actor = this.getActor<DivActor>(descriptor)
68
+ const DOM = actor.getDOM()
69
+ this.graphics.engine.DOM.appendChild(DOM)
70
+ document.head.appendChild(this.style)
71
+
72
+ this.resize = () => {
73
+ DOM.style.width = this.graphics.engine.DOM.clientWidth + 'px'
74
+ DOM.style.height = this.graphics.engine.DOM.clientHeight + 'px'
75
+ }
76
+ const uuid = this.graphics.engine.inputSystem.listen('resize', this.resize, { target: window })
77
+ this.unresize = () => this.graphics.engine.inputSystem.unlisten(uuid)
78
+ this.resize()
79
+ }
80
+
81
+ uninstall(descriptor: Scene) {
82
+ this.unresize()
83
+ const actor = this.getActor<DivActor>(descriptor)
84
+ const DOM = actor.getDOM()
85
+ DOM.remove()
86
+ this.style.remove()
87
+ }
88
+
89
+ update(descriptor: Scene) {
90
+ this.style.innerHTML = this.generateCSSRules(descriptor)
91
+ }
92
+ }
93
+ Interpreter.register(SceneInterpreter)
@@ -1,24 +1,17 @@
1
- import { ServiceDescriptor } from "../descriptor";
1
+ import { Service } from "../descriptor";
2
2
  import { PickupObject } from "../graphics";
3
3
  import { Interpreter } from "./Interpreter";
4
4
 
5
- class ServiceInterpreter extends Interpreter {
6
- static type = ServiceDescriptor.type
5
+ export interface ServiceInterpreter extends Interpreter {
6
+ clear(service: Service): void
7
7
 
8
- clear(service: ServiceDescriptor) { }
8
+ beforeRender(service: Service): void
9
9
 
10
- beforeRender(service: ServiceDescriptor) { }
10
+ render(service: Service): void
11
11
 
12
- render(service: ServiceDescriptor) { }
12
+ afterRender(service: Service): void
13
13
 
14
- afterRender(service: ServiceDescriptor) { }
14
+ beforePickup(mouse: { x: number; y: number }, rect: DOMRect): void
15
15
 
16
- beforePickup(mouse: { x: number; y: number }, rect: DOMRect) { }
17
-
18
- orderBy(result: PickupObject[]) { }
19
- }
20
- Interpreter.register(ServiceInterpreter)
21
-
22
- export {
23
- ServiceInterpreter
16
+ orderBy(result: PickupObject[]): void
24
17
  }
@@ -0,0 +1,7 @@
1
+ import { Store } from "../descriptor";
2
+ import { Interpreter } from "./Interpreter";
3
+
4
+ export class StoreInterpreter extends Interpreter {
5
+ static type = Store.type
6
+ }
7
+ Interpreter.register(StoreInterpreter)
@@ -0,0 +1,41 @@
1
+ import { Descriptor, Text } from "../descriptor"
2
+ import { Interpreter } from "./Interpreter"
3
+ import { TextActor, HTMLActor } from "../actor"
4
+ import { PickupObject } from "../graphics"
5
+
6
+ export class TextInterpreter extends Interpreter {
7
+ static type = Text.type
8
+
9
+ protected createActor(descriptor: Text) {
10
+ return new TextActor(descriptor.uuid)
11
+ }
12
+
13
+ update(descriptor: Text) {
14
+ super.update(descriptor)
15
+ const actor = this.getActor<TextActor>(descriptor)
16
+ actor.update(descriptor)
17
+ }
18
+
19
+ mount(descriptor: Text, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
21
+ const actor = this.getActor<TextActor>(descriptor)
22
+
23
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
24
+ parenActor.add(actor)
25
+ }
26
+
27
+ unmount(descriptor: Text, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
28
+ const actor = this.getActor<TextActor>(descriptor)
29
+ actor.cleanInteraction()
30
+
31
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
32
+ parenActor.remove(actor)
33
+
34
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
35
+ }
36
+
37
+ pickup(descriptor: Text, result: PickupObject[]) {
38
+ result.push({ uuid: descriptor.uuid })
39
+ }
40
+ }
41
+ Interpreter.register(TextInterpreter)
@@ -1,13 +1,11 @@
1
1
  export { Interpreter } from './Interpreter'
2
- export * from './DatasetInterpreter'
3
- export * from './StyleInterpreter'
4
- export * from './AnimationUnitInterpreter'
2
+ export * from './StoreInterpreter'
5
3
  export * from './FragmentInterpreter'
6
- export * from './DynamicInterpreter'
7
- export * from './PrefaInterpreter'
8
- export * from './PrefabInstanceInterpreter'
4
+ export * from './AnimationUnitInterpreter'
9
5
  export * from "./DivInterpreter";
6
+ export * from './InputInterpreter'
7
+ export * from './TextInterpreter'
10
8
  export * from "./HTMLTransformControllerInterpreter";
11
9
  export * from './ServiceInterpreter'
12
10
  export * from "./HTMLServiceInterpreter";
13
- export * from './ServiceSchedulerInterpreter'
11
+ export * from './SceneInterpreter'
@@ -3,8 +3,4 @@ import { zhCnLanguageProvider, ZhCNLanguageProvider } from "./LanguageProvider";
3
3
 
4
4
  Locale.register(zhCnLanguageProvider)
5
5
 
6
- const language = Locale.getLanguage<ZhCNLanguageProvider>(zhCnLanguageProvider.name)
7
-
8
- export {
9
- language
10
- }
6
+ export const language = Locale.getLanguage<ZhCNLanguageProvider>(zhCnLanguageProvider.name)
@@ -1,50 +1,193 @@
1
1
  import { LanguageProvider } from '@vyr/locale'
2
2
 
3
- interface ZhCNLanguageProvider extends LanguageProvider {
3
+ export interface ZhCNLanguageProvider extends LanguageProvider {
4
4
  'asyncTask.task.was.cancelled': string
5
- 'asset.load.fail': string
5
+ 'asset.load.failed': string
6
6
  'asset.already.exists': string
7
7
  'asset.provider.notFound': string
8
8
  'descriptor.notRegister': string
9
9
  'descriptor.insert.uuid.notFound': string
10
10
  'descriptor.insert.target.notFound': string
11
- 'descriptor.syncWith.fail': string
12
- 'interpreter.new.fail': string
11
+ 'descriptor.syncWith.failed': string
12
+ 'descriptor.variables.config.value': string
13
+ 'interpreter.new.failed': string
13
14
  'graphics.interpreter.notRegister': string
14
15
  'graphics.unit.notFound': string
15
16
  'engine.run.container.notFound': string
16
17
  'engine.switch.url.notFound': string
17
-
18
- '/virtual:/preset/net/http.ts': string
19
- '/virtual:/preset/dataset/update.ts': string
20
- '/virtual:/preset/scheduler/switch.ts': string
21
- '/virtual:/preset/graphics/invoke.ts': string
18
+ 'scriptable.fetch.name': string
19
+ 'scriptable.fetch.input.url': string
20
+ 'scriptable.fetch.input.type': string
21
+ 'scriptable.fetch.input.nodeIds': string
22
+ 'scriptable.fetch.input.type.interface': string
23
+ 'scriptable.fetch.input.interfaceId': string
24
+ 'scriptable.fetch.input.requestData': string
25
+ 'scriptable.find.name': string
26
+ 'scriptable.find.input.target': string
27
+ 'scriptable.find.output.descriptor': string
28
+ 'scriptable.invoke.name': string
29
+ 'scriptable.invoke.input.target': string
30
+ 'scriptable.invoke.input.interactionType': string
31
+ 'scriptable.update.name': string
32
+ 'scriptable.update.input.target': string
33
+ 'scriptable.update.input.propertyPath': string
34
+ 'scriptable.update.input.data': string
35
+ 'scriptable.update.input.nodeId': string
36
+ 'scriptable.switchScene.name': string
37
+ 'scriptable.switchScene.input.scene': string
38
+ 'scriptable.condition.name': string
39
+ 'scriptable.condition.input.nodeId': string
40
+ 'scriptable.condition.input.rules': string
41
+ 'scriptable.condition.output.success': string
42
+ 'scriptable.condition.operator.value': string
43
+ 'scriptable.condition.operator.value2': string
44
+ 'scriptable.condition.logic.rules': string
45
+ 'scriptable.condition.rule.type': string
46
+ 'scriptable.condition.rule.field': string
47
+ 'scriptable.condition.rule.compare': string
48
+ 'scriptable.condition.rule.logic': string
49
+ 'scriptable.condition.operator.description': string
50
+ 'scriptable.condition.operator.equal': string
51
+ 'scriptable.condition.operator.notEqual': string
52
+ 'scriptable.condition.operator.greater': string
53
+ 'scriptable.condition.operator.greaterEqual': string
54
+ 'scriptable.condition.operator.less': string
55
+ 'scriptable.condition.operator.lessEqual': string
56
+ 'scriptable.condition.operator.strictEqual': string
57
+ 'scriptable.condition.operator.strictNotEqual': string
58
+ 'scriptable.condition.operator.in': string
59
+ 'scriptable.condition.operator.notIn': string
60
+ 'scriptable.condition.operator.between': string
61
+ 'scriptable.condition.operator.notBetween': string
62
+ 'scriptable.condition.operator.contains': string
63
+ 'scriptable.condition.operator.startsWith': string
64
+ 'scriptable.condition.operator.endsWith': string
65
+ 'scriptable.condition.operator.matches': string
66
+ 'scriptable.condition.logic.description': string
67
+ 'scriptable.condition.logic.and': string
68
+ 'scriptable.condition.logic.or': string
69
+ 'scriptable.condition.logic.not': string
70
+ 'scriptable.condition.logic.xor': string
71
+ 'scriptable.condition.logic.nand': string
72
+ 'scriptable.condition.logic.nor': string
73
+ 'scene.cssPropertyName.invalid': string
74
+ 'scene.cssPropertyValue.empty': string
75
+ 'scene.cssPropertyValue.unsafe': string
76
+ 'scene.cssPropertyObject.empty': string
77
+ 'scene.cssSelector.invalid': string
78
+ 'scene.cssSelector.empty': string
79
+ 'scene.keyframe.invalid': string
80
+ 'scene.animation.missingStartEnd': string
81
+ 'scene.animation.name.invalid': string
22
82
  }
23
83
 
24
- const zhCnLanguageProvider: ZhCNLanguageProvider = {
84
+ export const zhCnLanguageProvider: ZhCNLanguageProvider = {
25
85
  id: 'zh_CN',
26
86
  name: '@vyr/engine',
27
87
  'asyncTask.task.was.cancelled': '任务已取消',
28
- 'asset.load.fail': '资产加载失败:未注册 {{category}} 类别的工厂方法',
88
+ 'asset.load.failed': '资产加载失败:未注册 {{category}} 类别的工厂方法',
29
89
  'asset.already.exists': '已存在同名资产,覆盖可能导致异常',
30
90
  'asset.provider.notFound': '未找到资源提供方:{{url}}',
31
91
  'descriptor.notRegister': '未注册描述器:{{type}}',
32
92
  'descriptor.insert.uuid.notFound': '节点不存在:${uuid}',
33
93
  'descriptor.insert.target.notFound': '目标节点不存在:${target}',
34
- 'descriptor.syncWith.fail': '只能从同类型实例同步属性',
35
- 'interpreter.new.fail': '请使用静态 create 方法创建实例',
94
+ 'descriptor.syncWith.failed': '只能从同类型实例同步属性',
95
+ 'descriptor.variables.config.value': '必须是合法的路径字符串,例如:a.b.c a.b[0].c,或者为空字符串',
96
+ 'interpreter.new.failed': '请使用静态 create 方法创建实例',
36
97
  'graphics.interpreter.notRegister': '未注册解释器:{{type}}',
37
98
  'graphics.unit.notFound': '单元不存在:{{uuid}}',
38
99
  'engine.run.container.notFound': '挂载节点不存在',
39
100
  'engine.switch.url.notFound': '切换失败,无法获资产地址!',
40
101
 
41
- '/virtual:/preset/net/http.ts': '网络请求',
42
- '/virtual:/preset/dataset/update.ts': '更新数据集',
43
- '/virtual:/preset/scheduler/switch.ts': '切换场景',
44
- '/virtual:/preset/graphics/invoke.ts': '调用交互',
45
- }
102
+ 'scriptable.fetch.name': '发送HTTP请求',
103
+ 'scriptable.fetch.input.url': '请求地址',
104
+ 'scriptable.fetch.input.type': '请求类型',
105
+ 'scriptable.fetch.input.requestData': '请求参数,结构需与接口一致',
106
+ 'scriptable.fetch.input.nodeIds': '交互节点ID(逗号分隔),按序合并节点输出至requestData',
107
+ 'scriptable.fetch.input.type.interface': '接口类型,使用系统预置接口',
108
+ 'scriptable.fetch.input.interfaceId': '接口ID',
109
+
110
+ 'scriptable.find.name': '获取目标描述器',
111
+ 'scriptable.find.input.target': '描述器UUID',
112
+ 'scriptable.find.output.descriptor': '目标描述器',
113
+
114
+ 'scriptable.invoke.name': '触发指定交互',
115
+ 'scriptable.invoke.input.target': '需要触发交互的目标UUID',
116
+ 'scriptable.invoke.input.interactionType': '需要触发的交互类型',
117
+
118
+ 'scriptable.update.name': '更新目标描述器',
119
+ 'scriptable.update.input.target': '目标描述器UUID',
120
+ 'scriptable.update.input.propertyPath': '待更新的属性路径,为空则更新整个目标',
121
+ 'scriptable.update.input.data': '更新数据,结构需与目标属性一致',
122
+ 'scriptable.update.input.nodeId': '交互节点ID,若设置则优先使用节点输出更新目标',
123
+
124
+ 'scriptable.switchScene.name': '切换至指定场景',
125
+ 'scriptable.switchScene.input.scene': '场景URL',
46
126
 
47
- export {
48
- ZhCNLanguageProvider,
49
- zhCnLanguageProvider,
127
+ 'scriptable.condition.name': '检查是否满足条件',
128
+ 'scriptable.condition.input.nodeId': '交互节点ID',
129
+ 'scriptable.condition.input.rules': '输出需要满足的规则集合',
130
+ 'scriptable.condition.output.success': '是否满足条件',
131
+ 'scriptable.condition.operator.value': '比较的参考值',
132
+ 'scriptable.condition.operator.value2': '第二个比较值,仅用于between/notBetween操作符',
133
+ 'scriptable.condition.logic.rules': '子规则列表',
134
+ 'scriptable.condition.rule.type': '期望的数据类型',
135
+ 'scriptable.condition.rule.field': '字段路径,支持点号访问嵌套属性,空表示验证整个数据',
136
+ 'scriptable.condition.rule.compare': '比较验证规则,通过操作符和目标值进行比较',
137
+ 'scriptable.condition.rule.logic': '逻辑组合验证规则,通过操作符组合多个子规则',
138
+ 'scriptable.condition.operator.description': '比较操作符:\n' +
139
+ '- = : 等于\n' +
140
+ '- != : 不等于\n' +
141
+ '- > : 大于\n' +
142
+ '- >= : 大于等于\n' +
143
+ '- < : 小于\n' +
144
+ '- <= : 小于等于\n' +
145
+ '- === : 严格等于(类型和值)\n' +
146
+ '- !== : 严格不等于\n' +
147
+ '- in : 值在数组中\n' +
148
+ '- notIn : 值不在数组中\n' +
149
+ '- between : 在范围内(包含边界),需要配合 value 和 value2 使用\n' +
150
+ '- notBetween : 不在范围内,需要配合 value 和 value2 使用\n' +
151
+ '- contains : 包含子串\n' +
152
+ '- startsWith : 以...开头\n' +
153
+ '- endsWith : 以...结尾\n' +
154
+ '- matches : 正则匹配',
155
+ 'scriptable.condition.operator.equal': '等于',
156
+ 'scriptable.condition.operator.notEqual': '不等于',
157
+ 'scriptable.condition.operator.greater': '大于',
158
+ 'scriptable.condition.operator.greaterEqual': '大于等于',
159
+ 'scriptable.condition.operator.less': '小于',
160
+ 'scriptable.condition.operator.lessEqual': '小于等于',
161
+ 'scriptable.condition.operator.strictEqual': '严格等于(类型和值)',
162
+ 'scriptable.condition.operator.strictNotEqual': '严格不等于',
163
+ 'scriptable.condition.operator.in': '值在数组中',
164
+ 'scriptable.condition.operator.notIn': '值不在数组中',
165
+ 'scriptable.condition.operator.between': '在范围内(包含边界)',
166
+ 'scriptable.condition.operator.notBetween': '不在范围内',
167
+ 'scriptable.condition.operator.contains': '包含子串',
168
+ 'scriptable.condition.operator.startsWith': '以...开头',
169
+ 'scriptable.condition.operator.endsWith': '以...结尾',
170
+ 'scriptable.condition.operator.matches': '正则匹配',
171
+ 'scriptable.condition.logic.description': '逻辑操作符:\n' +
172
+ '- AND : 所有规则必须为真\n' +
173
+ '- OR : 至少一个规则为真\n' +
174
+ '- NOT : 取反\n' +
175
+ '- XOR : 恰好一个规则为真\n' +
176
+ '- NAND : 不能同时为真\n' +
177
+ '- NOR : 全部为假',
178
+ 'scriptable.condition.logic.and': '所有规则必须为真',
179
+ 'scriptable.condition.logic.or': '至少一个规则为真',
180
+ 'scriptable.condition.logic.not': '取反',
181
+ 'scriptable.condition.logic.xor': '恰好一个规则为真',
182
+ 'scriptable.condition.logic.nand': '不能同时为真',
183
+ 'scriptable.condition.logic.nor': '全部为假',
184
+ 'scene.cssPropertyName.invalid': 'CSS属性名必须使用连字符格式,例如:"background-color", "font-size"',
185
+ 'scene.cssPropertyValue.empty': 'CSS属性值不能为空',
186
+ 'scene.cssPropertyValue.unsafe': 'CSS属性值包含不安全的字符',
187
+ 'scene.cssPropertyObject.empty': '样式对象不能为空',
188
+ 'scene.cssSelector.invalid': 'CSS选择器格式无效,支持类、ID、元素选择器、伪类和简单组合',
189
+ 'scene.cssSelector.empty': 'CSS选择器不能为空',
190
+ 'scene.keyframe.invalid': '关键帧必须为 "from", "to" 或 0%-100% 的百分比格式(如 "0%", "50%", "100%")',
191
+ 'scene.animation.missingStartEnd': '关键帧动画必须包含起始和结束状态(如 "0%" 和 "100%" 或 "from" 和 "to")',
192
+ 'scene.animation.name.invalid': '动画名称必须以字母开头,只能包含字母、数字、下划线和连字符',
50
193
  }
package/src/math/Euler.ts CHANGED
@@ -25,7 +25,7 @@ type EulerOrder = 'XYZ' | 'YXZ' | 'ZXY' | 'ZYX' | 'YZX' | 'XZY';
25
25
  * b.applyEuler(a);
26
26
  * ```
27
27
  */
28
- class Euler {
28
+ export class Euler {
29
29
  static create(euler?: number | DeserializationObject<Euler>, y?: number, z?: number, order?: EulerOrder) {
30
30
  if (euler === undefined) return new Euler()
31
31
 
@@ -39,7 +39,6 @@ class Euler {
39
39
  /**
40
40
  * The default Euler angle order.
41
41
  *
42
- * @static
43
42
  * @default 'XYZ'
44
43
  */
45
44
  static readonly DEFAULT_ORDER: EulerOrder = 'XYZ';
@@ -298,6 +297,4 @@ class Euler {
298
297
  yield this.z;
299
298
  yield this.order;
300
299
  }
301
- }
302
-
303
- export { Euler };
300
+ }
@@ -44,7 +44,7 @@ type CoordinateSystem = typeof WebGLCoordinateSystem | typeof WebGPUCoordinateSy
44
44
  * mind that if you are reading the source code, you'll have to take the
45
45
  * transpose of any matrices outlined here to make sense of the calculations.
46
46
  */
47
- class Matrix4 {
47
+ export class Matrix4 {
48
48
 
49
49
  /**
50
50
  * A column-major list of matrix values.
@@ -1118,6 +1118,4 @@ const _zero = /*@__PURE__*/ new Vector3(0, 0, 0);
1118
1118
  const _one = /*@__PURE__*/ new Vector3(1, 1, 1);
1119
1119
  const _x = /*@__PURE__*/ new Vector3();
1120
1120
  const _y = /*@__PURE__*/ new Vector3();
1121
- const _z = /*@__PURE__*/ new Vector3();
1122
-
1123
- export { Matrix4 };
1121
+ const _z = /*@__PURE__*/ new Vector3();