Merge pull request #5469 from cocos-creator/3d-v1.0.0

Merge 3d v1.0.0 to 3d
This commit is contained in:
pandamicro
2019-09-26 10:57:15 +08:00
committed by GitHub
22 changed files with 273 additions and 237 deletions
+4
View File
@@ -2705,3 +2705,7 @@ Stencil manager does not support level bigger than %d in this device.
### 9001
Stencil manager is already empty, cannot pop any mask
### 9100
texture size exceeds current device limits %d/%d
File diff suppressed because one or more lines are too long
+13 -1
View File
@@ -111,6 +111,7 @@ export class CameraComponent extends Component {
protected _targetTexture: RenderTexture | null = null;
protected _camera: Camera | null = null;
protected _inEditorMode = false;
/**
* @en The projection type of the camera
@@ -336,6 +337,17 @@ export class CameraComponent extends Component {
}
}
get inEditorMode() {
return this._inEditorMode;
}
set inEditorMode(value) {
this._inEditorMode = value;
if (this._camera) {
this._camera.changeTargetWindow(value ? cc.director.root && cc.director.root.mainWindow : cc.director.root && cc.director.root.tempWindow);
}
}
public onLoad () {
cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH, this.onSceneChanged, this);
}
@@ -387,7 +399,7 @@ export class CameraComponent extends Component {
name: this.node.name,
node: this.node,
projection: this._projection,
window: cc.director.root && cc.director.root.tempWindow,
window: this._inEditorMode ? cc.director.root && cc.director.root.mainWindow : cc.director.root && cc.director.root.tempWindow,
priority: this._priority,
});
@@ -104,6 +104,8 @@ export class EditorCameraComponent extends CameraComponent {
public onLoad () {
super.onLoad();
this._inEditorMode = true;
}
public onEnable () {
@@ -125,9 +127,6 @@ export class EditorCameraComponent extends CameraComponent {
protected _createCamera () {
const priorCamera = this._camera;
super._createCamera();
if(this._camera){
this._camera.changeTargetWindow(cc.director.root.mainWindow);
}
if (this._camera !== priorCamera && this._camera) {
if (this._uiEditorCamera) {
+12 -12
View File
@@ -2,30 +2,30 @@
* @category animation
*/
import System from '../components/system';
import { ccclass } from '../data/class-decorator';
import { director, Director } from '../director';
import { errorID } from '../platform/debug';
import { MutableForwardIterator, remove } from '../utils/array';
import { Node } from '../scene-graph';
import { Scheduler } from '../scheduler';
import { MutableForwardIterator, remove } from '../utils/array';
import { AnimationBlendState } from './animation-blend-state';
import { AnimationState } from './animation-state';
import { CrossFade } from './cross-fade';
import { director, Director } from '../director';
import { Scheduler } from '../scheduler';
import System from '../components/system';
@ccclass
export class AnimationManager extends System {
private _anims = new MutableForwardIterator<AnimationState>([]);
private _delayEvents: Array<{target: Node; func: string; args: any[]; }> = [];
private _blendState: AnimationBlendState = new AnimationBlendState();
private _crossFades: CrossFade[] = [];
public static ID = 'animation';
public get blendState () {
return this._blendState;
}
public static ID = 'animation';
private _anims = new MutableForwardIterator<AnimationState>([]);
private _delayEvents: Array<{target: Node; func: string; args: any[]; }> = [];
private _blendState: AnimationBlendState = new AnimationBlendState();
private _crossFades: CrossFade[] = [];
public addCrossFade (crossFade: CrossFade) {
this._crossFades.push(crossFade);
}
@@ -88,8 +88,8 @@ export class AnimationManager extends System {
}
}
director.on(Director.EVENT_INIT, function () {
let animationManager = new AnimationManager();
director.on(Director.EVENT_INIT, () => {
const animationManager = new AnimationManager();
director.registerSystem(AnimationManager.ID, animationManager, Scheduler.PRIORITY_SYSTEM);
});
+4 -4
View File
@@ -38,9 +38,10 @@ import { programLib } from '../renderer/core/program-lib';
import { Asset } from './asset';
export interface IPropertyInfo {
type: number; // auto-extracted
type: number; // auto-extracted from shader
handleInfo?: [string, number, number]; // auto-generated from 'target'
samplerHash?: number; // auto-generated from 'sampler'
value?: number[] | string;
samplerHash?: number;
}
export interface IPassStates {
priority?: number;
@@ -54,7 +55,7 @@ export interface IPassStates {
phase?: string;
}
export interface IPassInfo extends IPassStates {
program: string; // auto-generated
program: string; // auto-generated from 'vert' and 'frag'
switch?: string;
properties?: Record<string, IPropertyInfo>;
}
@@ -93,7 +94,6 @@ export interface IShaderInfo {
defines: IDefineInfo[];
blocks: IBlockInfo[];
samplers: ISamplerInfo[];
dependencies: Record<string, string>;
}
export interface IPreCompileInfo {
[name: string]: boolean[] | number[] | string[];
@@ -43,6 +43,7 @@ import visibleRect from '../../platform/visible-rect';
import { CameraComponent } from '../../3d/framework/camera-component';
import { INode } from '../../utils/interfaces';
import { Enum } from '../../value-types';
import { game } from '../../game';
const _worldPos = new Vec3();
@@ -310,9 +311,9 @@ export class CanvasComponent extends Component {
this.node.getWorldPosition(_worldPos);
if (this._camera) {
const size = view.getVisibleSize();
const size = game.canvas!;
this._camera.resize(size.width, size.height);
this._camera.orthoHeight = this._camera.height / 2;
this._camera.orthoHeight = game.canvas!.height / view.getScaleY() / 2;
this._camera.node.setPosition(_worldPos.x, _worldPos.y, 999);
this._camera.update();
}
+8
View File
@@ -108,24 +108,32 @@ export enum GFXAttributeName {
* GFX数据类型。
*/
export enum GFXType {
// assumptions about the order of this enum: (exploited by other parts of the engine)
// * vectors always come before samplers
// * vectors with the same data type are always consecutive and in an ascending order component-wise
// * unknown is always zero
UNKNOWN,
// vectors
BOOL,
BOOL2,
BOOL3,
BOOL4,
INT,
INT2,
INT3,
INT4,
UINT,
UINT2,
UINT3,
UINT4,
FLOAT,
FLOAT2,
FLOAT3,
FLOAT4,
MAT2,
MAT2X3,
MAT2X4,
+35 -15
View File
@@ -1,4 +1,5 @@
import { CachedArray } from '../../memop/cached-array';
import { errorID } from '../../platform/debug';
import { GFXBufferSource, IGFXDrawInfo, IGFXIndirectBuffer } from '../buffer';
import {
GFXBindingType,
@@ -38,7 +39,6 @@ import { WebGLGFXDevice } from './webgl-device';
import { IWebGLGPUInputAssembler, IWebGLGPUUniform, WebGLAttrib, WebGLGPUBindingLayout,
WebGLGPUBuffer, WebGLGPUFramebuffer, WebGLGPUInput,
WebGLGPUPipelineState, WebGLGPUShader, WebGLGPUTexture, WebGLGPUUniformBlock, WebGLGPUUniformSampler } from './webgl-gpu-objects';
import { IWebGLTexUnit } from './webgl-state-cache';
function CmpF32NotEuqal (a: number, b: number): boolean {
const c = a - b;
@@ -778,12 +778,20 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W
gpuTexture.glFormat = GFXFormatToWebGLFormat(gpuTexture.format, gl);
gpuTexture.glType = GFXFormatToWebGLType(gpuTexture.format, gl);
let w = gpuTexture.width;
let h = gpuTexture.height;
switch (gpuTexture.viewType) {
case GFXTextureViewType.TV2D: {
gpuTexture.viewType = GFXTextureViewType.TV2D;
gpuTexture.glTarget = gl.TEXTURE_2D;
const maxSize = Math.max(w, h);
if (maxSize > device.maxTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
if (gpuTexture.samples === GFXSampleCount.X1) {
const glTexture = gl.createTexture();
if (glTexture && gpuTexture.size > 0) {
@@ -795,9 +803,6 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W
glTexUnit.glTexture = gpuTexture.glTexture;
}
let w = gpuTexture.width;
let h = gpuTexture.height;
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
@@ -846,6 +851,11 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W
gpuTexture.viewType = GFXTextureViewType.CUBE;
gpuTexture.glTarget = gl.TEXTURE_CUBE_MAP;
const maxSize = Math.max(w, h);
if (maxSize > device.maxCubeMapTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
const glTexture = gl.createTexture();
if (glTexture && gpuTexture.size > 0) {
gpuTexture.glTexture = glTexture;
@@ -858,8 +868,8 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0,
gpuTexture.glFormat, gpuTexture.glType, null);
@@ -870,8 +880,8 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W
} else {
if (gpuTexture.glInternelFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
const view: Uint8Array = new Uint8Array(imgSize);
@@ -936,11 +946,19 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W
gpuTexture.glFormat = GFXFormatToWebGLFormat(gpuTexture.format, gl);
gpuTexture.glType = GFXFormatToWebGLType(gpuTexture.format, gl);
let w = gpuTexture.width;
let h = gpuTexture.height;
switch (gpuTexture.viewType) {
case GFXTextureViewType.TV2D: {
gpuTexture.viewType = GFXTextureViewType.TV2D;
gpuTexture.glTarget = gl.TEXTURE_2D;
const maxSize = Math.max(w, h);
if (maxSize > device.maxTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
if (gpuTexture.samples === GFXSampleCount.X1) {
const glTexUnit = device.stateCache.glTexUnits[device.stateCache.texUnit];
@@ -949,9 +967,6 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W
glTexUnit.glTexture = gpuTexture.glTexture;
}
let w = gpuTexture.width;
let h = gpuTexture.height;
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
@@ -976,6 +991,11 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W
gpuTexture.viewType = GFXTextureViewType.CUBE;
gpuTexture.glTarget = gl.TEXTURE_CUBE_MAP;
const maxSize = Math.max(w, h);
if (maxSize > device.maxCubeMapTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
const glTexUnit = device.stateCache.glTexUnits[device.stateCache.texUnit];
if (glTexUnit.glTexture !== gpuTexture.glTexture) {
@@ -985,8 +1005,8 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
w = Math.max(1, w >> 1);
@@ -996,8 +1016,8 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W
} else {
if (gpuTexture.glInternelFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
const view: Uint8Array = new Uint8Array(imgSize);
+1 -7
View File
@@ -1,4 +1,4 @@
import { GFXStatus, GFXTextureViewType } from '../define';
import { GFXStatus } from '../define';
import { GFXDevice } from '../device';
import { GFXTextureView, IGFXTextureViewInfo } from '../texture-view';
import { WebGLGPUTextureView } from './webgl-gpu-objects';
@@ -47,12 +47,6 @@ export class WebGLGFXTextureView extends GFXTextureView {
levelCount: info.levelCount ? info.levelCount : 1,
};
const maxSizeLimit = this._type === GFXTextureViewType.CUBE ? this._device.maxCubeMapTextureSize : this._device.maxTextureSize;
const maxSize = Math.max(this._texture.width, this._texture.height);
if (maxSize > maxSizeLimit) {
console.warn(`texture size exceeds current device limits ${maxSize}/${maxSizeLimit}`);
}
this._status = GFXStatus.SUCCESS;
return true;
+35 -15
View File
@@ -1,4 +1,5 @@
import { CachedArray } from '../../memop/cached-array';
import { errorID } from '../../platform';
import { GFXBufferSource, IGFXDrawInfo, IGFXIndirectBuffer } from '../buffer';
import {
GFXBindingType,
@@ -51,7 +52,6 @@ import {
WebGL2GPUUniformBlock,
WebGL2GPUUniformSampler,
} from './webgl2-gpu-objects';
import { IWebGL2TexUnit } from './webgl2-state-cache';
const WebGLWraps: GLenum[] = [
WebGLRenderingContext.REPEAT,
@@ -959,11 +959,19 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
gpuTexture.glFormat = GFXFormatToWebGLFormat(gpuTexture.format, gl);
gpuTexture.glType = GFXFormatToWebGLType(gpuTexture.format, gl);
let w = gpuTexture.width;
let h = gpuTexture.height;
switch (gpuTexture.viewType) {
case GFXTextureViewType.TV2D: {
gpuTexture.viewType = GFXTextureViewType.TV2D;
gpuTexture.glTarget = gl.TEXTURE_2D;
const maxSize = Math.max(w, h);
if (maxSize > device.maxTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
if (gpuTexture.samples === GFXSampleCount.X1) {
const glTexture = gl.createTexture();
if (glTexture && gpuTexture.size > 0) {
@@ -975,9 +983,6 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
glTexUnit.glTexture = gpuTexture.glTexture;
}
let w = gpuTexture.width;
let h = gpuTexture.height;
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
@@ -1035,6 +1040,11 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
gpuTexture.viewType = GFXTextureViewType.CUBE;
gpuTexture.glTarget = gl.TEXTURE_CUBE_MAP;
const maxSize = Math.max(w, h);
if (maxSize > device.maxCubeMapTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
const glTexture = gl.createTexture();
if (glTexture && gpuTexture.size > 0) {
gpuTexture.glTexture = glTexture;
@@ -1047,8 +1057,8 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
w = Math.max(1, w >> 1);
@@ -1058,8 +1068,8 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
} else {
if (gpuTexture.glInternelFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
const view: Uint8Array = new Uint8Array(imgSize);
@@ -1125,11 +1135,19 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
gpuTexture.glFormat = GFXFormatToWebGLFormat(gpuTexture.format, gl);
gpuTexture.glType = GFXFormatToWebGLType(gpuTexture.format, gl);
let w = gpuTexture.width;
let h = gpuTexture.height;
switch (gpuTexture.viewType) {
case GFXTextureViewType.TV2D: {
gpuTexture.viewType = GFXTextureViewType.TV2D;
gpuTexture.glTarget = gl.TEXTURE_2D;
const maxSize = Math.max(w, h);
if (maxSize > device.maxTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
if (gpuTexture.samples === GFXSampleCount.X1) {
const glTexUnit = device.stateCache.glTexUnits[device.stateCache.texUnit];
@@ -1138,9 +1156,6 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
glTexUnit.glTexture = gpuTexture.glTexture;
}
let w = gpuTexture.width;
let h = gpuTexture.height;
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
@@ -1176,6 +1191,11 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
gpuTexture.viewType = GFXTextureViewType.CUBE;
gpuTexture.glTarget = gl.TEXTURE_CUBE_MAP;
const maxSize = Math.max(w, h);
if (maxSize > device.maxCubeMapTextureSize) {
errorID(9100, maxSize, device.maxTextureSize);
}
const glTexUnit = device.stateCache.glTexUnits[device.stateCache.texUnit];
if (glTexUnit.glTexture !== gpuTexture.glTexture) {
@@ -1185,8 +1205,8 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
if (!GFXFormatInfos[gpuTexture.format].isCompressed) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
w = Math.max(1, w >> 1);
@@ -1196,8 +1216,8 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
} else {
if (gpuTexture.glInternelFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) {
for (let f = 0; f < 6; ++f) {
let w = gpuTexture.width;
let h = gpuTexture.height;
w = gpuTexture.width;
h = gpuTexture.height;
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
const view: Uint8Array = new Uint8Array(imgSize);
+1 -7
View File
@@ -1,4 +1,4 @@
import { GFXStatus, GFXTextureViewType } from '../define';
import { GFXStatus } from '../define';
import { GFXDevice } from '../device';
import { GFXTextureView, IGFXTextureViewInfo } from '../texture-view';
import { WebGL2GPUTextureView } from './webgl2-gpu-objects';
@@ -47,12 +47,6 @@ export class WebGL2GFXTextureView extends GFXTextureView {
levelCount: info.levelCount ? info.levelCount : 1,
};
const maxSizeLimit = this._type === GFXTextureViewType.CUBE ? this._device.maxCubeMapTextureSize : this._device.maxTextureSize;
const maxSize = Math.max(this._texture.width, this._texture.height);
if (maxSize > maxSizeLimit) {
console.warn(`texture size exceeds current device limits ${maxSize}/${maxSizeLimit}`);
}
this._status = GFXStatus.SUCCESS;
return true;
+2 -2
View File
@@ -24,8 +24,8 @@
*/
// @ts-ignore
import * as debugInfos from '../../../DebugInfos';
const ERROR_MAP_URL = 'https://github.com/cocos-creator/engine/blob/master/EngineErrorMap.md';
import debugInfos from '../../../DebugInfos';
const ERROR_MAP_URL = 'https://github.com/cocos-creator/engine/blob/3d-v1.0.0/EngineErrorMap.md';
// The html element displays log in web page (DebugMode.INFO_FOR_WEB_PAGE)
let logList: HTMLTextAreaElement | null = null;
+10 -19
View File
@@ -27,11 +27,8 @@
import '../data/class';
import { EventTarget } from '../event/event-target';
import { Game } from '../game';
import { Rect, Size } from '../math';
import { director } from '../director';
let _currentFrame = 0;
import '../game';
class BrowserGetter {
@@ -91,6 +88,14 @@ switch (__BrowserGetter.adaptationType) {
case cc.sys.BROWSER_TYPE_SAFARI:
__BrowserGetter.meta['minimal-ui'] = 'true';
case cc.sys.BROWSER_TYPE_SOUGOU:
case cc.sys.BROWSER_TYPE_UC:
__BrowserGetter.availWidth = function(frame){
return frame.clientWidth;
};
__BrowserGetter.availHeight = function(frame){
return frame.clientHeight;
};
break;
case cc.sys.BROWSER_TYPE_WECHAT_GAME:
__BrowserGetter.availWidth = () => {
return window.innerWidth;
@@ -901,14 +906,6 @@ export class View extends EventTarget {
// Resize helper functions
private _resizeEvent () {
const frameId = director.getTotalFrames();
if (_currentFrame !== frameId) {
_currentFrame = frameId;
}
else {
// Avoid adapte multiple times in a frame
return;
}
// tslint:disable: no-shadowed-variable
let view;
if (this.setDesignResolutionSize) {
@@ -1249,7 +1246,7 @@ class ContentStrategy {
public _buildResult (containerW, containerH, contentW, contentH, scaleX, scaleY) {
// Makes content fit better the canvas
if ( Math.abs(containerW - contentW) < 2 ) {
contentW = containerW;
contentW = containerW;
}
if ( Math.abs(containerH - contentH) < 2 ) {
contentH = containerH;
@@ -1259,12 +1256,6 @@ class ContentStrategy {
Math.round((containerH - contentH) / 2),
contentW, contentH);
// Translate the content
if (cc.game.renderType === Game.RENDER_TYPE_CANVAS){
// TODO: modify something for setTransform
// game._renderContext.translate(viewport.x, viewport.y + contentH);
}
this._result.scale = [scaleX, scaleY];
this._result.viewport = viewport;
return this._result;
+7
View File
@@ -252,6 +252,13 @@ export class Pass {
return acc + (GFXGetTypeSize(cur.type) >> 2) * cur.count;
}, 0);
}
// store indirect property handles
for (const name of Object.keys(this._properties)) {
const prop = this._properties[name];
if (!prop.handleInfo) { continue; }
this._handleMap[name] = this.getHandle.apply(this, prop.handleInfo)!;
}
// store sampler handles
for (const u of this._shaderInfo.samplers) {
this._handleMap[u.name] = genHandle(GFXBindingType.SAMPLER, u.binding, u.type);
}
-13
View File
@@ -73,17 +73,6 @@ const prepareDefines = (defs: IDefineMap, tDefs: IDefineInfo[]) => {
return defines;
};
const validateDefines = (defines: IDefineValue[], device: GFXDevice, deps: Record<string, string>) => {
for (const info of defines) {
const name = info.name;
// fallback if extension dependency not supported
if (info.result !== '0' && deps[name] && !device[deps[name]]) {
console.warn(`${deps[name]} not supported on this platform, disabled ${name}`);
info.result = '0';
}
}
};
const getShaderInstanceName = (name: string, defs: IDefineValue[]) => {
return name + defs.reduce((acc, cur) => cur.result !== '0' ? `${acc}|${cur.name}${cur.result}` : acc, '');
};
@@ -137,7 +126,6 @@ class ProgramLib {
* { name: 'color', type: 'vec4', count: 1, size: 16 }], defines: [], size: 16 }
* ],
* samplers: [],
* dependencies: { 'USE_NORMAL_TEXTURE': 'OES_standard_derivatives' },
* };
* programLib.define(program);
* ```
@@ -244,7 +232,6 @@ class ProgramLib {
if (!tmpl.globalsInited) { insertBuiltinBindings(tmpl, pipeline.globalBindings, 'globals'); tmpl.globalsInited = true; }
const defs = prepareDefines(defines, tmpl.defines);
validateDefines(defs, device, tmpl.dependencies);
const customDef = defs.reduce((acc, cur) => {
return `${acc}#define ${cur.name} ${cur.result}\n`;
}, '');
+1 -1
View File
@@ -10,12 +10,12 @@ import { GFXUniformBlock } from '../../gfx/shader';
import { Mat4, Vec3 } from '../../math';
import Pool from '../../memop/pool';
import { IInternalBindingInst, UBOForwardLight, UBOLocal } from '../../pipeline/define';
import { Layers } from '../../scene-graph/layers';
import { INode } from '../../utils/interfaces';
import { Pass } from '../core/pass';
import { customizationManager } from './customization-manager';
import { RenderScene } from './render-scene';
import { SubModel } from './submodel';
import { Layers } from '../../scene-graph/layers';
const m4_1 = new Mat4();
+1
View File
@@ -65,6 +65,7 @@ export class UIMaterial {
this._material.copy(info.material);
this._pass = this._material.passes[0];
this._pass.update();
this._psos = new Pool(() => {
const pso = this._pass!.createPipelineState()!;
+12
View File
@@ -106,3 +106,15 @@ replaceProperty(Layers, 'Layers', [
targetName: 'Layers',
},
]);
removeProperty(Layers.Enum,'Layers.Enum',[
{
'name': 'ALWAYS',
}
]);
removeProperty(Layers.BitMask,'Layers.BitMask',[
{
'name': 'ALWAYS',
}
]);
-1
View File
@@ -40,7 +40,6 @@ const layerList = {
UI_2D : (1 << 25),
PROFILER : (1 << 28),
ALWAYS : (1 << 29),
DEFAULT : (1 << 30),
ALL : 0xffffffff,
};
+7 -7
View File
@@ -27,13 +27,13 @@
* @category core/value-types
*/
import * as js from '../utils/js';
import { value } from '../utils/js';
export function BitMask<T> (obj: T): T {
if ('__bitmask__' in obj) {
return obj;
}
js.value(obj, '__bitmask__', null, true);
value(obj, '__bitmask__', null, true);
let lastIndex: number = -1;
const keys: string[] = Object.keys(obj);
@@ -59,7 +59,7 @@ export function BitMask<T> (obj: T): T {
cc.errorID(7100, reverseKey);
continue;
}
js.value(obj, reverseKey, key);
value(obj, reverseKey, key);
}
}
return obj;
@@ -77,9 +77,9 @@ BitMask.getList = (BitMaskDef) => {
const bitlist: any[] = BitMaskDef.__bitmask__ = [];
// tslint:disable-next-line: forin
for (const name in BitMaskDef) {
const value = BitMaskDef[name];
if (Number.isInteger(value)) {
bitlist.push({ name, value });
const v = BitMaskDef[name];
if (Number.isInteger(v)) {
bitlist.push({ name, value: v });
}
}
bitlist.sort((a, b) => a.value - b.value);
@@ -90,7 +90,7 @@ export function ccbitmask (bitmaskx) {
if ('__bitmask__' in bitmaskx) {
return;
}
js.value(bitmaskx, '__bitmask__', null, true);
value(bitmaskx, '__bitmask__', null, true);
}
cc.BitMask = BitMask;
+7 -7
View File
@@ -28,7 +28,7 @@
* @category core/value-types
*/
import * as js from '../utils/js';
import { value } from '../utils/js';
/**
* @en
@@ -47,7 +47,7 @@ export function Enum<T> (obj: T): T {
if ('__enums__' in obj) {
return obj;
}
js.value(obj, '__enums__', null, true);
value(obj, '__enums__', null, true);
let lastIndex: number = -1;
const keys: string[] = Object.keys(obj);
@@ -74,7 +74,7 @@ export function Enum<T> (obj: T): T {
cc.errorID(7100, reverseKey);
continue;
}
js.value(obj, reverseKey, key);
value(obj, reverseKey, key);
}
}
return obj;
@@ -96,9 +96,9 @@ Enum.getList = (enumDef) => {
const enums: any[] = enumDef.__enums__ = [];
// tslint:disable-next-line: forin
for (const name in enumDef) {
const value = enumDef[name];
if (Number.isInteger(value)) {
enums.push({ name, value });
const v = enumDef[name];
if (Number.isInteger(v)) {
enums.push({ name, value: v });
}
}
enums.sort((a, b) => a.value - b.value);
@@ -122,7 +122,7 @@ export function ccenum (enumx) {
if ('__enums__' in enumx) {
return;
}
js.value(enumx, '__enums__', null, true);
value(enumx, '__enums__', null, true);
}
cc.Enum = Enum;