bg2e-js 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/bg2e-js.js +7031 -6989
  2. package/dist/bg2e-js.js.map +1 -1
  3. package/package.json +20 -2
  4. package/src/app/AppController.ts +39 -0
  5. package/src/app/Bg2KeyboardEvent.ts +54 -0
  6. package/src/app/Bg2MouseEvent.ts +82 -0
  7. package/src/app/Bg2TouchEvent.ts +18 -0
  8. package/src/app/Canvas.ts +108 -0
  9. package/src/app/EventBase.ts +10 -0
  10. package/src/app/MainLoop.ts +273 -0
  11. package/src/app/index.ts +25 -0
  12. package/src/base/Color.ts +134 -0
  13. package/src/base/Environment.ts +183 -0
  14. package/src/base/Light.ts +192 -0
  15. package/src/base/Material.ts +616 -0
  16. package/src/base/PolyList.ts +365 -0
  17. package/src/base/Texture.ts +620 -0
  18. package/src/base/index.ts +81 -0
  19. package/src/db/Bg2LoaderPlugin.ts +129 -0
  20. package/src/db/DBPluginApi.ts +48 -0
  21. package/src/db/Loader.ts +116 -0
  22. package/src/db/LoaderPlugin.ts +34 -0
  23. package/src/db/MtlParser.ts +7 -0
  24. package/src/db/ObjLoaderPlugin.ts +55 -0
  25. package/src/db/ObjParser.ts +252 -0
  26. package/src/db/ObjWriterPlugin.ts +19 -0
  27. package/src/db/VitscnjLoaderPlugin.ts +100 -0
  28. package/src/db/Writer.ts +52 -0
  29. package/src/db/WriterPlugin.ts +22 -0
  30. package/src/db/index.ts +44 -0
  31. package/src/debug/DebugRenderer.ts +173 -0
  32. package/src/debug/WebGLTextureViewer.ts +75 -0
  33. package/src/debug/index.ts +7 -0
  34. package/src/index.html +11 -0
  35. package/src/index.ts +33 -0
  36. package/src/manipulation/SelectionBuffer.ts +82 -0
  37. package/src/manipulation/SelectionHighlight.ts +85 -0
  38. package/src/manipulation/SelectionIdAssignVisitor.ts +97 -0
  39. package/src/manipulation/SelectionManager.ts +166 -0
  40. package/src/manipulation/SelectionMode.ts +6 -0
  41. package/src/math/Mat3.ts +259 -0
  42. package/src/math/Mat4.ts +706 -0
  43. package/src/math/MatrixStrategy.ts +25 -0
  44. package/src/math/Quat.ts +65 -0
  45. package/src/math/Vec.ts +753 -0
  46. package/src/math/constants.ts +47 -0
  47. package/src/math/functions.ts +103 -0
  48. package/src/math/index.ts +74 -0
  49. package/src/phsics/joint.ts +137 -0
  50. package/src/primitives/arrow.ts +58 -0
  51. package/src/primitives/cone.ts +138 -0
  52. package/src/primitives/cube.ts +60 -0
  53. package/src/primitives/cylinder.ts +216 -0
  54. package/src/primitives/index.ts +13 -0
  55. package/src/primitives/plane.ts +31 -0
  56. package/src/primitives/sphere.ts +809 -0
  57. package/src/render/BRDFIntegrationMap.ts +4 -0
  58. package/src/render/Environment.ts +136 -0
  59. package/src/render/FrameBuffer.ts +35 -0
  60. package/src/render/MaterialRenderer.ts +34 -0
  61. package/src/render/Pipeline.ts +109 -0
  62. package/src/render/PolyListRenderer.ts +47 -0
  63. package/src/render/RenderBuffer.ts +197 -0
  64. package/src/render/RenderQueue.ts +199 -0
  65. package/src/render/RenderState.ts +116 -0
  66. package/src/render/Renderer.ts +248 -0
  67. package/src/render/SceneAppController.ts +238 -0
  68. package/src/render/SceneRenderer.ts +373 -0
  69. package/src/render/Shader.ts +32 -0
  70. package/src/render/ShadowRenderer.ts +176 -0
  71. package/src/render/SkyCube.ts +106 -0
  72. package/src/render/SkySphere.ts +118 -0
  73. package/src/render/TextureMergerRenderer.ts +70 -0
  74. package/src/render/TextureRenderer.ts +34 -0
  75. package/src/render/index.ts +67 -0
  76. package/src/render/webgl/FrameBuffer.ts +10 -0
  77. package/src/render/webgl/MaterialRenderer.ts +113 -0
  78. package/src/render/webgl/Pipeline.ts +89 -0
  79. package/src/render/webgl/PolyListRenderer.ts +260 -0
  80. package/src/render/webgl/RenderBuffer.ts +227 -0
  81. package/src/render/webgl/Renderer.ts +262 -0
  82. package/src/render/webgl/SceneRenderer.ts +68 -0
  83. package/src/render/webgl/ShaderProgram.ts +424 -0
  84. package/src/render/webgl/ShadowRenderer.ts +6 -0
  85. package/src/render/webgl/SkyCube.ts +16 -0
  86. package/src/render/webgl/SkySphere.ts +16 -0
  87. package/src/render/webgl/State.ts +152 -0
  88. package/src/render/webgl/TextureRenderer.ts +167 -0
  89. package/src/render/webgl/VertexBuffer.ts +137 -0
  90. package/src/render/webgl/index.ts +35 -0
  91. package/src/scene/Camera.ts +458 -0
  92. package/src/scene/Chain.ts +44 -0
  93. package/src/scene/ChainJoint.ts +58 -0
  94. package/src/scene/Component.ts +173 -0
  95. package/src/scene/ComponentMap.ts +107 -0
  96. package/src/scene/Drawable.ts +154 -0
  97. package/src/scene/EnvironmentComponent.ts +142 -0
  98. package/src/scene/FindNodeVisitor.ts +60 -0
  99. package/src/scene/LightComponent.ts +155 -0
  100. package/src/scene/MatrixState.ts +46 -0
  101. package/src/scene/Node.ts +314 -0
  102. package/src/scene/NodeVisitor.ts +15 -0
  103. package/src/scene/OrbitCameraController.ts +450 -0
  104. package/src/scene/SmoothOrbitCameraController.ts +99 -0
  105. package/src/scene/Transform.ts +73 -0
  106. package/src/scene/index.ts +57 -0
  107. package/src/shaders/BasicDiffuseColorShader.ts +111 -0
  108. package/src/shaders/BasicPBRLightShader.ts +277 -0
  109. package/src/shaders/DebugRenderShader.ts +98 -0
  110. package/src/shaders/DepthRenderShader.ts +91 -0
  111. package/src/shaders/IrradianceMapCubeShader.ts +116 -0
  112. package/src/shaders/PBRLightIBLShader.ts +487 -0
  113. package/src/shaders/PickSelectionShader.ts +101 -0
  114. package/src/shaders/PresentDebugFramebufferShader.ts +118 -0
  115. package/src/shaders/PresentTextureShader.ts +99 -0
  116. package/src/shaders/SelectionHighlightShader.ts +127 -0
  117. package/src/shaders/ShaderFunction.ts +318 -0
  118. package/src/shaders/SkyCubeShader.ts +94 -0
  119. package/src/shaders/SkySphereShader.ts +102 -0
  120. package/src/shaders/SpecularMapCubeShader.ts +165 -0
  121. package/src/shaders/TextureMergerShader.ts +171 -0
  122. package/src/shaders/index.ts +37 -0
  123. package/src/shaders/webgl/color_correction.glsl +47 -0
  124. package/src/shaders/webgl/constants.glsl +6 -0
  125. package/src/shaders/webgl/index.ts +70 -0
  126. package/src/shaders/webgl/normal_map.glsl +9 -0
  127. package/src/shaders/webgl/pbr.glsl +173 -0
  128. package/src/shaders/webgl/uniforms.glsl +91 -0
  129. package/src/shaders/webgl_shader_lib.ts +213 -0
  130. package/src/tools/BinaryResourceProvider.ts +14 -0
  131. package/src/tools/ImageResourceProvider.ts +66 -0
  132. package/src/tools/MaterialModifier.ts +276 -0
  133. package/src/tools/Resource.ts +203 -0
  134. package/src/tools/ResourceProvider.ts +69 -0
  135. package/src/tools/TextResourceProvider.ts +24 -0
  136. package/src/tools/TextureCache.ts +52 -0
  137. package/src/tools/TextureResourceDatabase.ts +100 -0
  138. package/src/tools/UserAgent.ts +362 -0
  139. package/src/tools/VideoResourceProvider.ts +50 -0
  140. package/src/tools/WriteStrategy.ts +22 -0
  141. package/src/tools/base64.ts +11 -0
  142. package/src/tools/crypto.ts +19 -0
  143. package/src/tools/endiantess.ts +13 -0
  144. package/src/tools/image.ts +18 -0
  145. package/src/tools/index.ts +41 -0
  146. package/src/tools/processType.ts +38 -0
  147. package/src/vite-env.d.ts +12 -0
