Skip to content

Commit

Permalink
Merge pull request cocos#59 from minggo/fix_wrapper
Browse files Browse the repository at this point in the history
fix some wrapper
  • Loading branch information
minggo authored Nov 1, 2021
2 parents a733f57 + 1c281b0 commit 83da4e2
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 10 deletions.
9 changes: 2 additions & 7 deletions cocos/core/renderer/scene/camera.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
THE SOFTWARE.
*/

import { RenderWindow } from "../core/render-window";
import { ClearFlagBit } from "../../gfx";
import { RenderWindow } from '../core/render-window';
import { ClearFlagBit } from '../../gfx';

export enum CameraFOVAxis {
VERTICAL,
Expand Down Expand Up @@ -85,11 +85,6 @@ export enum CameraShutter {
D4000,
}

const FSTOPS: number[] = [1.8, 2.0, 2.2, 2.5, 2.8, 3.2, 3.5, 4.0, 4.5, 5.0, 5.6, 6.3, 7.1, 8.0, 9.0, 10.0, 11.0, 13.0, 14.0, 16.0, 18.0, 20.0, 22.0];
const SHUTTERS: number[] = [1.0, 1.0 / 2.0, 1.0 / 4.0, 1.0 / 8.0, 1.0 / 15.0, 1.0 / 30.0, 1.0 / 60.0, 1.0 / 125.0,
1.0 / 250.0, 1.0 / 500.0, 1.0 / 1000.0, 1.0 / 2000.0, 1.0 / 4000.0];
const ISOS: number[] = [100.0, 200.0, 400.0, 800.0];

export interface ICameraInfo {
name: string;
node: Node;
Expand Down
169 changes: 168 additions & 1 deletion cocos/core/renderer/scene/index.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,52 @@
THE SOFTWARE.
*/
import { legacyCC } from '../../global-exports';
import { Enum } from '../../value-types';

export type Ambient = jsb.Ambient;
export const Ambient = jsb.Ambient;
legacyCC.Ambient = Ambient;

/**
* Light related.
*/

// Color temperature (in Kelvin) to RGB
export function ColorTemperatureToRGB (rgb: Vec3, kelvin: number) {
if (kelvin < 1000.0) {
kelvin = 1000.0;
} else if (kelvin > 15000.0) {
kelvin = 15000.0;
}

// Approximate Planckian locus in CIE 1960 UCS
const kSqr = kelvin * kelvin;
const u = (0.860117757 + 1.54118254e-4 * kelvin + 1.28641212e-7 * kSqr) / (1.0 + 8.42420235e-4 * kelvin + 7.08145163e-7 * kSqr);
const v = (0.317398726 + 4.22806245e-5 * kelvin + 4.20481691e-8 * kSqr) / (1.0 - 2.89741816e-5 * kelvin + 1.61456053e-7 * kSqr);

const d = (2.0 * u - 8.0 * v + 4.0);
const x = (3.0 * u) / d;
const y = (2.0 * v) / d;
const z = (1.0 - x) - y;

const X = (1.0 / y) * x;
const Z = (1.0 / y) * z;

// XYZ to RGB with BT.709 primaries
rgb.x = 3.2404542 * X + -1.5371385 + -0.4985314 * Z;
rgb.y = -0.9692660 * X + 1.8760108 + 0.0415560 * Z;
rgb.z = 0.0556434 * X + -0.2040259 + 1.0572252 * Z;
}

export enum LightType {
DIRECTIONAL,
SPHERE,
SPOT,
UNKNOWN,
}

export const nt2lm = (size: number) => 4 * Math.PI * Math.PI * size * size;

export const DirectionalLight = jsb.DirectionalLight;
export type DirectionalLight = jsb.DirectionalLight;
legacyCC.DirectionalLight = jsb.DirectionalLight;
Expand All @@ -40,10 +81,124 @@ export const SphereLight = jsb.SphereLight;
export type SphereLight = jsb.SphereLight;
legacyCC.SphereLight = jsb.SphereLight;

/**
* Fog related.
*/

export const FogType = Enum({
/**
* @zh
* 线性雾。
* @en
* Linear fog
* @readonly
*/
LINEAR: 0,
/**
* @zh
* 指数雾。
* @en
* Exponential fog
* @readonly
*/
EXP: 1,
/**
* @zh
* 指数平方雾。
* @en
* Exponential square fog
* @readonly
*/
EXP_SQUARED: 2,
/**
* @zh
* 层叠雾。
* @en
* Layered fog
* @readonly
*/
LAYERED: 3,
});
export const FogInfo = jsb.FogInfo;
export type FogInfo = jsb.FogInfo;
export const Fog = jsb.Fog;
export type Fog = jsb.Fog;
legacyCC.Fog = Fog;

/**
* Shadows related.
*/

export const ShadowSize = Enum({
/**
* @zh 分辨率 256 * 256。
* @en shadow resolution 256 * 256.
* @readonly
*/
Low_256x256: 256,

/**
* @zh 分辨率 512 * 512。
* @en shadow resolution 512 * 512.
* @readonly
*/
Medium_512x512: 512,

/**
* @zh 分辨率 1024 * 1024。
* @en shadow resolution 1024 * 1024.
* @readonly
*/
High_1024x1024: 1024,

/**
* @zh 分辨率 2048 * 2048。
* @en shadow resolution 2048 * 2048.
* @readonly
*/
Ultra_2048x2048: 2048,
});
export const ShadowType = Enum({
/**
* @zh 平面阴影。
* @en Planar shadow
* @property Planar
* @readonly
*/
Planar: 0,

/**
* @zh 阴影贴图。
* @en Shadow type
* @property ShadowMap
* @readonly
*/
ShadowMap: 1,
});
export const PCFType = Enum({
/**
* @zh x1 次采样
* @en x1 times
* @readonly
*/
HARD: 0,

/**
* @zh 软阴影
* @en soft shadow
* @readonly
*/
SOFT: 1,

/**
* @zh 软阴影
* @en soft shadow
* @readonly
*/
SOFT_2X: 2,
});
export const ShadowsInfo = jsb.ShadowsInfo;
export type ShadowsInfo = jsb.ShadowsInfo;
export const Shadows = jsb.Shadow;
export type Shadows = jsb.Shadow;
legacyCC.Shadows = Shadows;
Expand All @@ -52,7 +207,19 @@ export const Skybox = jsb.Skybox;
export type Skybox = jsb.Skybox;
legacyCC.Skybox = Skybox;

export * from './camera';
/**
* Model related.
*/

export enum ModelType {
DEFAULT,
SKINNING,
BAKED_SKINNING,
BATCH_2D,
PARTICLE_BATCH,
LINE,
}
export * from './model';

export * from './render-scene';
export * from './submodel';
2 changes: 1 addition & 1 deletion cocos/core/renderer/scene/model.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
THE SOFTWARE.
*/

import { Attribute } from "../../gfx";
import { Attribute } from '../../gfx';

export interface IInstancedAttributeBlock {
buffer: Uint8Array;
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/renderer/scene/render-scene.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
THE SOFTWARE.
*/

import { Node } from "../../scene-graph";
import { Node } from '../../scene-graph';

export interface IRenderSceneInfo {
name: string;
Expand Down

0 comments on commit 83da4e2

Please sign in to comment.