ohzi-core 6.5.5 → 6.7.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.
- package/build/index.module.js +1 -1
- package/build/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/Debug.js +2 -2
- package/src/Graphics.js +20 -20
- package/src/Initializer.js +2 -2
- package/src/OScreen.js +74 -0
- package/src/Screen.js +17 -32
- package/src/UI.js +4 -4
- package/src/components/UIElement.js +9 -9
- package/src/editor/ObjectPicker.js +4 -4
- package/src/index.js +2 -0
- package/src/materials/UIElementMaterial.js +3 -1
- package/src/render_mode/BloomRender.js +7 -6
- package/src/render_mode/DeferredRender.js +4 -4
- package/src/render_mode/NormalAORender.js +6 -6
- package/src/render_mode/OutlineRender.js +6 -6
- package/src/render_mode/PlanarReflectionsRender.js +2 -2
- package/src/render_mode/TransparencyMixRender.js +11 -11
- package/src/render_mode/UnrealBloomRender.js +6 -6
- package/src/render_utilities/DepthAndNormalsRenderer.js +4 -4
- package/src/render_utilities/ViewPositionRenderer.js +5 -5
- package/src/resource_loader/JSONLoader.js +6 -26
- package/src/utilities/CameraUtilities.js +13 -13
- package/src/view_components/ViewManager.js +33 -0
- package/types/OScreen.d.ts +18 -0
- package/types/index.d.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import OScreen from '../OScreen';
|
|
2
2
|
import RenderLayers from '../RenderLayers';
|
|
3
3
|
import transparent_mix_vert from '../shaders/transparent_mix/transparent_mix.vert';
|
|
4
4
|
import transparent_mix_frag from '../shaders/transparent_mix/transparent_mix.frag';
|
|
@@ -18,15 +18,15 @@ export default class TransparencyMixRender
|
|
|
18
18
|
constructor(webgl)
|
|
19
19
|
{
|
|
20
20
|
this.SSAA = Configuration.use_ssaa ? 2 : 1;
|
|
21
|
-
this.main_rt = new WebGLRenderTarget(
|
|
22
|
-
this.opaque_rt = new WebGLRenderTarget(
|
|
23
|
-
this.fxaa_rt = new WebGLRenderTarget(
|
|
21
|
+
this.main_rt = new WebGLRenderTarget(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
22
|
+
this.opaque_rt = new WebGLRenderTarget(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
23
|
+
this.fxaa_rt = new WebGLRenderTarget(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
24
24
|
|
|
25
25
|
this.mix_material = new ShaderMaterial({
|
|
26
26
|
uniforms: {
|
|
27
27
|
_OpaqueTex: { value: this.opaque_rt.texture },
|
|
28
28
|
_TransparentTex: { value: this.main_rt.texture },
|
|
29
|
-
_Resolution: { value: new Vector2(
|
|
29
|
+
_Resolution: { value: new Vector2(OScreen.width, OScreen.height) },
|
|
30
30
|
_Opacity: { value: Configuration.transparency_amount }
|
|
31
31
|
},
|
|
32
32
|
vertexShader: transparent_mix_vert,
|
|
@@ -62,11 +62,11 @@ export default class TransparencyMixRender
|
|
|
62
62
|
|
|
63
63
|
resize()
|
|
64
64
|
{
|
|
65
|
-
this.main_rt.setSize(
|
|
66
|
-
this.opaque_rt.setSize(
|
|
67
|
-
this.fxaa_rt.setSize(
|
|
68
|
-
this.fxaa_material.uniforms._Resolution.value.set(
|
|
69
|
-
this.mix_material.uniforms._Resolution.value.set(
|
|
65
|
+
this.main_rt.setSize(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
66
|
+
this.opaque_rt.setSize(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
67
|
+
this.fxaa_rt.setSize(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
68
|
+
this.fxaa_material.uniforms._Resolution.value.set(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
69
|
+
this.mix_material.uniforms._Resolution.value.set(OScreen.width * this.SSAA, OScreen.height * this.SSAA);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
__get_fxaa_material()
|
|
@@ -74,7 +74,7 @@ export default class TransparencyMixRender
|
|
|
74
74
|
return new ShaderMaterial({
|
|
75
75
|
uniforms: {
|
|
76
76
|
_MainTex: { value: this.fxaa_rt.texture },
|
|
77
|
-
_Resolution: { value: new Vector2(
|
|
77
|
+
_Resolution: { value: new Vector2(OScreen.width * this.SSAA, OScreen.height * this.SSAA) }
|
|
78
78
|
},
|
|
79
79
|
vertexShader: transparent_mix_vert,
|
|
80
80
|
fragmentShader: fxaa,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import OScreen from '../OScreen';
|
|
2
2
|
import BaseRender from '../render_mode/BaseRender';
|
|
3
3
|
import UnrealBloomComposeMaterial from '../materials/UnrealBloomComposeMaterial';
|
|
4
4
|
import AddMaterial from '../materials/AddMaterial';
|
|
@@ -28,8 +28,8 @@ export default class UnrealBloomRender extends BaseRender
|
|
|
28
28
|
on_enter()
|
|
29
29
|
{
|
|
30
30
|
this.blurrer = new GaussianBlurrer();
|
|
31
|
-
this.main_RT = new WebGLRenderTarget(
|
|
32
|
-
this.blur_RT = new WebGLRenderTarget(
|
|
31
|
+
this.main_RT = new WebGLRenderTarget(OScreen.render_width, OScreen.render_height);
|
|
32
|
+
this.blur_RT = new WebGLRenderTarget(OScreen.render_width, OScreen.render_height);
|
|
33
33
|
|
|
34
34
|
this.bloom_compose_mat = new UnrealBloomComposeMaterial(5);
|
|
35
35
|
this.blurrer = new GaussianBlurrer(5);
|
|
@@ -100,10 +100,10 @@ export default class UnrealBloomRender extends BaseRender
|
|
|
100
100
|
|
|
101
101
|
__check_RT_size()
|
|
102
102
|
{
|
|
103
|
-
if (this.main_RT.width !==
|
|
103
|
+
if (this.main_RT.width !== OScreen.render_width || this.main_RT.height !== OScreen.render_height)
|
|
104
104
|
{
|
|
105
|
-
this.main_RT.setSize(
|
|
106
|
-
this.blur_RT.setSize(
|
|
105
|
+
this.main_RT.setSize(OScreen.render_width, OScreen.render_height);
|
|
106
|
+
this.blur_RT.setSize(OScreen.render_width, OScreen.render_height);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import CameraManager from '../CameraManager';
|
|
2
|
-
import
|
|
2
|
+
import OScreen from '../OScreen';
|
|
3
3
|
|
|
4
4
|
import ClearDepthNormalMaterial from '../materials/ClearDepthNormalMaterial';
|
|
5
5
|
import DepthNormalMaterial from '../materials/DepthNormalMaterial';
|
|
@@ -11,7 +11,7 @@ export default class DepthAndNormalsRenderer
|
|
|
11
11
|
{
|
|
12
12
|
constructor()
|
|
13
13
|
{
|
|
14
|
-
this.RT = new WebGLRenderTarget(
|
|
14
|
+
this.RT = new WebGLRenderTarget(OScreen.width, OScreen.height);
|
|
15
15
|
|
|
16
16
|
this.clear_depth_normal_mat = new ClearDepthNormalMaterial(1, new Vector3(0, 0, 1));
|
|
17
17
|
this.depth_normal_material = new DepthNormalMaterial();
|
|
@@ -32,9 +32,9 @@ export default class DepthAndNormalsRenderer
|
|
|
32
32
|
|
|
33
33
|
__resize_RT_if_necessary()
|
|
34
34
|
{
|
|
35
|
-
if (this.RT.width !==
|
|
35
|
+
if (this.RT.width !== OScreen.width || this.RT.height !== OScreen.height)
|
|
36
36
|
{
|
|
37
|
-
this.RT.setSize(
|
|
37
|
+
this.RT.setSize(OScreen.width, OScreen.height);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import CameraManager from '../CameraManager';
|
|
2
2
|
import SceneManager from '../SceneManager';
|
|
3
|
-
import
|
|
3
|
+
import OScreen from '../OScreen';
|
|
4
4
|
import ViewPositionMaterial from '../materials/ViewPositionMaterial';
|
|
5
5
|
|
|
6
6
|
import { WebGLRenderTarget } from 'three';
|
|
@@ -11,21 +11,21 @@ export default class ViewPositionRenderer
|
|
|
11
11
|
{
|
|
12
12
|
constructor()
|
|
13
13
|
{
|
|
14
|
-
this.RT = new WebGLRenderTarget(
|
|
14
|
+
this.RT = new WebGLRenderTarget(OScreen.width, OScreen.height, { type: FloatType });
|
|
15
15
|
this.clear_color = new Color(0, 0, 0);
|
|
16
16
|
this.render_pos_mat = new ViewPositionMaterial();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
render(context, renderer)
|
|
20
20
|
{
|
|
21
|
-
if (this.RT.width !==
|
|
21
|
+
if (this.RT.width !== OScreen.width || this.RT.height !== OScreen.height)
|
|
22
22
|
{
|
|
23
|
-
this.RT.setSize(
|
|
23
|
+
this.RT.setSize(OScreen.width, OScreen.height);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (CameraManager.current)
|
|
27
27
|
{
|
|
28
|
-
CameraManager.current.aspect =
|
|
28
|
+
CameraManager.current.aspect = OScreen.aspect_ratio;
|
|
29
29
|
CameraManager.current.updateProjectionMatrix();
|
|
30
30
|
CameraManager.current.updateMatrix();
|
|
31
31
|
CameraManager.current.updateMatrixWorld(true);
|
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
import AbstractLoader from './AbstractLoader';
|
|
2
2
|
|
|
3
|
-
import { FileLoader as THREEFileLoader } from 'three';
|
|
4
|
-
|
|
5
3
|
export default class JSONLoader extends AbstractLoader
|
|
6
4
|
{
|
|
7
5
|
constructor(resource_id, url, size)
|
|
8
6
|
{
|
|
9
7
|
super(resource_id, url, size);
|
|
10
|
-
|
|
11
|
-
this.loader = new THREEFileLoader();
|
|
12
8
|
}
|
|
13
9
|
|
|
14
|
-
on_preloaded_finished(resource_container)
|
|
10
|
+
on_preloaded_finished(resource_container, response)
|
|
15
11
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.loader.load(this.url, (data) =>
|
|
12
|
+
response.json().then((json) =>
|
|
19
13
|
{
|
|
20
|
-
resource_container.set_resource(
|
|
14
|
+
resource_container.set_resource(this.resource_id, this.url, json);
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
(xhr) =>
|
|
26
|
-
{
|
|
27
|
-
// if (xhr)
|
|
28
|
-
// {
|
|
29
|
-
// let total = xhr.total || this.total_bytes;
|
|
30
|
-
// ctx.__update_downloaded_bytes(xhr.loaded, total);
|
|
31
|
-
// }
|
|
32
|
-
},
|
|
33
|
-
(msg) =>
|
|
34
|
-
{
|
|
35
|
-
ctx.__set_error(msg + '\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource');
|
|
36
|
-
ctx.__loading_ended();
|
|
37
|
-
}
|
|
38
|
-
);
|
|
16
|
+
this.__update_downloaded_bytes(1, 1);
|
|
17
|
+
this.__loading_ended();
|
|
18
|
+
});
|
|
39
19
|
}
|
|
40
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import CameraManager from '../CameraManager';
|
|
2
2
|
import Input from '../Input';
|
|
3
3
|
import OMath from '../utilities/OMath';
|
|
4
|
-
import
|
|
4
|
+
import OScreen from '../OScreen';
|
|
5
5
|
|
|
6
6
|
import { Vector3 } from 'three';
|
|
7
7
|
import { Matrix4 } from 'three';
|
|
@@ -152,13 +152,13 @@ class CameraUtilities
|
|
|
152
152
|
const obj_x = this.tmp_size.x;
|
|
153
153
|
const obj_y = this.tmp_size.y;
|
|
154
154
|
const object_aspect = obj_x / obj_y;
|
|
155
|
-
if (
|
|
155
|
+
if (OScreen.aspect_ratio / object_aspect > 1)
|
|
156
156
|
{
|
|
157
|
-
return
|
|
157
|
+
return OScreen.height / obj_y;
|
|
158
158
|
}
|
|
159
159
|
else
|
|
160
160
|
{
|
|
161
|
-
return
|
|
161
|
+
return OScreen.width / obj_x;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
else
|
|
@@ -178,8 +178,8 @@ class CameraUtilities
|
|
|
178
178
|
object.getWorldPosition(tmp_vec);
|
|
179
179
|
tmp_vec.project(camera);
|
|
180
180
|
|
|
181
|
-
tmp_vec.x = (tmp_vec.x * 0.5 + 0.5) * (
|
|
182
|
-
tmp_vec.y = (1 - (tmp_vec.y * 0.5 + 0.5)) *
|
|
181
|
+
tmp_vec.x = (tmp_vec.x * 0.5 + 0.5) * (OScreen.width);
|
|
182
|
+
tmp_vec.y = (1 - (tmp_vec.y * 0.5 + 0.5)) * OScreen.height;
|
|
183
183
|
return tmp_vec;
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -191,18 +191,18 @@ class CameraUtilities
|
|
|
191
191
|
tmp_vec.copy(pos);
|
|
192
192
|
tmp_vec.project(camera);
|
|
193
193
|
|
|
194
|
-
tmp_vec.x = (tmp_vec.x * 0.5 + 0.5) * (
|
|
195
|
-
tmp_vec.y = (1 - (tmp_vec.y * 0.5 + 0.5)) *
|
|
194
|
+
tmp_vec.x = (tmp_vec.x * 0.5 + 0.5) * (OScreen.width);
|
|
195
|
+
tmp_vec.y = (1 - (tmp_vec.y * 0.5 + 0.5)) * OScreen.height;
|
|
196
196
|
return tmp_vec;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
update_projection(camera)
|
|
200
200
|
{
|
|
201
|
-
camera.left = -
|
|
202
|
-
camera.right =
|
|
203
|
-
camera.top =
|
|
204
|
-
camera.bottom = -
|
|
205
|
-
camera.aspect =
|
|
201
|
+
camera.left = -OScreen.width / 2;
|
|
202
|
+
camera.right = OScreen.width / 2;
|
|
203
|
+
camera.top = OScreen.height / 2;
|
|
204
|
+
camera.bottom = -OScreen.height / 2;
|
|
205
|
+
camera.aspect = OScreen.aspect_ratio;
|
|
206
206
|
camera.updateProjectionMatrix(true);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -11,6 +11,8 @@ class ViewManager
|
|
|
11
11
|
this.transition_handler = new ViewStateTransitionHandler(this.transition_table);
|
|
12
12
|
|
|
13
13
|
this.view_change_subscribers = [];
|
|
14
|
+
|
|
15
|
+
this.browser_title_suffix = '';
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
update()
|
|
@@ -28,6 +30,7 @@ class ViewManager
|
|
|
28
30
|
if (change_url)
|
|
29
31
|
{
|
|
30
32
|
this.__change_browser_url(v.url);
|
|
33
|
+
this.__change_browser_title(v.url);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
this.notify_view_change(view_name);
|
|
@@ -81,6 +84,11 @@ class ViewManager
|
|
|
81
84
|
this.transition_handler.set_state(view);
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
set_browser_title_suffix(title_suffix)
|
|
88
|
+
{
|
|
89
|
+
this.browser_title_suffix = title_suffix;
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
get_current_view()
|
|
85
93
|
{
|
|
86
94
|
return this.transition_handler.current_state;
|
|
@@ -135,6 +143,13 @@ class ViewManager
|
|
|
135
143
|
window.history.pushState('', '', url);
|
|
136
144
|
}
|
|
137
145
|
|
|
146
|
+
__change_browser_title(name)
|
|
147
|
+
{
|
|
148
|
+
const title = this.__capitalize(name);
|
|
149
|
+
|
|
150
|
+
document.title = title ? `${title} | ${this.browser_title_suffix}` : this.browser_title_suffix;
|
|
151
|
+
}
|
|
152
|
+
|
|
138
153
|
__set_views_opacities()
|
|
139
154
|
{
|
|
140
155
|
for (let i = 0; i < this.views.length; i++)
|
|
@@ -142,6 +157,24 @@ class ViewManager
|
|
|
142
157
|
this.views[i].set_opacity(this.transition_handler.current_state_data);
|
|
143
158
|
}
|
|
144
159
|
}
|
|
160
|
+
|
|
161
|
+
__capitalize(string)
|
|
162
|
+
{
|
|
163
|
+
let aux_string = string.toUpperCase().replace('/', '');
|
|
164
|
+
aux_string = this.__snake_to_whitespace(aux_string);
|
|
165
|
+
|
|
166
|
+
return aux_string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
__snake_to_whitespace(string)
|
|
170
|
+
{
|
|
171
|
+
return string.replace(
|
|
172
|
+
/([-_][A-Z])/g,
|
|
173
|
+
(group) => group
|
|
174
|
+
.replace('-', ' ')
|
|
175
|
+
.replace('_', ' ')
|
|
176
|
+
);
|
|
177
|
+
}
|
|
145
178
|
}
|
|
146
179
|
|
|
147
180
|
export default new ViewManager();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class OScreen {
|
|
2
|
+
static init(): void;
|
|
3
|
+
static width: any;
|
|
4
|
+
static height: any;
|
|
5
|
+
static position: any;
|
|
6
|
+
static render_width: number;
|
|
7
|
+
static render_height: number;
|
|
8
|
+
static width_height: any;
|
|
9
|
+
static dpr: number;
|
|
10
|
+
static pixel_size: any;
|
|
11
|
+
static update_position(x: any, y: any): void;
|
|
12
|
+
static update_size(width: any, height: any): void;
|
|
13
|
+
static apply_pixel_density_v2(vector2: any): any;
|
|
14
|
+
static apply_pixel_density(value: any): number;
|
|
15
|
+
static get_pixel_size(): any;
|
|
16
|
+
static get aspect_ratio(): number;
|
|
17
|
+
static get portrait(): boolean;
|
|
18
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from './PerspectiveCamera';
|
|
|
27
27
|
export * from './RenderLoop';
|
|
28
28
|
export * from './SceneManager';
|
|
29
29
|
export * from './Screen';
|
|
30
|
+
export * from './OScreen';
|
|
30
31
|
export * from './canvas_drawer/SimpleTextDrawer';
|
|
31
32
|
export * from './Time';
|
|
32
33
|
export * from './UI';
|