@@ -0,0 +1,155 @@
1
+ import Component from "./Component";
2
+ import Light, { LightType } from "../base/Light";
3
+ import FindNodeVisitor from "./FindNodeVisitor";
4
+ import Node from "./Node";
5
+
6
+
7
+ export default class LightComponent extends Component {
8
+ static GetLights(sceneRoot: Node): LightComponent[] {
9
+ if (sceneRoot.sceneChanged || !(sceneRoot as any).__lights) {
10
+ (sceneRoot as any).__lights = [];
11
+ let findLights = new FindNodeVisitor();
12
+ findLights.hasComponents(["Light"]);
13
+ sceneRoot.accept(findLights);
14
+ (sceneRoot as any).__lights = findLights.result.map(n => n.lightComponent);
15
+ }
16
+ return (sceneRoot as any).__lights;
17
+ }
18
+
19
+ static GetFirstShadowCastingLight(sceneRoot: Node): LightComponent | undefined {
20
+ if (sceneRoot.sceneChanged || !(sceneRoot as any).__mainDirectionalLight) {
21
+ (sceneRoot as any).__mainDirectionalLight = LightComponent.GetLights(sceneRoot)
22
+ .find(l => l.light.type === LightType.DIRECTIONAL || l.light.type === LightType.SPOT);
23
+ }
24
+ return (sceneRoot as any).__mainDirectionalLight;
25
+ }
26
+
27
+ static GetMainDirectionalLight(sceneRoot: Node): LightComponent | undefined {
28
+ if (sceneRoot.sceneChanged || !(sceneRoot as any).__mainDirectionalLight) {
29
+ (sceneRoot as any).__mainDirectionalLight = LightComponent.GetLights(sceneRoot)
30
+ .find(l => l.light.type === LightType.DIRECTIONAL);
31
+ }
32
+ return (sceneRoot as any).__mainDirectionalLight || LightComponent.GetFirstShadowCastingLight(sceneRoot);
33
+ }
34
+
35
+ _light: Light;
36
+
37
+ constructor(light: Light | null = null) {
38
+ super("Light");
39
+
40
+ this._light = light || new Light();
41
+ }
42
+
43
+ get light(): Light { return this._light; }
44
+ set light(l: Light) { this._light = l; }
45
+
46
+ set depthTexture(t: any) {
47
+ this._light.depthTexture = t;
48
+ }
49
+
50
+ get depthTexture(): any {
51
+ return this._light.depthTexture;
52
+ }
53
+
54
+ set viewMatrix(vm: any) {
55
+ this._light.viewMatrix = vm;
56
+ }
57
+
58
+ get viewMatrix(): any {
59
+ return this._light.viewMatrix;
60
+ }
61
+
62
+ clone(): LightComponent {
63
+ const result = new LightComponent();
64
+ result.assign(this);
65
+ return result;
66
+ }
67
+
68
+ assign(other: LightComponent): void {
69
+ this._light = other._light.clone();
70
+ }
71
+
72
+ setProperties({
73
+ enabled,
74
+ type,
75
+ lightType, // alias of type
76
+ direction,
77
+ position,
78
+ color,
79
+ spotCutoff,
80
+ spotExponent,
81
+ shadowStrength,
82
+ castShadows,
83
+ shadowBias,
84
+ intensity,
85
+ projection
86
+ }: {
87
+ enabled?: boolean;
88
+ type?: LightType;
89
+ lightType?: LightType;
90
+ direction?: any;
91
+ position?: any;
92
+ color?: any;
93
+ spotCutoff?: number;
94
+ spotExponent?: number;
95
+ shadowStrength?: number;
96
+ castShadows?: boolean;
97
+ shadowBias?: number;
98
+ intensity?: number;
99
+ projection?: any;
100
+ }): void {
101
+ if (enabled !== undefined) {
102
+ this.light.enabled = enabled;
103
+ }
104
+ if (type !== undefined) {
105
+ this.light.type = type;
106
+ }
107
+ if (lightType !== undefined) {
108
+ this.light.type = lightType;
109
+ }
110
+ if (direction !== undefined) {
111
+ this.light.direction = direction;
112
+ }
113
+ if (position !== undefined) {
114
+ this.light.position = position;
115
+ }
116
+ if (color !== undefined) {
117
+ this.light.color = color;
118
+ }
119
+ if (spotCutoff !== undefined) {
120
+ this.light.spotCutoff = spotCutoff;
121
+ }
122
+ if (spotExponent !== undefined) {
123
+ this.light.spotExponent = spotExponent;
124
+ }
125
+ if (shadowStrength !== undefined) {
126
+ this.light.shadowStrength = shadowStrength;
127
+ }
128
+ if (castShadows !== undefined) {
129
+ this.light.castShadows = castShadows;
130
+ }
131
+ if (shadowBias !== undefined) {
132
+ this.light.shadowBias = shadowBias;
133
+ }
134
+ if (intensity !== undefined) {
135
+ this.light.intensity = intensity;
136
+ }
137
+ if (projection !== undefined) {
138
+ this.light.projection = projection;
139
+ }
140
+ }
141
+
142
+ async deserialize(sceneData: any, loader: any): Promise<void> {
143
+ await this._light.deserialize(sceneData);
144
+ }
145
+
146
+ async serialize(sceneData: any, writer: any): Promise<void> {
147
+ await super.serialize(sceneData,writer);
148
+ await this._light.serialize(sceneData);
149
+ throw new Error("LightComponent.serialize() not implemented");
150
+ }
151
+
152
+ draw(renderQueue: any, modelMatrix: any): void {
153
+ renderQueue.addLight(this.light, modelMatrix);
154
+ }
155
+ }
@@ -0,0 +1,46 @@
1
+
2
+ import Mat4 from "../math/Mat4";
3
+
4
+ const pushMatrix = function(mat: Mat4, stack: Mat4[], id: string): void {
5
+ stack.push(new Mat4(mat));
6
+ }
7
+
8
+ const popMatrix = function(mat: Mat4, stack: Mat4[], id: string): void {
9
+ if (stack.length > 0) {
10
+ mat.assign(stack[stack.length - 1]);
11
+ stack.splice(stack.length - 1, 1);
12
+ }
13
+ else {
14
+ throw new Error(`Matrix stack underflow detected in ${id} matrix`);
15
+ }
16
+ }
17
+
18
+ export default class MatrixState {
19
+ private _projection: Mat4;
20
+ private _view: Mat4;
21
+ private _model: Mat4;
22
+ private _projMatrixStack: Mat4[];
23
+ private _viewMatrixStack: Mat4[];
24
+ private _modelMatrixStack: Mat4[];
25
+
26
+ constructor() {
27
+ this._projection = Mat4.MakeIdentity();
28
+ this._view = Mat4.MakeIdentity();
29
+ this._model = Mat4.MakeIdentity();
30
+
31
+ this._projMatrixStack = [];
32
+ this._viewMatrixStack = [];
33
+ this._modelMatrixStack = [];
34
+ }
35
+
36
+ get projection(): Mat4 { return this._projection; }
37
+ get view(): Mat4 { return this._view; }
38
+ get model(): Mat4 { return this._model; }
39
+
40
+ pushProjection(): void { pushMatrix(this._projection, this._projMatrixStack, 'projection'); }
41
+ popProjection(): void { popMatrix(this._projection, this._projMatrixStack, 'projection'); }
42
+ pushView(): void { pushMatrix(this._view, this._viewMatrixStack, 'view'); }
43
+ popView(): void { popMatrix(this._view, this._viewMatrixStack, 'view'); }
44
+ pushModel(): void { pushMatrix(this._model, this._modelMatrixStack, 'model'); }
45
+ popModel(): void { popMatrix(this._model, this._modelMatrixStack, 'model'); }
46
+ }
@@ -0,0 +1,314 @@
1
+ import Mat4 from '../math/Mat4';
2
+ import ComponentMap from './ComponentMap';
3
+ import Component from './Component';
4
+ import Renderer from '../render/Renderer';
5
+ import Camera from './Camera';
6
+ import Transform from './Transform';
7
+ import Drawable from './Drawable';
8
+ import LightComponent from './LightComponent';
9
+
10
+ export function bindRenderer(node: Node, renderer: Renderer): void {
11
+ (node as any)._bindedRenderer = renderer;
12
+ node.components.forEach(comp => {
13
+ comp.bindRenderer(renderer);
14
+ });
15
+ }
16
+
17
+ export async function init(node: Node): Promise<void> {
18
+ for (const i in node.components.array) {
19
+ const comp = node.components.array[i];
20
+ if (!(comp as any)._initialized) {
21
+ await comp.init();
22
+ (comp as any)._initialized = true;
23
+ }
24
+ }
25
+ (node as any)._sceneChanged = false;
26
+ }
27
+
28
+ export default class Node {
29
+ private _name: string;
30
+ private _enabled: boolean;
31
+ private _steady: boolean;
32
+ private _components: ComponentMap;
33
+ private _parent: Node | null;
34
+ private _children: Node[];
35
+ private _bindedRenderer?: Renderer;
36
+ private _sceneChanged: boolean = false;
37
+
38
+ constructor(name: string = "") {
39
+ this._name = name;
40
+ this._enabled = true;
41
+ this._steady = false;
42
+
43
+ this._components = new ComponentMap(this);
44
+
45
+ this._parent = null;
46
+ this._children = [];
47
+ }
48
+
49
+ get name(): string { return this._name; }
50
+ set name(n: string) { this._name = n; }
51
+
52
+ get enabled(): boolean { return this._enabled; }
53
+ set enabled(e: boolean) { this._enabled = e; }
54
+
55
+ get steady(): boolean { return this._steady; }
56
+ set steady(s: boolean) { this._steady = s; }
57
+
58
+ get components(): ComponentMap { return this._components; }
59
+
60
+ get parent(): Node | null { return this._parent; }
61
+ get children(): Node[] { return this._children; }
62
+
63
+ clone(cloneChildren: boolean = false): Node {
64
+ const newNode = new Node();
65
+ newNode.assign(this, cloneChildren);
66
+ return newNode;
67
+ }
68
+
69
+ assign(other: Node, cloneChildren: boolean = false): void {
70
+ this._name = other.name + "-copy";
71
+ this._enabled = other.enabled;
72
+ this._steady = other.steady;
73
+ this._components.assign(other._components);
74
+ if (cloneChildren) {
75
+ this._children = [];
76
+ other._children.forEach(c => {
77
+ this._children.push(c.clone(cloneChildren));
78
+ });
79
+ }
80
+ }
81
+
82
+ destroy(): void {
83
+ this._components.empty();
84
+ this.emptyChildren();
85
+ }
86
+
87
+ async deserialize(sceneData: any, loader: any): Promise<void> {
88
+ throw new Error("Node.deserialize() not implemented");
89
+ }
90
+
91
+ async serialize(sceneData: any, writer: any): Promise<void> {
92
+ throw new Error("Node.serialice() not implemented");
93
+ }
94
+
95
+ addComponent(component: Component): Component {
96
+ this.components.add(component);
97
+ this.setSceneChanged();
98
+ return component;
99
+ }
100
+
101
+ component(typeId: string): Component | undefined {
102
+ return this.components.find(typeId);
103
+ }
104
+
105
+ removeComponent(component: Component | string): void {
106
+ this.components.remove(component);
107
+ this.setSceneChanged();
108
+ }
109
+
110
+ addedToNode(node: Node): void {
111
+ // Override in subclasses if needed
112
+ }
113
+
114
+ removedFromNode(node: Node): void {
115
+ // Override in subclasses if needed
116
+ }
117
+
118
+ // This attribute returns true if a node or component
119
+ // has been added or removed to this node or any child node
120
+ get sceneChanged(): boolean {
121
+ return this._sceneChanged;
122
+ }
123
+
124
+ setSceneChanged(): void {
125
+ this._sceneChanged = true;
126
+ if (this._parent) {
127
+ this._parent.setSceneChanged();
128
+ }
129
+ }
130
+
131
+ addChild(node: Node): void {
132
+ if (node._parent) {
133
+ node._parent.removeChild(node);
134
+ }
135
+ node._parent = this;
136
+ this._children.push(node);
137
+ node.addedToNode(this);
138
+
139
+ // If this node has been binded to a renderer, we need to bind
140
+ // the same renderer to any node that is added as child
141
+ if (this._bindedRenderer) {
142
+ bindRenderer(node, this._bindedRenderer);
143
+ }
144
+
145
+ this.setSceneChanged();
146
+ }
147
+
148
+ removeChild(node: Node): void {
149
+ if (node._parent === this) {
150
+ node._parent = null;
151
+ node.removedFromNode(this);
152
+ const index = this._children.indexOf(node);
153
+ if (index !== -1) {
154
+ this._children.splice(index, 1);
155
+ this.setSceneChanged();
156
+ }
157
+ else {
158
+ console.warn(`Scene inconsistency found removing node '${ node.name }' from node '${ this.name }'. The parent node is valid, but the child is not present in the children array.`);
159
+ }
160
+ }
161
+ else {
162
+ throw new Error(`Node.removeChild() - the specified node is not a child of this node.`);
163
+ }
164
+ }
165
+
166
+ emptyChildren(): void {
167
+ this._children.forEach(ch => {
168
+ ch._parent = null;
169
+ ch.removedFromNode(this);
170
+ });
171
+ this._children = [];
172
+ this.setSceneChanged();
173
+ }
174
+
175
+ haveChild(node: Node): boolean {
176
+ return this._children.indexOf(node) !== -1;
177
+ }
178
+
179
+ isAncientOf(node: Node): boolean {
180
+ const isNodeAncient = (node: Node | null, ancient: Node): boolean => {
181
+ if (!node || !ancient) {
182
+ return false;
183
+ }
184
+ else if (node._parent === ancient) {
185
+ return true;
186
+ }
187
+ else {
188
+ return isNodeAncient(node._parent, ancient);
189
+ }
190
+ }
191
+ return isNodeAncient(this, node);
192
+ }
193
+
194
+ // Visitor functions
195
+ accept(nodeVisitor: any): void {
196
+ if (!nodeVisitor.ignoreDisabled || this.enabled) {
197
+ nodeVisitor.visit(this);
198
+ this._children.forEach(ch => ch.accept(nodeVisitor));
199
+ nodeVisitor.didVisit(this);
200
+ }
201
+ }
202
+
203
+ acceptReverse(nodeVisitor: any): void {
204
+ if (!nodeVisitor.ignoreDisabled || this.enabled) {
205
+ if (this._parent) {
206
+ this._parent.acceptReverse(nodeVisitor);
207
+ }
208
+ nodeVisitor.visit(this);
209
+ }
210
+ }
211
+
212
+ async asyncAccept(nodeVisitor: any): Promise<void> {
213
+ if (!nodeVisitor.ignoreDisabled || this.enabled) {
214
+ await nodeVisitor.asyncVisit(this);
215
+ for (const ch in this._children) {
216
+ await this._children[ch].asyncAccept(nodeVisitor);
217
+ }
218
+ }
219
+ }
220
+
221
+ // Most usual components
222
+ get transform(): Transform | undefined {
223
+ return this.component("Transform") as Transform;
224
+ }
225
+
226
+ get lightComponent(): LightComponent | undefined {
227
+ return this.component("Light") as LightComponent;
228
+ }
229
+
230
+ get drawable(): Drawable | undefined {
231
+ return this.component("Drawable") as Drawable;
232
+ }
233
+
234
+ get camera(): Camera | undefined {
235
+ return this.component("Camera") as Camera;
236
+ }
237
+
238
+ frame(delta: number, modelMatrix: Mat4, renderQueue: any): void {
239
+ const willUpdateComponents: Component[] = [];
240
+ const updateComponents: Component[] = [];
241
+ const drawComponents: Component[] = [];
242
+ this._components.forEach(comp => {
243
+ if (comp.requireWillUpdate) {
244
+ willUpdateComponents.push(comp);
245
+ }
246
+ if (comp.requireUpdate) {
247
+ updateComponents.push(comp);
248
+ }
249
+ if (comp.requireDraw) {
250
+ drawComponents.push(comp);
251
+ }
252
+ });
253
+
254
+ willUpdateComponents.forEach(comp => (comp as any).willUpdate(delta));
255
+ updateComponents.forEach(comp => (comp as any).update(delta, modelMatrix));
256
+ drawComponents.forEach(comp => (comp as any).draw(renderQueue, modelMatrix));
257
+ }
258
+
259
+ keyDown(evt: any): void {
260
+ this._components.forEach(comp => {
261
+ comp.keyDown(evt);
262
+ });
263
+ }
264
+ keyUp(evt: any): void {
265
+ this._components.forEach(comp => {
266
+ comp.keyUp(evt);
267
+ });
268
+ }
269
+ mouseUp(evt: any): void {
270
+ this._components.forEach(comp => {
271
+ comp.mouseUp(evt);
272
+ });
273
+ }
274
+ mouseDown(evt: any): void {
275
+ this._components.forEach(comp => {
276
+ comp.mouseDown(evt);
277
+ });
278
+ }
279
+ mouseMove(evt: any): void {
280
+ this._components.forEach(comp => {
281
+ comp.mouseMove(evt);
282
+ });
283
+ }
284
+ mouseOut(evt: any): void {
285
+ this._components.forEach(comp => {
286
+ comp.mouseOut(evt);
287
+ });
288
+ }
289
+ mouseDrag(evt: any): void {
290
+ this._components.forEach(comp => {
291
+ comp.mouseDrag(evt);
292
+ });
293
+ }
294
+ mouseWheel(evt: any): void {
295
+ this._components.forEach(comp => {
296
+ comp.mouseWheel(evt);
297
+ });
298
+ }
299
+ touchStart(evt: any): void {
300
+ this._components.forEach(comp => {
301
+ comp.touchStart(evt);
302
+ });
303
+ }
304
+ touchMove(evt: any): void {
305
+ this._components.forEach(comp => {
306
+ comp.touchMove(evt);
307
+ });
308
+ }
309
+ touchEnd(evt: any): void {
310
+ this._components.forEach(comp => {
311
+ comp.touchEnd(evt);
312
+ });
313
+ }
314
+ }
@@ -0,0 +1,15 @@
1
+ import Node
2
+ from "./Node";
3
+ export default class NodeVisitor {
4
+ private _ignoreDisabled: boolean;
5
+
6
+ constructor() {
7
+ this._ignoreDisabled = true;
8
+ }
9
+
10
+ get ignoreDisabled() { return this._ignoreDisabled; }
11
+ set ignoreDisabled(i) { this._ignoreDisabled = i; }
12
+
13
+ visit(node: Node) {}
14
+ didVisit(node: Node) {}
15
+ }