ohzi-core 10.6.7 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.module.js +1 -1
- package/build/index.module.js.map +1 -1
- package/package.json +9 -11
- package/src/BaseApplication.js +3 -0
- package/src/Browser.js +4 -4
- package/src/Graphics.js +17 -19
- package/src/Initializer.js +1 -7
- package/src/OS.js +2 -2
- package/src/RenderLoop.js +16 -13
- package/src/action_sequencer/ActionEvent.js +1 -2
- package/src/action_sequencer/ActionSequencer.js +3 -7
- package/src/data_textures/RGBDataTexture.js +2 -2
- package/src/data_textures/RGBFloatDataTexture.js +2 -3
- package/src/gpu_particles/ParticleAttribute.js +2 -7
- package/src/index.js +41 -141
- package/src/materials/SSAOMaterial.js +2 -6
- package/src/primitives/Arrow.js +3 -6
- package/src/primitives/Sphere.js +2 -4
- package/src/render_mode/DeferredRender.js +5 -9
- package/src/render_mode/NormalAORender.js +7 -8
- package/src/resource_loader/AsyncTextureLoader.js +5 -3
- package/src/resource_loader/BasisLoader.js +0 -4
- package/src/static_batcher/GeometryBatch.js +2 -8
- package/src/view_components/ApplicationView.js +2 -29
- package/src/view_components/ApplicationViewController.js +95 -0
- package/src/view_components/TransitionManager.js +60 -0
- package/src/view_components/VCManager.js +9 -0
- package/src/view_components/ViewComponent.js +9 -36
- package/src/view_components/ViewComponentController.js +73 -0
- package/src/view_components/ViewComponentControllerManager.js +59 -0
- package/src/view_components/ViewComponentManager.js +3 -13
- package/src/view_components/ViewControllerManager.js +91 -0
- package/src/view_components/ViewManager.js +11 -104
- package/src/view_components/ViewState.js +0 -7
- package/src/view_components/WorkerToMain.js +25 -0
- package/src/view_components/transition/ActionSequencerBuilder.js +3 -3
- package/src/view_components/transition/TransitionTable.js +9 -2
- package/types/BaseApplication.d.ts +1 -0
- package/types/Browser.d.ts +1 -1
- package/types/CameraManager.d.ts +2 -4
- package/types/Graphics.d.ts +8 -3
- package/types/Initializer.d.ts +1 -1
- package/types/RenderLoop.d.ts +1 -2
- package/types/SceneManager.d.ts +1 -3
- package/types/action_sequencer/ActionSequencer.d.ts +2 -2
- package/types/blitter_index.d.ts +6 -0
- package/types/index.d.ts +75 -73
- package/types/render_mode/NormalAORender.d.ts +1 -0
- package/types/resource_loader/AsyncTextureLoader.d.ts +1 -0
- package/types/utilities/FrustumPointFitter.d.ts +1 -3
- package/types/utilities/OMath.d.ts +9 -9
- package/types/view_components/ApplicationView.d.ts +1 -3
- package/types/view_components/ApplicationViewController.d.ts +11 -0
- package/types/view_components/TransitionManager.d.ts +17 -0
- package/types/view_components/VCManager.d.ts +5 -0
- package/types/view_components/ViewComponent.d.ts +1 -5
- package/types/view_components/ViewComponentController.d.ts +14 -0
- package/types/view_components/ViewComponentControllerManager.d.ts +12 -0
- package/types/view_components/ViewComponentManager.d.ts +0 -1
- package/types/view_components/ViewControllerManager.d.ts +12 -0
- package/types/view_components/ViewManager.d.ts +4 -22
- package/types/view_components/ViewState.d.ts +0 -1
- package/types/view_components/WorkerToMain.d.ts +8 -0
- package/types/view_components/transition/ActionSequencerBuilder.d.ts +1 -1
- package/types/view_components/transition/TransitionTable.d.ts +2 -0
- package/src/Configuration.js +0 -23
- package/src/Screen.js +0 -55
- package/src/render_mode/TransparencyMixRender.js +0 -147
- package/src/view_components/ViewContext.js +0 -15
- package/types/Configuration.d.ts +0 -8
- package/types/view_components/ViewContext.d.ts +0 -6
|
@@ -3,11 +3,7 @@ import { BlitMaterial } from '../materials/BlitMaterial';
|
|
|
3
3
|
import frag from '../shaders/ssao/ssao.frag';
|
|
4
4
|
import vert from '../shaders/ssao/ssao.vert';
|
|
5
5
|
|
|
6
|
-
import { Matrix4 } from 'three';
|
|
7
|
-
import { Vector3 } from 'three';
|
|
8
|
-
import { DataTexture } from 'three';
|
|
9
|
-
import { RGBFormat } from 'three';
|
|
10
|
-
import { RepeatWrapping } from 'three';
|
|
6
|
+
import { DataTexture, Matrix4, RGBAFormat, RepeatWrapping, Vector3 } from 'three';
|
|
11
7
|
|
|
12
8
|
import { OMath } from '../utilities/OMath';
|
|
13
9
|
class SSAOMaterial extends BlitMaterial
|
|
@@ -57,7 +53,7 @@ class SSAOMaterial extends BlitMaterial
|
|
|
57
53
|
rotation_kernel[i * 3 + 3] = 0;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
const rotation_texture = new DataTexture(rotation_kernel, 4, 4,
|
|
56
|
+
const rotation_texture = new DataTexture(rotation_kernel, 4, 4, RGBAFormat);
|
|
61
57
|
rotation_texture.wrapS = RepeatWrapping;
|
|
62
58
|
rotation_texture.wrapT = RepeatWrapping;
|
|
63
59
|
|
package/src/primitives/Arrow.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConeBufferGeometry } from 'three';
|
|
3
|
-
import { MeshBasicMaterial } from 'three';
|
|
4
|
-
import { Vector3, Mesh } from 'three';
|
|
1
|
+
import { ConeGeometry, CylinderGeometry, Mesh, MeshBasicMaterial, Vector3 } from 'three';
|
|
5
2
|
|
|
6
3
|
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
7
4
|
|
|
@@ -14,10 +11,10 @@ class Arrow extends Mesh
|
|
|
14
11
|
|
|
15
12
|
const cone_height = 0.4;
|
|
16
13
|
const cylinder_height = length - cone_height;
|
|
17
|
-
const cylinder_geo = new
|
|
14
|
+
const cylinder_geo = new CylinderGeometry(0.01, 0.01, cylinder_height, 32);
|
|
18
15
|
cylinder_geo.translate(0, cylinder_height / 2, 0);
|
|
19
16
|
|
|
20
|
-
const cone_geometry = new
|
|
17
|
+
const cone_geometry = new ConeGeometry(0.1, cone_height, 32);
|
|
21
18
|
cone_geometry.translate(0, cylinder_height + cone_height / 2, 0);
|
|
22
19
|
|
|
23
20
|
const buffer_geometry = BufferGeometryUtils.mergeBufferGeometries([cylinder_geo, cone_geometry]);
|
package/src/primitives/Sphere.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Mesh } from 'three';
|
|
2
|
-
import { SphereBufferGeometry } from 'three';
|
|
3
|
-
import { MeshBasicMaterial } from 'three';
|
|
1
|
+
import { Mesh, MeshBasicMaterial, SphereGeometry } from 'three';
|
|
4
2
|
|
|
5
3
|
class Sphere extends Mesh
|
|
6
4
|
{
|
|
@@ -8,7 +6,7 @@ class Sphere extends Mesh
|
|
|
8
6
|
{
|
|
9
7
|
color = color || '#FF0000';
|
|
10
8
|
radius = radius || 1;
|
|
11
|
-
const geometry = new
|
|
9
|
+
const geometry = new SphereGeometry(radius, 64, 64);
|
|
12
10
|
const material = new MeshBasicMaterial({ color: color });
|
|
13
11
|
super(geometry, material);
|
|
14
12
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { CameraManager } from '../CameraManager';
|
|
2
|
-
import {
|
|
2
|
+
import { Graphics } from '../Graphics';
|
|
3
3
|
import { OScreen } from '../OScreen';
|
|
4
|
-
import {
|
|
4
|
+
import { SceneManager } from '../SceneManager';
|
|
5
5
|
import { DeferredRendererComposeMaterial } from '../materials/DeferredRendererComposeMaterial';
|
|
6
|
-
import { Graphics } from '../Graphics';
|
|
7
6
|
import { DeferredPointLightMaterial } from '../materials/deferred/DeferredPointLightMaterial';
|
|
7
|
+
import { BaseRender } from '../render_mode/BaseRender';
|
|
8
8
|
|
|
9
|
-
import { WebGLRenderTarget } from 'three';
|
|
10
|
-
import { Scene } from 'three';
|
|
11
|
-
import { Mesh } from 'three';
|
|
12
|
-
import { SphereBufferGeometry } from 'three';
|
|
13
|
-
import { Matrix4 } from 'three';
|
|
9
|
+
import { Matrix4, Mesh, Scene, SphereGeometry, WebGLRenderTarget } from 'three';
|
|
14
10
|
|
|
15
11
|
class DeferredRender extends BaseRender
|
|
16
12
|
{
|
|
@@ -29,7 +25,7 @@ class DeferredRender extends BaseRender
|
|
|
29
25
|
const light_intensity = 1;
|
|
30
26
|
const light_brightest_component = 1;
|
|
31
27
|
const radius_needed_for_intensity = Math.sqrt(4 * light_intensity * (light_brightest_component * (256.0 / 5.0))) / (2 * light_intensity);
|
|
32
|
-
const sphere = new Mesh(new
|
|
28
|
+
const sphere = new Mesh(new SphereGeometry(radius_needed_for_intensity), new DeferredPointLightMaterial(light_intensity));
|
|
33
29
|
// sphere.position.y = 2;
|
|
34
30
|
// this.scene_lights.add(sphere);
|
|
35
31
|
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { CameraManager } from '../CameraManager';
|
|
2
|
-
import {
|
|
2
|
+
import { Graphics } from '../Graphics';
|
|
3
3
|
import { OScreen } from '../OScreen';
|
|
4
|
-
import {
|
|
5
|
-
import { Configuration } from '../Configuration';
|
|
6
|
-
import { SSAOMaterial } from '../materials/SSAOMaterial';
|
|
7
|
-
import { SSAOComposeMaterial } from '../materials/SSAOComposeMaterial';
|
|
4
|
+
import { SceneManager } from '../SceneManager';
|
|
8
5
|
import { DisplayNormalTextureMaterial } from '../materials/DisplayNormalTextureMaterial';
|
|
6
|
+
import { SSAOComposeMaterial } from '../materials/SSAOComposeMaterial';
|
|
7
|
+
import { SSAOMaterial } from '../materials/SSAOMaterial';
|
|
8
|
+
import { BaseRender } from '../render_mode/BaseRender';
|
|
9
9
|
import { Blurrer } from '../render_utilities/Blurrer';
|
|
10
|
-
import { Graphics } from '../Graphics';
|
|
11
10
|
|
|
12
11
|
import { WebGLRenderTarget } from 'three';
|
|
13
12
|
|
|
14
13
|
class NormalAORender extends BaseRender
|
|
15
14
|
{
|
|
16
|
-
constructor()
|
|
15
|
+
constructor(use_ssaa = false)
|
|
17
16
|
{
|
|
18
17
|
super();
|
|
19
18
|
|
|
@@ -21,7 +20,7 @@ class NormalAORender extends BaseRender
|
|
|
21
20
|
this.ssao_compose_mat = new SSAOComposeMaterial();
|
|
22
21
|
this.debug_normals = new DisplayNormalTextureMaterial();
|
|
23
22
|
|
|
24
|
-
this.ssaa =
|
|
23
|
+
this.ssaa = use_ssaa ? 2 : 1;
|
|
25
24
|
|
|
26
25
|
this.main_RT = new WebGLRenderTarget(OScreen.width * this.ssaa, OScreen.height * this.ssaa);
|
|
27
26
|
|
|
@@ -9,6 +9,8 @@ class AsyncTextureLoader extends AbstractLoader
|
|
|
9
9
|
{
|
|
10
10
|
super(resource_id, url, size);
|
|
11
11
|
|
|
12
|
+
this.original_url = '';
|
|
13
|
+
|
|
12
14
|
this.colorSpaceConversion = colorSpaceConversion;
|
|
13
15
|
this.premultiplyAlpha = premultiplyAlpha;
|
|
14
16
|
this.flipY = flipY;
|
|
@@ -51,7 +53,7 @@ class AsyncTextureLoader extends AbstractLoader
|
|
|
51
53
|
|
|
52
54
|
image.onerror = () =>
|
|
53
55
|
{
|
|
54
|
-
console.error('
|
|
56
|
+
console.error('The source image could not be decoded.', this.original_url);
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
else
|
|
@@ -93,9 +95,9 @@ class AsyncTextureLoader extends AbstractLoader
|
|
|
93
95
|
|
|
94
96
|
this.__update_downloaded_bytes(1, 1);
|
|
95
97
|
this.__loading_ended();
|
|
96
|
-
}).catch(
|
|
98
|
+
}).catch((e) =>
|
|
97
99
|
{
|
|
98
|
-
console.error(e);
|
|
100
|
+
console.error(e, this.original_url);
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
else
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AbstractLoader } from './AbstractLoader';
|
|
2
2
|
|
|
3
|
-
// import { sRGBEncoding } from 'three';
|
|
4
|
-
|
|
5
3
|
class BasisLoader extends AbstractLoader
|
|
6
4
|
{
|
|
7
5
|
constructor(resource_id, url, loader, size)
|
|
@@ -17,8 +15,6 @@ class BasisLoader extends AbstractLoader
|
|
|
17
15
|
{
|
|
18
16
|
this.loader.load(this.url, (basis) =>
|
|
19
17
|
{
|
|
20
|
-
// basis.encoding = sRGBEncoding;
|
|
21
|
-
|
|
22
18
|
resource_container.set_resource(this.resource_id, this.url, basis);
|
|
23
19
|
|
|
24
20
|
this.__update_downloaded_bytes(1, 1);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { Vector2 } from 'three';
|
|
2
|
-
import { ShaderMaterial } from 'three';
|
|
3
|
-
import { Mesh } from 'three';
|
|
4
|
-
import { DataTexture } from 'three';
|
|
5
|
-
import { RGBAFormat } from 'three';
|
|
6
|
-
import { RGBFormat } from 'three';
|
|
7
|
-
import { FloatType } from 'three';
|
|
1
|
+
import { DataTexture, FloatType, Mesh, RGBAFormat, ShaderMaterial, Vector2 } from 'three';
|
|
8
2
|
|
|
9
3
|
class GeometryBatch
|
|
10
4
|
{
|
|
@@ -242,7 +236,7 @@ class GeometryBatch
|
|
|
242
236
|
__create_rgb_texture(width)
|
|
243
237
|
{
|
|
244
238
|
const data = new Uint8Array(3 * width * width);
|
|
245
|
-
return new DataTexture(data, width, width,
|
|
239
|
+
return new DataTexture(data, width, width, RGBAFormat);
|
|
246
240
|
}
|
|
247
241
|
|
|
248
242
|
__create_rgba_texture(width)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ResourceContainer } from '../ResourceContainer';
|
|
2
|
-
import { HTMLUtilities } from '../utilities/HTMLUtilities';
|
|
3
1
|
import { ViewManager } from './ViewManager';
|
|
4
2
|
import { ViewState } from './ViewState';
|
|
5
3
|
|
|
@@ -12,22 +10,7 @@ class ApplicationView extends ViewState
|
|
|
12
10
|
this.container = container;
|
|
13
11
|
this.url = url;
|
|
14
12
|
|
|
15
|
-
let transition_data = ResourceContainer.get(`${name}_data`);
|
|
16
|
-
|
|
17
|
-
transition_data = transition_data || {
|
|
18
|
-
animation_tracks: [],
|
|
19
|
-
triggers: []
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const transitions = [
|
|
23
|
-
{
|
|
24
|
-
to: name,
|
|
25
|
-
data: transition_data
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
|
|
29
13
|
ViewManager.register_view(this);
|
|
30
|
-
ViewManager.add_transitions(transitions);
|
|
31
14
|
}
|
|
32
15
|
|
|
33
16
|
show()
|
|
@@ -58,19 +41,9 @@ class ApplicationView extends ViewState
|
|
|
58
41
|
this.container.classList.remove('before_exit');
|
|
59
42
|
}
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
HTMLUtilities.load_images(this.container);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
load_html_videos()
|
|
67
|
-
{
|
|
68
|
-
HTMLUtilities.load_videos(this.container);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
set_opacity(current_state_data)
|
|
44
|
+
set_opacity(opacity)
|
|
72
45
|
{
|
|
73
|
-
this.container.style.opacity =
|
|
46
|
+
this.container.style.opacity = opacity;
|
|
74
47
|
}
|
|
75
48
|
}
|
|
76
49
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { TransitionManager } from './TransitionManager';
|
|
2
|
+
import { VCManager } from './VCManager';
|
|
3
|
+
import { ViewState } from './ViewState';
|
|
4
|
+
import { WorkerToMain } from './WorkerToMain';
|
|
5
|
+
|
|
6
|
+
class ApplicationViewController extends ViewState
|
|
7
|
+
{
|
|
8
|
+
constructor({ name, url, transition_data })
|
|
9
|
+
{
|
|
10
|
+
super(name);
|
|
11
|
+
|
|
12
|
+
this.url = url;
|
|
13
|
+
|
|
14
|
+
transition_data = transition_data || {
|
|
15
|
+
animation_tracks: [],
|
|
16
|
+
triggers: []
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const transitions = [
|
|
20
|
+
{
|
|
21
|
+
to: name,
|
|
22
|
+
data: transition_data
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
this.current_opacity = 0;
|
|
27
|
+
|
|
28
|
+
VCManager.register_view_controller(this);
|
|
29
|
+
TransitionManager.add_transitions(transitions);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
show()
|
|
33
|
+
{
|
|
34
|
+
WorkerToMain.push(`${this.name}_view.show`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
before_enter()
|
|
38
|
+
{
|
|
39
|
+
WorkerToMain.push(`${this.name}_view.before_enter`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
on_enter()
|
|
43
|
+
{
|
|
44
|
+
WorkerToMain.push(`${this.name}_view.on_enter`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
before_exit()
|
|
48
|
+
{
|
|
49
|
+
WorkerToMain.push(`${this.name}_view.before_exit`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
on_exit()
|
|
53
|
+
{
|
|
54
|
+
WorkerToMain.push(`${this.name}_view.on_exit`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
hide()
|
|
58
|
+
{
|
|
59
|
+
WorkerToMain.push(`${this.name}_view.hide`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
update()
|
|
63
|
+
{
|
|
64
|
+
WorkerToMain.push(`${this.name}_view.update`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fixed_update()
|
|
68
|
+
{
|
|
69
|
+
// TODO: Evaluate if a fixed update is necessary on the main thread
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
update_enter_transition(global_view_data, transition_progress, action_sequencer)
|
|
73
|
+
{
|
|
74
|
+
WorkerToMain.push(`${this.name}_view.update_enter_transition`, [global_view_data, transition_progress]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
update_exit_transition(global_view_data, transition_progress, action_sequencer)
|
|
78
|
+
{
|
|
79
|
+
WorkerToMain.push(`${this.name}_view.update_exit_transition`, [global_view_data, transition_progress]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
set_opacity(current_state_data)
|
|
83
|
+
{
|
|
84
|
+
const opacity = current_state_data[`${this.name}_opacity`];
|
|
85
|
+
|
|
86
|
+
if (this.current_opacity > opacity || this.current_opacity < opacity)
|
|
87
|
+
{
|
|
88
|
+
this.current_opacity = opacity;
|
|
89
|
+
|
|
90
|
+
WorkerToMain.push(`${this.name}_view.set_opacity`, [opacity]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { ApplicationViewController };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { TransitionTable } from './transition/TransitionTable';
|
|
2
|
+
import { ViewStateTransitionHandler } from './transition/ViewStateTransitionHandler';
|
|
3
|
+
|
|
4
|
+
class TransitionManager
|
|
5
|
+
{
|
|
6
|
+
constructor()
|
|
7
|
+
{
|
|
8
|
+
this.transition_table = new TransitionTable();
|
|
9
|
+
this.transition_handler = new ViewStateTransitionHandler(this.transition_table);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get action_sequencer()
|
|
13
|
+
{
|
|
14
|
+
return this.transition_handler.action_sequencer;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get current_state_data()
|
|
18
|
+
{
|
|
19
|
+
return this.transition_handler.current_state_data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
before_update()
|
|
23
|
+
{
|
|
24
|
+
this.transition_handler.before_update();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
update()
|
|
28
|
+
{
|
|
29
|
+
this.transition_handler.update();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fixed_update()
|
|
33
|
+
{
|
|
34
|
+
this.transition_handler.fixed_update();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
add_transitions(transitions)
|
|
38
|
+
{
|
|
39
|
+
this.transition_table.add_transitions(transitions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
set_transitions(transitions)
|
|
43
|
+
{
|
|
44
|
+
this.transition_table.set_transitions(transitions);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set_default_state_data(default_state_data)
|
|
48
|
+
{
|
|
49
|
+
this.transition_table.set_default_state_data(default_state_data);
|
|
50
|
+
this.transition_handler.set_default_state_data(default_state_data);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set_transitions_velocity(transitions_velocity)
|
|
54
|
+
{
|
|
55
|
+
this.transition_table.set_transitions_velocity(transitions_velocity);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const transition_manager = new TransitionManager();
|
|
60
|
+
export { transition_manager as TransitionManager };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { HTMLUtilities } from '../utilities/HTMLUtilities';
|
|
2
1
|
import { ViewComponentManager } from './ViewComponentManager';
|
|
3
2
|
|
|
4
3
|
class ViewComponent
|
|
@@ -7,7 +6,8 @@ class ViewComponent
|
|
|
7
6
|
{
|
|
8
7
|
this.name = name;
|
|
9
8
|
this.container = container;
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
// this.hidden = true;
|
|
11
11
|
|
|
12
12
|
ViewComponentManager.register_component(this);
|
|
13
13
|
}
|
|
@@ -19,9 +19,10 @@ class ViewComponent
|
|
|
19
19
|
on_enter()
|
|
20
20
|
{
|
|
21
21
|
this.container.classList.remove('hidden');
|
|
22
|
-
ViewComponentManager.enable_component(this);
|
|
23
22
|
|
|
24
|
-
this.hidden = false;
|
|
23
|
+
// this.hidden = false;
|
|
24
|
+
|
|
25
|
+
ViewComponentManager.enable_component(this);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
update()
|
|
@@ -31,43 +32,15 @@ class ViewComponent
|
|
|
31
32
|
on_exit()
|
|
32
33
|
{
|
|
33
34
|
this.container.classList.add('hidden');
|
|
34
|
-
ViewComponentManager.disable_component(this);
|
|
35
|
-
|
|
36
|
-
this.hidden = true;
|
|
37
|
-
}
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
this.container.style.opacity = current_state_data[`${this.name}_opacity`];
|
|
42
|
-
this.toggle_hidden();
|
|
43
|
-
}
|
|
36
|
+
// this.hidden = true;
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
if (this.container.style.opacity > 0.001)
|
|
48
|
-
{
|
|
49
|
-
if (this.hidden)
|
|
50
|
-
{
|
|
51
|
-
this.on_enter();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else
|
|
55
|
-
{
|
|
56
|
-
if (!this.hidden)
|
|
57
|
-
{
|
|
58
|
-
this.on_exit();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
load_html_images()
|
|
64
|
-
{
|
|
65
|
-
HTMLUtilities.load_images(this.container);
|
|
38
|
+
ViewComponentManager.disable_component(this);
|
|
66
39
|
}
|
|
67
40
|
|
|
68
|
-
|
|
41
|
+
set_opacity(opacity)
|
|
69
42
|
{
|
|
70
|
-
|
|
43
|
+
this.container.style.opacity = opacity;
|
|
71
44
|
}
|
|
72
45
|
}
|
|
73
46
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ViewComponentControllerManager } from './ViewComponentControllerManager';
|
|
2
|
+
import { WorkerToMain } from './WorkerToMain';
|
|
3
|
+
|
|
4
|
+
class ViewComponentController
|
|
5
|
+
{
|
|
6
|
+
constructor({ name })
|
|
7
|
+
{
|
|
8
|
+
this.name = name;
|
|
9
|
+
|
|
10
|
+
this.current_opacity = 0;
|
|
11
|
+
this.hidden = true;
|
|
12
|
+
|
|
13
|
+
ViewComponentControllerManager.register_component_controller(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
start()
|
|
17
|
+
{
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
on_enter()
|
|
21
|
+
{
|
|
22
|
+
ViewComponentControllerManager.enable_component_controller(this);
|
|
23
|
+
WorkerToMain.push(`${this.name}_component.on_enter`);
|
|
24
|
+
|
|
25
|
+
this.hidden = false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
update()
|
|
29
|
+
{
|
|
30
|
+
WorkerToMain.push(`${this.name}_component.update`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
on_exit()
|
|
34
|
+
{
|
|
35
|
+
ViewComponentControllerManager.disable_component_controller(this);
|
|
36
|
+
WorkerToMain.push(`${this.name}_component.on_exit`);
|
|
37
|
+
|
|
38
|
+
this.hidden = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set_opacity(current_state_data)
|
|
42
|
+
{
|
|
43
|
+
const opacity = current_state_data[`${this.name}_opacity`];
|
|
44
|
+
|
|
45
|
+
if (this.current_opacity > opacity || this.current_opacity < opacity)
|
|
46
|
+
{
|
|
47
|
+
this.current_opacity = opacity;
|
|
48
|
+
|
|
49
|
+
WorkerToMain.push(`${this.name}_component.set_opacity`, [opacity]);
|
|
50
|
+
this.toggle_hidden();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
toggle_hidden()
|
|
55
|
+
{
|
|
56
|
+
if (this.current_opacity > 0.0001)
|
|
57
|
+
{
|
|
58
|
+
if (this.hidden)
|
|
59
|
+
{
|
|
60
|
+
this.on_enter();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
{
|
|
65
|
+
if (!this.hidden)
|
|
66
|
+
{
|
|
67
|
+
this.on_exit();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { ViewComponentController };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TransitionManager } from './TransitionManager';
|
|
2
|
+
|
|
3
|
+
class ViewComponentControllerManager
|
|
4
|
+
{
|
|
5
|
+
constructor()
|
|
6
|
+
{
|
|
7
|
+
this.component_controllers = [];
|
|
8
|
+
this.enabled_component_controllers = new Set();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
update()
|
|
12
|
+
{
|
|
13
|
+
this.__set_component_controllers_opacities();
|
|
14
|
+
|
|
15
|
+
for (const component_controller of this.enabled_component_controllers)
|
|
16
|
+
{
|
|
17
|
+
component_controller.update(TransitionManager.current_state_data);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
register_component_controller(component_controller)
|
|
22
|
+
{
|
|
23
|
+
this.component_controllers.push(component_controller);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
enable_component_controller(component_controller)
|
|
27
|
+
{
|
|
28
|
+
this.enabled_component_controllers.add(component_controller);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disable_component_controller(component_controller)
|
|
32
|
+
{
|
|
33
|
+
this.enabled_component_controllers.delete(component_controller);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get(component_name)
|
|
37
|
+
{
|
|
38
|
+
for (let i = 0; i < this.component_controllers.length; i++)
|
|
39
|
+
{
|
|
40
|
+
if (this.component_controllers[i].name === component_name)
|
|
41
|
+
{
|
|
42
|
+
return this.component_controllers[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
console.error('[ViewComponentControllerManager.get] no component_controller found for: ', component_name);
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
__set_component_controllers_opacities()
|
|
50
|
+
{
|
|
51
|
+
for (let i = 0; i < this.component_controllers.length; i++)
|
|
52
|
+
{
|
|
53
|
+
this.component_controllers[i].set_opacity(TransitionManager.current_state_data);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const view_component_contorller_manager = new ViewComponentControllerManager();
|
|
59
|
+
export { view_component_contorller_manager as ViewComponentControllerManager };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransitionManager } from './TransitionManager';
|
|
2
2
|
|
|
3
3
|
class ViewComponentManager
|
|
4
4
|
{
|
|
@@ -14,7 +14,7 @@ class ViewComponentManager
|
|
|
14
14
|
|
|
15
15
|
for (const component of this.enabled_components)
|
|
16
16
|
{
|
|
17
|
-
component.update(
|
|
17
|
+
component.update(TransitionManager.current_state_data);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -25,24 +25,14 @@ class ViewComponentManager
|
|
|
25
25
|
|
|
26
26
|
enable_component(component)
|
|
27
27
|
{
|
|
28
|
-
// const component_to_enable = this.get_component_by_name(component_name);
|
|
29
|
-
|
|
30
28
|
this.enabled_components.add(component);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
disable_component(component)
|
|
34
32
|
{
|
|
35
|
-
// const component_to_disable = this.get_component_by_name(component_name);
|
|
36
|
-
|
|
37
33
|
this.enabled_components.delete(component);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
get_component_by_name(component_name)
|
|
41
|
-
{
|
|
42
|
-
console.warn('DEPRECATED. Use ViewComponentManager.get instead');
|
|
43
|
-
this.get(component_name);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
36
|
get(component_name)
|
|
47
37
|
{
|
|
48
38
|
for (let i = 0; i < this.components.length; i++)
|
|
@@ -60,7 +50,7 @@ class ViewComponentManager
|
|
|
60
50
|
{
|
|
61
51
|
for (let i = 0; i < this.components.length; i++)
|
|
62
52
|
{
|
|
63
|
-
this.components[i].set_opacity(
|
|
53
|
+
this.components[i].set_opacity(TransitionManager.current_state_data);
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
}
|