From 7e064c517e539a33653ced315c710e840fce9a9c Mon Sep 17 00:00:00 2001 From: Martin Valigursky Date: Tue, 11 Oct 2022 17:15:26 +0100 Subject: [PATCH] Moved PROJECTION_*** constants from /scene to /core/shape --- src/core/shape/constants.js | 13 +++++++++++++ src/core/shape/frustum.js | 2 +- src/deprecated/deprecated.js | 3 ++- src/framework/lightmapper/lightmapper.js | 4 +++- src/framework/parsers/glb-parser.js | 4 +++- src/index.js | 1 + src/scene/camera.js | 3 ++- src/scene/constants.js | 14 -------------- src/scene/renderer/forward-renderer.js | 3 ++- src/scene/renderer/light-camera.js | 3 ++- 10 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 src/core/shape/constants.js diff --git a/src/core/shape/constants.js b/src/core/shape/constants.js new file mode 100644 index 00000000000..ad90b854894 --- /dev/null +++ b/src/core/shape/constants.js @@ -0,0 +1,13 @@ +/** + * A perspective camera projection where the frustum shape is essentially pyramidal. + * + * @type {number} + */ +export const PROJECTION_PERSPECTIVE = 0; + + /** + * An orthographic camera projection where the frustum shape is essentially a cuboid. + * + * @type {number} + */ +export const PROJECTION_ORTHOGRAPHIC = 1; diff --git a/src/core/shape/frustum.js b/src/core/shape/frustum.js index d4b85d1df76..abbdc84cef8 100644 --- a/src/core/shape/frustum.js +++ b/src/core/shape/frustum.js @@ -1,5 +1,5 @@ import { Vec3 } from '../math/vec3.js'; -import { PROJECTION_PERSPECTIVE } from '../../scene/constants.js'; +import { PROJECTION_PERSPECTIVE } from './constants.js'; /** @typedef {import('../math/mat4.js').Mat4} Mat4 */ /** @typedef {import('./bounding-sphere.js').BoundingSphere} BoundingSphere */ diff --git a/src/deprecated/deprecated.js b/src/deprecated/deprecated.js index 5f6f157bf27..78ab822478c 100644 --- a/src/deprecated/deprecated.js +++ b/src/deprecated/deprecated.js @@ -10,6 +10,7 @@ import { Vec2 } from '../core/math/vec2.js'; import { Vec3 } from '../core/math/vec3.js'; import { Vec4 } from '../core/math/vec4.js'; +import { PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE } from '../core/shape/constants.js'; import { BoundingBox } from '../core/shape/bounding-box.js'; import { BoundingSphere } from '../core/shape/bounding-sphere.js'; import { Frustum } from '../core/shape/frustum.js'; @@ -52,7 +53,7 @@ import { VertexBuffer } from '../platform/graphics/vertex-buffer.js'; import { VertexFormat } from '../platform/graphics/vertex-format.js'; import { VertexIterator } from '../platform/graphics/vertex-iterator.js'; -import { PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE, LAYERID_IMMEDIATE, LINEBATCH_OVERLAY, LAYERID_WORLD } from '../scene/constants.js'; +import { LAYERID_IMMEDIATE, LINEBATCH_OVERLAY, LAYERID_WORLD } from '../scene/constants.js'; import { calculateTangents, createBox, createCapsule, createCone, createCylinder, createMesh, createPlane, createSphere, createTorus } from '../scene/procedural.js'; import { partitionSkin } from '../scene/skin-partition.js'; import { BasicMaterial } from '../scene/materials/basic-material.js'; diff --git a/src/framework/lightmapper/lightmapper.js b/src/framework/lightmapper/lightmapper.js index 80ca35a1f1b..eab25be0db3 100644 --- a/src/framework/lightmapper/lightmapper.js +++ b/src/framework/lightmapper/lightmapper.js @@ -6,6 +6,9 @@ import { Color } from '../../core/math/color.js'; import { Vec3 } from '../../core/math/vec3.js'; import { BoundingBox } from '../../core/shape/bounding-box.js'; +import { + PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE +} from '../../core/shape/constants.js'; import { ADDRESS_CLAMP_TO_EDGE, @@ -38,7 +41,6 @@ import { BAKE_COLORDIR, FOG_NONE, LIGHTTYPE_DIRECTIONAL, LIGHTTYPE_OMNI, LIGHTTYPE_SPOT, - PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE, SHADER_FORWARDHDR, SHADERDEF_DIRLM, SHADERDEF_LM, SHADERDEF_LMAMBIENT, MASK_BAKE, MASK_AFFECT_LIGHTMAPPED, diff --git a/src/framework/parsers/glb-parser.js b/src/framework/parsers/glb-parser.js index 0ec3157ad0a..b6161e480e0 100644 --- a/src/framework/parsers/glb-parser.js +++ b/src/framework/parsers/glb-parser.js @@ -10,6 +10,9 @@ import { Vec3 } from '../../core/math/vec3.js'; import { Color } from '../../core/math/color.js'; import { BoundingBox } from '../../core/shape/bounding-box.js'; +import { + PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE +} from '../../core/shape/constants.js'; import { typedArrayTypes, typedArrayTypesByteSize, @@ -30,7 +33,6 @@ import { VertexFormat } from '../../platform/graphics/vertex-format.js'; import { BLEND_NONE, BLEND_NORMAL, LIGHTFALLOFF_INVERSESQUARED, - PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE, ASPECT_MANUAL, ASPECT_AUTO, SPECOCC_AO } from '../../scene/constants.js'; diff --git a/src/index.js b/src/index.js index 2ed9906fed3..ed90a591eb5 100644 --- a/src/index.js +++ b/src/index.js @@ -45,6 +45,7 @@ export { Vec3 } from './core/math/vec3.js'; export { Vec4 } from './core/math/vec4.js'; // CORE / SHAPE +export * from './core/shape/constants.js'; export { BoundingBox } from './core/shape/bounding-box.js'; export { BoundingSphere } from './core/shape/bounding-sphere.js'; export { Frustum } from './core/shape/frustum.js'; diff --git a/src/scene/camera.js b/src/scene/camera.js index d7b94c4ba00..28692820127 100644 --- a/src/scene/camera.js +++ b/src/scene/camera.js @@ -5,9 +5,10 @@ import { Vec4 } from '../core/math/vec4.js'; import { math } from '../core/math/math.js'; import { Frustum } from '../core/shape/frustum.js'; +import { PROJECTION_PERSPECTIVE } from '../core/shape/constants.js'; import { - ASPECT_AUTO, PROJECTION_PERSPECTIVE, + ASPECT_AUTO, LAYERID_WORLD, LAYERID_DEPTH, LAYERID_SKYBOX, LAYERID_UI, LAYERID_IMMEDIATE } from './constants.js'; diff --git a/src/scene/constants.js b/src/scene/constants.js index 9489ce60b13..9b6497b5ad5 100644 --- a/src/scene/constants.js +++ b/src/scene/constants.js @@ -385,20 +385,6 @@ export const PARTICLEORIENTATION_WORLD = 1; */ export const PARTICLEORIENTATION_EMITTER = 2; -/** - * A perspective camera projection where the frustum shape is essentially pyramidal. - * - * @type {number} - */ -export const PROJECTION_PERSPECTIVE = 0; - -/** - * An orthographic camera projection where the frustum shape is essentially a cuboid. - * - * @type {number} - */ -export const PROJECTION_ORTHOGRAPHIC = 1; - /** * Render mesh instance as solid geometry. * diff --git a/src/scene/renderer/forward-renderer.js b/src/scene/renderer/forward-renderer.js index bccaf3f6d2a..3affb1c1c54 100644 --- a/src/scene/renderer/forward-renderer.js +++ b/src/scene/renderer/forward-renderer.js @@ -7,6 +7,7 @@ import { Vec3 } from '../../core/math/vec3.js'; import { Color } from '../../core/math/color.js'; import { BoundingSphere } from '../../core/shape/bounding-sphere.js'; +import { PROJECTION_ORTHOGRAPHIC } from '../../core/shape/constants.js'; import { CLEARFLAG_COLOR, CLEARFLAG_DEPTH, CLEARFLAG_STENCIL, @@ -34,7 +35,7 @@ import { MASK_AFFECT_LIGHTMAPPED, MASK_AFFECT_DYNAMIC, MASK_BAKE, SHADOWUPDATE_NONE, SORTKEY_DEPTH, SORTKEY_FORWARD, - VIEW_CENTER, SHADOWUPDATE_THISFRAME, LAYERID_DEPTH, PROJECTION_ORTHOGRAPHIC + VIEW_CENTER, SHADOWUPDATE_THISFRAME, LAYERID_DEPTH } from '../constants.js'; import { Material } from '../materials/material.js'; import { LightTextureAtlas } from '../lighting/light-texture-atlas.js'; diff --git a/src/scene/renderer/light-camera.js b/src/scene/renderer/light-camera.js index 160283c0cf8..0a85e6dbfff 100644 --- a/src/scene/renderer/light-camera.js +++ b/src/scene/renderer/light-camera.js @@ -2,7 +2,8 @@ import { Quat } from '../../core/math/quat.js'; import { Vec3 } from '../../core/math/vec3.js'; import { Mat4 } from '../../core/math/mat4.js'; -import { ASPECT_MANUAL, LIGHTTYPE_DIRECTIONAL, LIGHTTYPE_OMNI, LIGHTTYPE_SPOT, PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE } from '../constants.js'; +import { PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE } from '../../core/shape/constants.js'; +import { ASPECT_MANUAL, LIGHTTYPE_DIRECTIONAL, LIGHTTYPE_OMNI, LIGHTTYPE_SPOT } from '../constants.js'; import { Camera } from '../camera.js'; import { GraphNode } from '../graph-node.js';