Merge pull request #5890 from pandamicro/3d-v1.0.2

Merge 3d v1.0.2
This commit is contained in:
pandamicro
2019-12-12 17:10:25 +08:00
committed by GitHub
28 changed files with 236 additions and 204 deletions
+12 -12
View File
@@ -73,18 +73,6 @@ export class AudioClip extends Asset {
return super.destroy();
}
private _getPlayer (clip: any) {
let ctor: any;
if (typeof AudioBuffer !== 'undefined' && clip instanceof AudioBuffer) {
ctor = AudioPlayerWeb;
this._loadMode = AudioType.WEB_AUDIO;
} else {
ctor = AudioPlayerDOM;
this._loadMode = AudioType.DOM_AUDIO;
}
return ctor;
}
set _nativeAsset (clip: any) {
this._audio = clip;
if (clip) {
@@ -123,6 +111,18 @@ export class AudioClip extends Asset {
public getVolume () { if (this._player) { return this._player.getVolume(); } return 1; }
public setLoop (val: boolean) { if (this._player) { this._player.setLoop(val); } }
public getLoop () { if (this._player) { return this._player.getLoop(); } return false; }
private _getPlayer (clip: any) {
let ctor: any;
if (typeof AudioBuffer !== 'undefined' && clip instanceof AudioBuffer) {
ctor = AudioPlayerWeb;
this._loadMode = AudioType.WEB_AUDIO;
} else {
ctor = AudioPlayerDOM;
this._loadMode = AudioType.DOM_AUDIO;
}
return ctor;
}
}
cc.AudioClip = AudioClip;
+1 -1
View File
@@ -66,6 +66,7 @@ export class AudioPlayerWeb extends AudioPlayer {
};
this._do_play = () => {
this._state = PlayingState.PLAYING;
this._sourceNode = this._context.createBufferSource();
this._sourceNode.buffer = this._audio;
this._sourceNode.loop = this._loop;
@@ -75,7 +76,6 @@ export class AudioPlayerWeb extends AudioPlayer {
cc.director.once(cc.Director.EVENT_AFTER_UPDATE, () => {
this._sourceNode.start(0, this._offset);
this._eventTarget.emit('started');
this._state = PlayingState.PLAYING;
});
/* still not supported by all platforms *
this._sourceNode.onended = this._on_ended;
File diff suppressed because one or more lines are too long
@@ -113,6 +113,10 @@ export class CameraComponent extends Component {
protected _inEditorMode = false;
protected _flows: string[] | undefined = undefined;
get camera () {
return this._camera!;
}
/**
* @en The projection type of the camera
* @zh 相机的投影类型。
@@ -179,6 +179,9 @@ export class ModelComponent extends RenderableComponent {
}
public onEnable () {
if (!this._model) {
this._updateModels();
}
if (this._model) {
this._attachToScene();
}
+6 -4
View File
@@ -399,20 +399,22 @@ export class Mesh extends Asset {
const idxView = prim.indexView;
let dstStride = idxView.stride;
let dstSize = idxView.length;
if (dstStride === 4 && !gfxDevice.hasFeature(GFXFeature.ELEMENT_INDEX_UINT)) {
const vertexCount = this._struct.vertexBundles[prim.vertexBundelIndices[0]].view.count;
if (vertexCount >= 2 ** 16) {
warnID(10001, vertexCount, 2 ** 16);
if (vertexCount >= 65536) {
warnID(10001, vertexCount, 65536);
continue; // Ignore this primitive
} else {
dstStride = 2; // Reduce to short.
dstStride >>= 1; // Reduce to short.
dstSize >>= 1;
}
}
indexBuffer = gfxDevice.createBuffer({
usage: GFXBufferUsageBit.INDEX | GFXBufferUsageBit.TRANSFER_DST,
memUsage: GFXMemoryUsageBit.HOST | GFXMemoryUsageBit.DEVICE,
size: idxView.length,
size: dstSize,
stride: dstStride,
});
indexBuffers.push(indexBuffer);
+4 -5
View File
@@ -6,9 +6,9 @@ import { ccclass, property } from '../data/class-decorator';
import { GFXFormat } from '../gfx';
import { GFXDevice } from '../gfx/device';
import { GFXWindow } from '../gfx/window';
import { ccenum } from '../value-types/enum';
import { DepthStencilFormat, PixelFormat } from './asset-enum';
import { TextureBase } from './texture-base';
import { ccenum } from '../value-types/enum';
export interface IRenderTextureCreateInfo {
name?: string;
@@ -74,11 +74,11 @@ export class RenderTexture extends TextureBase {
if (info) {
this._width = info.width;
this._height = info.height;
if(info.colorFormat){
if (info.colorFormat){
this._format = info.colorFormat;
}
if(info.depthStencilFormat){
if (info.depthStencilFormat){
this._depthStencilFormat = info.depthStencilFormat;
}
@@ -136,7 +136,6 @@ export class RenderTexture extends TextureBase {
this._createWindow(device);
}
protected _createWindow (device: GFXDevice) {
const config = {
title: this.name,
@@ -147,7 +146,7 @@ export class RenderTexture extends TextureBase {
depthStencilFmt: this._depthStencilFormat as unknown as GFXFormat,
};
if(this._window){
if (this._window){
this._window.initialize(config);
return this._window;
}
@@ -35,7 +35,7 @@ import { director, Director } from '../../director';
import { game } from '../../game';
import { GFXClearFlag } from '../../gfx/define';
import { GFXWindow } from '../../gfx/window';
import { Color, Vec3 } from '../../math';
import { Color, Vec3, Rect } from '../../math';
import { ResolutionPolicy, view } from '../../platform/view';
import visibleRect from '../../platform/visible-rect';
import { Camera } from '../../renderer';
@@ -121,12 +121,12 @@ export class CanvasComponent extends Component {
/**
* @zh
* 渲染优先级。
* 相机排序优先级。当 RenderMode 为 intersperse 时,指定与其它相机的渲染顺序,当 RenderMode 为 overlay 时,指定跟其余 Canvas 做排序使用。需要对多 Canvas 设定 priority 以免出现不同平台下的闪屏问题。
*
* @param value - 渲染优先级。
*/
@property({
tooltip: '相机排序优先级。当 RenderMode 为 intersperse 时,指定与其它相机的渲染顺序,当 RenderMode 为 overlay 时,指定跟其余 Canvas 做排序使用',
tooltip: '相机排序优先级。当 RenderMode 为 intersperse 时,指定与其它相机的渲染顺序,当 RenderMode 为 overlay 时,指定跟其余 Canvas 做排序使用。需要对多 Canvas 设定 priority 以免出现不同平台下的闪屏问题。',
})
get priority () {
return this._priority;
@@ -228,6 +228,7 @@ export class CanvasComponent extends Component {
this._camera.fov = 45;
this._camera.clearFlag = this.clearFlag;
this._camera.farClip = 2000;
this._camera.viewport = new Rect(0, 0, 1, 1);
this.color = this._color;
const device = director.root!.device;
@@ -170,6 +170,7 @@ export class UIRenderComponent extends UIComponent {
type: Material,
displayOrder: 3,
tooltip:'源材质',
visible: false,
})
get sharedMaterial () {
return this._sharedMaterial;
+29 -13
View File
@@ -17,20 +17,36 @@ import { GFXShader } from './shader';
import { GFXTexture } from './texture';
import { GFXTextureView } from './texture-view';
export * from './binding-layout';
export * from './buffer';
export * from './command-allocator';
export * from './command-buffer';
export * from './define';
export * from './device';
export * from './framebuffer';
export * from './input-assembler';
export * from './pipeline-layout';
export * from './pipeline-state';
export * from './queue';
export * from './render-pass';
export * from './sampler';
export * from './shader';
export * from './texture-view';
export * from './texture';
export * from './window';
cc.GFXDevice = GFXDevice; export { GFXDevice };
cc.GFXBuffer = GFXBuffer; export { GFXBuffer };
cc.GFXTexture = GFXTexture; export { GFXTexture };
cc.GFXTextureView = GFXTextureView; export { GFXTextureView };
cc.GFXSampler = GFXSampler; export { GFXSampler };
cc.GFXShader = GFXShader; export { GFXShader };
cc.GFXInputAssembler = GFXInputAssembler; export { GFXInputAssembler };
cc.GFXRenderPass = GFXRenderPass; export { GFXRenderPass };
cc.GFXFramebuffer = GFXFramebuffer; export { GFXFramebuffer };
cc.GFXPipelineLayout = GFXPipelineLayout; export { GFXPipelineLayout };
cc.GFXPipelineState = GFXPipelineState; export { GFXPipelineState };
cc.GFXCommandBuffer = GFXCommandBuffer; export { GFXCommandBuffer };
cc.GFXQueue = GFXQueue; export { GFXQueue };
cc.GFXDevice = GFXDevice;
cc.GFXBuffer = GFXBuffer;
cc.GFXTexture = GFXTexture;
cc.GFXTextureView = GFXTextureView;
cc.GFXSampler = GFXSampler;
cc.GFXShader = GFXShader;
cc.GFXInputAssembler = GFXInputAssembler;
cc.GFXRenderPass = GFXRenderPass;
cc.GFXFramebuffer = GFXFramebuffer;
cc.GFXPipelineLayout = GFXPipelineLayout;
cc.GFXPipelineState = GFXPipelineState;
cc.GFXCommandBuffer = GFXCommandBuffer;
cc.GFXQueue = GFXQueue;
Object.assign(cc, GFXDefines);
+13 -3
View File
@@ -148,7 +148,6 @@ function GFXFormatToWebGLType (format: GFXFormat, gl: WebGLRenderingContext): GL
}
}
// tslint:disable: max-line-length
function GFXFormatToWebGLInternalFormat (format: GFXFormat, gl: WebGLRenderingContext): GLenum {
switch (format) {
case GFXFormat.A8: return gl.ALPHA;
@@ -192,7 +191,6 @@ function GFXFormatToWebGLInternalFormat (format: GFXFormat, gl: WebGLRenderingCo
}
}
}
// tslint:enable: max-line-length
function GFXFormatToWebGLFormat (format: GFXFormat, gl: WebGLRenderingContext): GLenum {
switch (format) {
@@ -792,7 +790,19 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W
errorID(9100, maxSize, device.maxTextureSize);
}
if (gpuTexture.samples === GFXSampleCount.X1) {
if (!device.WEBGL_depth_texture && GFXFormatInfos[gpuTexture.format].hasDepth) {
const glRenderbuffer = gl.createRenderbuffer();
if (glRenderbuffer && gpuTexture.size > 0) {
gpuTexture.glRenderbuffer = glRenderbuffer;
if (device.stateCache.glRenderbuffer !== gpuTexture.glRenderbuffer) {
gl.bindRenderbuffer(gl.RENDERBUFFER, gpuTexture.glRenderbuffer);
device.stateCache.glRenderbuffer = gpuTexture.glRenderbuffer;
}
gl.renderbufferStorage(gl.RENDERBUFFER, gpuTexture.glInternelFmt, w, h);
}
} else if (gpuTexture.samples === GFXSampleCount.X1) {
const glTexture = gl.createTexture();
if (glTexture && gpuTexture.size > 0) {
gpuTexture.glTexture = glTexture;
+1 -1
View File
@@ -5,7 +5,7 @@ import { WebGLCmdFuncCreateTexture, WebGLCmdFuncDestroyTexture, WebGLCmdFuncResi
import { WebGLGFXDevice } from './webgl-device';
import { WebGLGPUTexture } from './webgl-gpu-objects';
function IsPowerOf2 (x: number): boolean{
function IsPowerOf2 (x: number) {
return x > 0 && (x & (x - 1)) === 0;
}
+3
View File
@@ -73,6 +73,9 @@ export class RenderView {
public set priority (val: number) {
this._priority = val;
if (cc.director.root) {
cc.director.root.sortViews();
}
}
/**
+1
View File
@@ -123,3 +123,4 @@ class SamplerLib {
}
export const samplerLib = new SamplerLib();
cc.samplerLib = samplerLib;
+20 -11
View File
@@ -4,20 +4,29 @@ import config from './config';
const addStage = config.addStage;
export { addStage };
export * from './core/constants';
export * from './core/pass-utils';
export * from './core/pass';
export * from './core/program-lib';
export * from './core/sampler-lib';
export * from './core/texture-buffer-pool';
export { RenderQueue, PassStage } from './core/constants';
export { Pass } from './core/pass';
export { programLib } from './core/program-lib';
import { samplerLib } from './core/sampler-lib';
cc.samplerLib = samplerLib;
export { samplerLib };
export { Light } from './scene/light';
export { Camera } from './scene/camera';
export { Model } from './scene/model';
export { SkinningModel } from './models/skinning-model';
export * from './models/skeletal-animation-utils';
export * from './models/skinning-model';
export * from './scene/ambient';
export * from './scene/camera';
export * from './scene/customization-manager';
export * from './scene/deprecated';
export * from './scene/directional-light';
export * from './scene/light';
export * from './scene/model';
export * from './scene/planar-shadows';
export * from './scene/render-scene';
export * from './scene/skybox';
export * from './scene/sphere-light';
export * from './scene/spot-light';
export * from './scene/submodel';
import './scene/deprecated';
import './ui/render-data';
@@ -108,7 +108,7 @@ function uploadJointDataDQS (out: Float32Array, base: number, mat: Mat4, firstBo
}
function roundUpTextureSize (targetLength: number, formatSize: number) {
const minSize = 204;
const minSize = 480; // have to be multiples of 12
const formatScale = 4 / Math.sqrt(formatSize);
return Math.ceil(Math.max(minSize * formatScale, targetLength) / 12) * 12;
}
@@ -296,8 +296,8 @@ export class JointsAnimationInfo {
this._pool.delete(nodeID);
}
public get (nodeID: string) {
return this._pool.get(nodeID) || this.create(-1 as any);
public get (nodeID = '-1') {
return this._pool.get(nodeID) || this.create('-1');
}
public switchClip (info: IAnimInfo, clip: AnimationClip | null) {
+11 -13
View File
@@ -38,15 +38,15 @@ import { UBOSkinningAnimation, UBOSkinningTexture, UniformJointsTexture } from '
import { INode } from '../../utils/interfaces';
import { Pass } from '../core/pass';
import { samplerLib } from '../core/sampler-lib';
import { DataPoolManager } from '../data-pool-manager';
import { Model } from '../scene/model';
import { RenderScene } from '../scene/render-scene';
import { IAnimInfo, IJointsTextureHandle, jointsTextureSamplerHash, selectJointsMediumType } from './skeletal-animation-utils';
interface IJointsInfo {
buffer: GFXBuffer | null;
jointsTextureInfo: Float32Array;
texture: IJointsTextureHandle | null;
animInfo: IAnimInfo | null;
animInfo: IAnimInfo;
boundsInfo: aabb[] | null;
}
@@ -58,12 +58,16 @@ export class SkinningModel extends Model {
private _skeleton: Skeleton | null = null;
private _staticModelBounds: aabb | null = null;
private _mesh: Mesh | null = null;
private _dataPoolManager: DataPoolManager;
constructor () {
super();
this._type = 'skinning';
this._dataPoolManager = cc.director.root.dataPoolManager;
const jointsTextureInfo = new Float32Array(4);
this._jointsMedium = { buffer: null, jointsTextureInfo, texture: null, animInfo: null, boundsInfo: null };
const texture = this._dataPoolManager.jointsTexturePool.getDefaultJointsTexture();
const animInfo = this._dataPoolManager.jointsAnimationInfo.get();
this._jointsMedium = { buffer: null, jointsTextureInfo, texture, animInfo, boundsInfo: null };
}
public destroy () {
@@ -74,19 +78,13 @@ export class SkinningModel extends Model {
}
}
public attachToScene (scene: RenderScene) {
super.attachToScene(scene);
const texture = scene.root.dataPoolManager.jointsTexturePool.getDefaultJointsTexture();
this._jointsMedium.texture = texture;
}
public bindSkeleton (skeleton: Skeleton | null, skinningRoot: INode | null, mesh: Mesh | null) {
this._skeleton = skeleton;
this._mesh = mesh;
if (!skeleton || !skinningRoot || !mesh) { return; }
this._transform = skinningRoot;
this._jointsMedium.animInfo = cc.director.root.dataPoolManager.jointsAnimationInfo.get(skinningRoot.uuid);
if (!this._jointsMedium.buffer) {
this._jointsMedium.animInfo = this._dataPoolManager.jointsAnimationInfo.get(skinningRoot.uuid);
if (!this._jointsMedium.buffer) { // create buffer here so re-init after destroy could work
this._jointsMedium.buffer = this._device.createBuffer({
usage: GFXBufferUsageBit.UNIFORM | GFXBufferUsageBit.TRANSFER_DST,
memUsage: GFXMemoryUsageBit.HOST | GFXMemoryUsageBit.DEVICE,
@@ -124,7 +122,7 @@ export class SkinningModel extends Model {
public uploadAnimation (anim: AnimationClip | null) {
if (!this._skeleton || !this._mesh) { return; }
this.uploadedAnim = anim;
const resMgr = cc.director.root.dataPoolManager;
const resMgr = this._dataPoolManager;
const texture = anim ? resMgr.jointsTexturePool.getJointsTextureWithAnimation(this._skeleton, anim) :
resMgr.jointsTexturePool.getDefaultJointsTexture(this._skeleton);
resMgr.jointsAnimationInfo.switchClip(this._jointsMedium.animInfo!, anim);
@@ -136,7 +134,7 @@ export class SkinningModel extends Model {
protected _applyJointsTexture (texture: IJointsTextureHandle | null) {
if (!texture) { return; }
const oldTex = this._jointsMedium.texture;
if (oldTex && oldTex !== texture) { cc.director.root.dataPoolManager.jointsTexturePool.releaseHandle(oldTex); }
if (oldTex && oldTex !== texture) { this._dataPoolManager.jointsTexturePool.releaseHandle(oldTex); }
this._jointsMedium.texture = texture;
const { buffer, jointsTextureInfo } = this._jointsMedium;
jointsTextureInfo[0] = texture.handle.texture.width;
+2 -2
View File
@@ -103,7 +103,7 @@ export class PlanarShadows {
public updateSphereLight (light: SphereLight) {
light.node!.getWorldPosition(_v3);
const n = this._normal; const d = this._distance;
const n = this._normal; const d = this._distance + 0.001; // avoid z-fighting
const NdL = Vec3.dot(n, _v3);
const lx = _v3.x; const ly = _v3.y; const lz = _v3.z;
const nx = n.x; const ny = n.y; const nz = n.z;
@@ -131,7 +131,7 @@ export class PlanarShadows {
public updateDirLight (light: DirectionalLight) {
light.node!.getWorldRotation(_qt);
Vec3.transformQuat(_v3, _forward, _qt);
const n = this._normal; const d = this._distance;
const n = this._normal; const d = this._distance + 0.001; // avoid z-fighting
const NdL = Vec3.dot(n, _v3); const scale = 1 / NdL;
const lx = _v3.x * scale; const ly = _v3.y * scale; const lz = _v3.z * scale;
const nx = n.x; const ny = n.y; const nz = n.z;
+7 -5
View File
@@ -351,10 +351,6 @@ export class Root {
}
const views = this._views;
views.sort((a: RenderView, b: RenderView) => {
return a.priority - b.priority;
});
for (let i = 0; i < views.length; i++) {
const view = views[i];
if (view.isEnable && (view.window &&
@@ -458,7 +454,7 @@ export class Root {
view.initialize(info);
// view.camera.resize(cc.game.canvas.width, cc.game.canvas.height);
this._views.push(view);
this.sortViews();
return view;
}
@@ -546,4 +542,10 @@ export class Root {
}
}
}
public sortViews () {
this._views.sort((a: RenderView, b: RenderView) => {
return a.priority - b.priority;
});
}
}
-6
View File
@@ -7,12 +7,6 @@ import { replaceProperty, removeProperty } from '../utils/deprecated';
import { Layers } from './layers';
import { Node } from './node';
// js.get(BaseNode.prototype, 'childrenCount', function () {
// cc.warn("`childrenCount` is deprecated, please use `node.children.length` instead.");
// // @ts-ignore
// return this.children.length;
// });
replaceProperty(BaseNode.prototype, 'BaseNode', [
{
'name': 'childrenCount',
-35
View File
@@ -35,41 +35,6 @@ import * as misc from './misc';
* 用于处理文件与目录的路径的模块
*/
import * as path from './path';
import { replaceProperty } from './deprecated';
import * as math from '../math';
// replaceProperty(misc,'misc',[
// {
// name: 'clampf',
// newName: 'clamp',
// target: math,
// targetName: 'math'
// },
// {
// name: 'clamp01',
// newName: 'clamp01',
// target: math,
// targetName: 'math'
// },
// {
// name: 'lerp',
// newName: 'lerp',
// target: math,
// targetName: 'math'
// },
// {
// name: 'degreesToRadians',
// newName: 'toRadian',
// target: math,
// targetName: 'math'
// },
// {
// name: 'radiansToDegrees',
// newName: 'toDegree',
// target: math,
// targetName: 'math'
// },
// ]);
export * from './deprecated';
export * from './text-utils';
+18 -1
View File
@@ -80,6 +80,18 @@ export class PhysicsSystem extends System {
this._deltaTime = value;
}
/**
* @zh
* 获取或设置是否使用固定的时间步长进行模拟,默认为 true。
*/
get useFixedTime () {
return this._useFixedTime;
}
set useFixedTime (value: boolean) {
this._useFixedTime = value;
}
/**
* @zh
* 获取或设置物理世界的重力数值,默认为 (0, -10, 0)
@@ -135,6 +147,7 @@ export class PhysicsSystem extends System {
private _enable = true;
private _deltaTime = 1.0 / 60.0;
private _useFixedTime = true;
private _maxSubStep = 2;
// private _frameRate = 60;
// private _singleStep = false;
@@ -185,7 +198,11 @@ export class PhysicsSystem extends System {
director.emit(Director.EVENT_BEFORE_PHYSICS);
this._world.step(this._deltaTime, deltaTime, this._maxSubStep);
if (this._useFixedTime) {
this._world.step(this._deltaTime);
} else {
this._world.step(this._deltaTime, deltaTime, this._maxSubStep);
}
// if (this._singleStep) {
// this._enable = false;
// }
+2 -2
View File
@@ -1080,7 +1080,7 @@ export class LayoutComponent extends Component {
const newWidth = this._getHorizontalBaseWidth(this.node.children);
const fnPositionY = (child: INode) => {
const pos = this._isAlign ? this.node.position : child.position;
const pos = this._isAlign ? Vec3.ZERO : child.position;
return pos.y;
};
@@ -1091,7 +1091,7 @@ export class LayoutComponent extends Component {
const newHeight = this._getVerticalBaseHeight(this.node.children);
const fnPositionX = (child: INode) => {
const pos = this._isAlign ? this.node.position : child.position;
const pos = this._isAlign ? Vec3.ZERO : child.position;
return pos.x;
};
+4
View File
@@ -190,6 +190,10 @@ export class MaskComponent extends UIRenderComponent {
}
set segments (value) {
if(this._segments === value){
return;
}
this._segments = clamp(value, SEGEMENTS_MIN, SEGEMENTS_MAX);
this._updateGraphics();
}
+2 -2
View File
@@ -210,8 +210,8 @@ export class PageViewComponent extends ScrollViewComponent {
}
this._indicator = value;
if (this.indicator) {
this.indicator.setPageView(this);
if (this._indicator) {
this._indicator.setPageView(this);
}
}
@@ -120,24 +120,24 @@ export class UIStaticBatchComponent extends UIRenderComponent {
}
/**
* @zh 开始采集数据。调用时存储 ia 数据。
* @zh 开始采集数据标识。调用时存储 ia 数据。
* 注意:尽量不要频繁调用此接口,因为会清空原先存储的 ia 数据重新采集,会有一定内存损耗。
*/
@property({
tooltip: CC_DEV ? '点击采集数据': ''
tooltip: '开始采集数据标识',
})
get collect () {
return this._collect;
get collectMark () {
return this._collectMark;
}
set collect (value) {
set collectMark (value) {
const ui = this._getUI();
if (this._collect === value || !ui){
if (this._collectMark === value || !ui){
return;
}
this.node._static = false;
this._collect = true;
this._collectMark = true;
this._init = false;
if (!this._meshBuffer) {
@@ -147,36 +147,22 @@ export class UIStaticBatchComponent extends UIRenderComponent {
this._meshBuffer = buffer;
}
this._meshBuffer!.reset();
for (let i = 0; i < this._uiDrawBathcList.length; i++) {
const element = this._uiDrawBathcList[i];
element.destroy(ui);
}
this._uiDrawBathcList.length = 0;
this.clearData();
}
get drawBatchList (){
return this._uiDrawBathcList;
return this._uiDrawBatchList;
}
protected _init = false;
protected _meshBuffer: MeshBuffer | null = null;
protected _collect = false;
protected _collectMark = false;
private _lastMeshBuffer: MeshBuffer | null = null;
private _uiDrawBathcList: UIDrawBatch[] = [];
private _uiDrawBatchList: UIDrawBatch[] = [];
public onDestroy (){
super.onDestroy();
const ui = this._getUI();
if (ui) {
for (let i = 0; i < this._uiDrawBathcList.length; i++) {
const element = this._uiDrawBathcList[i];
element.destroy(ui);
}
}
this._uiDrawBathcList.length = 0;
this.clearData();
if(this._meshBuffer){
this._meshBuffer.destroy();
this._meshBuffer = null;
@@ -185,7 +171,7 @@ export class UIStaticBatchComponent extends UIRenderComponent {
public updateAssembler (render: UI) {
if (this._collect) {
if (this._collectMark) {
render.finishMergeBatches();
this._lastMeshBuffer = render.currBufferBatch;;
render.currBufferBatch = this._meshBuffer;
@@ -199,11 +185,11 @@ export class UIStaticBatchComponent extends UIRenderComponent {
}
public postUpdateAssembler (render: UI) {
if (this._collect) {
if (this._collectMark) {
render.finishMergeBatches();
render.currBufferBatch = this._lastMeshBuffer;
render.currStaticRoot = null;
this._collect = false;
this._collectMark = false;
this._init = true;
this.node._static = true;
@@ -214,10 +200,27 @@ export class UIStaticBatchComponent extends UIRenderComponent {
public requireDrawBatch (){
const batch = new UIDrawBatch();
batch.isStatic = true;
this._uiDrawBathcList.push(batch);
this._uiDrawBatchList.push(batch);
return batch;
}
public clearData(){
if(this._meshBuffer){
this._meshBuffer!.reset();
}
const ui = this._getUI();
if(ui){
for (let i = 0; i < this._uiDrawBatchList.length; i++) {
const element = this._uiDrawBatchList[i];
element.destroy(ui);
}
}
this._uiDrawBatchList.length = 0;
this._init = false;
}
protected _getUI (){
if(director.root && director.root.ui){
return director.root.ui;
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "cocos-creator-3d",
"version": "0.1.0",
"version": "1.0.2",
"description": "Cocos Creator 3D is a cross-platform 3D game engine written in Javascript, licensed under MIT.",
"homepage": "http://www.cocos.com",
"license": "MIT",
@@ -11,8 +11,8 @@
"scripts": {
"server": "http-server . -p 8002 -o http://127.0.0.1:8002/playground/index.html",
"build": "npm run build:min && npm run build-declaration",
"build:dev": "node ./rollup/out/build-engine-cli.js --sourcemap --platform=universal --physics=cannon --destination=./bin/cocos-3d.dev.js",
"build:min": "node ./rollup/out/build-engine-cli.js --compress --sourcemap --platform=universal --physics=cannon --destination=./bin/cocos3d-js.min.js",
"build:dev": "node ./rollup/out/build-engine-cli.js --sourcemap --buildmode=universal --platform=HTML5 --physics=cannon --destination=./bin/cocos-3d.dev.js",
"build:min": "node ./rollup/out/build-engine-cli.js --compress --sourcemap --buildmode=universal --platform=HTML5 --physics=cannon --destination=./bin/cocos3d-js.min.js",
"build-declaration": "node ./scripts/generate-declarations/generate-declarations-cli.js",
"build-rollup": "tsc --build rollup/tsconfig.json",
"postinstall": "npm run build-rollup",
+1 -1
View File
@@ -218,7 +218,7 @@ if (CC_DEV) {
* If you post a bug to forum, please attach this flag.
* @property {String} ENGINE_VERSION
*/
const engineVersion = '1.0.1';
const engineVersion = '1.0.2';
_global['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
export default cc;