ohzi-core 6.5.3 → 6.6.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/Time.js +1 -1
- 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/utilities/CameraUtilities.js +13 -13
- package/types/OScreen.d.ts +18 -0
- package/types/index.d.ts +1 -0
- package/types/resource_loader/AudioLoader.d.ts +1 -1
|
@@ -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,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
|
}
|
|
@@ -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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractLoader } from "./AbstractLoader";
|
|
2
2
|
|
|
3
3
|
export class AudioLoader extends AbstractLoader {
|
|
4
|
-
constructor(resource_id:
|
|
4
|
+
constructor(resource_id: string, url: string, loop: boolean, volume: number, size: number, positional: boolean);
|
|
5
5
|
loader: any;
|
|
6
6
|
loop: boolean;
|
|
7
7
|
volume: number;
|