From 283123ec20a5403ade7dcb3878595c352801d4c1 Mon Sep 17 00:00:00 2001 From: JoneLau <32630749+JoneLau@users.noreply.github.com> Date: Thu, 26 Sep 2019 18:48:57 +0800 Subject: [PATCH 01/33] adjust code and fix inertia (#5470) --- cocos/ui/components/scroll-view-component.ts | 127 ++++++++----------- 1 file changed, 54 insertions(+), 73 deletions(-) diff --git a/cocos/ui/components/scroll-view-component.ts b/cocos/ui/components/scroll-view-component.ts index 4b1607914e..21353039f2 100644 --- a/cocos/ui/components/scroll-view-component.ts +++ b/cocos/ui/components/scroll-view-component.ts @@ -31,7 +31,7 @@ import { EventHandler as ComponentEventHandler } from '../../core/components'; import { ccclass, executionOrder, menu, property } from '../../core/data/class-decorator'; import { Event } from '../../core/event'; -import { EventMouse, EventTouch, SystemEventType, Touch } from '../../core/platform'; +import { EventMouse, EventTouch, Touch } from '../../core/platform'; import { Size, Vec2, Vec3 } from '../../core/math'; import { ccenum } from '../../core/value-types/enum'; import { LayoutComponent } from './layout-component'; @@ -41,16 +41,16 @@ import { INode } from '../../core/utils/interfaces'; import { Node } from '../../core/scene-graph/node'; import { director, Director } from '../../core/director'; -const NodeEvent = SystemEventType; - const NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED = 5; const OUT_OF_BOUNDARY_BREAKING_FACTOR = 0.05; const EPSILON = 1e-4; const MOVEMENT_FACTOR = 0.7; const ZERO = new Vec3(); const _tempPos = new Vec3(); +const _tempVec2 = new Vec2(); +const _tempVec2_1 = new Vec2(); -const quintEaseOut = (time) => { +const quintEaseOut = (time: number) => { time -= 1; return (time * time * time * time * time + 1); }; @@ -302,7 +302,7 @@ export class ScrollViewComponent extends ViewGroupComponent { protected _autoScrolling = false; protected _scrolling = false; @property - private _content: INode | null = null; + protected _content: INode | null = null; @property protected _horizontalScrollBar: ScrollBarComponent | null = null; @property @@ -768,12 +768,12 @@ export class ScrollViewComponent extends ViewGroupComponent { if (!CC_EDITOR) { this._registerEvent(); if (this.content) { - this.content.on(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); - this.content.on(NodeEvent.SCALE_PART, this._calculateBoundary, this); + this.content.on(Node.EventType.SIZE_CHANGED, this._calculateBoundary, this); + this.content.on(Node.EventType.SCALE_PART, this._calculateBoundary, this); if (this.view!) { - this.view!.on(NodeEvent.POSITION_PART, this._calculateBoundary, this); - this.view!.on(NodeEvent.SCALE_PART, this._calculateBoundary, this); - this.view!.on(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); + this.view!.on(Node.EventType.POSITION_PART, this._calculateBoundary, this); + this.view!.on(Node.EventType.SCALE_PART, this._calculateBoundary, this); + this.view!.on(Node.EventType.SIZE_CHANGED, this._calculateBoundary, this); } } } @@ -790,12 +790,12 @@ export class ScrollViewComponent extends ViewGroupComponent { if (!CC_EDITOR) { this._unregisterEvent(); if (this.content) { - this.content.off(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); - this.content.off(NodeEvent.SCALE_PART, this._calculateBoundary, this); + this.content.off(Node.EventType.SIZE_CHANGED, this._calculateBoundary, this); + this.content.off(Node.EventType.SCALE_PART, this._calculateBoundary, this); if (this.view!) { - this.view!.off(NodeEvent.POSITION_PART, this._calculateBoundary, this); - this.view!.off(NodeEvent.SCALE_PART, this._calculateBoundary, this); - this.view!.off(NodeEvent.SIZE_CHANGED, this._calculateBoundary, this); + this.view!.off(Node.EventType.POSITION_PART, this._calculateBoundary, this); + this.view!.off(Node.EventType.SCALE_PART, this._calculateBoundary, this); + this.view!.off(Node.EventType.SIZE_CHANGED, this._calculateBoundary, this); } } } @@ -805,29 +805,22 @@ export class ScrollViewComponent extends ViewGroupComponent { // private methods protected _registerEvent () { - this.node.on(NodeEvent.TOUCH_START, this._onTouchBegan, this, true); - this.node.on(NodeEvent.TOUCH_MOVE, this._onTouchMoved, this, true); - this.node.on(NodeEvent.TOUCH_END, this._onTouchEnded, this, true); - this.node.on(NodeEvent.TOUCH_CANCEL, this._onTouchCancelled, this, true); - this.node.on(NodeEvent.MOUSE_WHEEL, this._onMouseWheel, this, true); + this.node.on(Node.EventType.TOUCH_START, this._onTouchBegan, this, true); + this.node.on(Node.EventType.TOUCH_MOVE, this._onTouchMoved, this, true); + this.node.on(Node.EventType.TOUCH_END, this._onTouchEnded, this, true); + this.node.on(Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this, true); + this.node.on(Node.EventType.MOUSE_WHEEL, this._onMouseWheel, this, true); } protected _unregisterEvent () { - this.node.off(NodeEvent.TOUCH_START, this._onTouchBegan, this, true); - this.node.off(NodeEvent.TOUCH_MOVE, this._onTouchMoved, this, true); - this.node.off(NodeEvent.TOUCH_END, this._onTouchEnded, this, true); - this.node.off(NodeEvent.TOUCH_CANCEL, this._onTouchCancelled, this, true); - this.node.off(NodeEvent.MOUSE_WHEEL, this._onMouseWheel, this, true); + this.node.off(Node.EventType.TOUCH_START, this._onTouchBegan, this, true); + this.node.off(Node.EventType.TOUCH_MOVE, this._onTouchMoved, this, true); + this.node.off(Node.EventType.TOUCH_END, this._onTouchEnded, this, true); + this.node.off(Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this, true); + this.node.off(Node.EventType.MOUSE_WHEEL, this._onMouseWheel, this, true); } - /** - * @zh - * 鼠标滚轮事件。 - * - * @param event - 鼠标事件信息。 - * @param captureListeners - */ - protected _onMouseWheel (event: EventMouse, captureListeners?: any) { + protected _onMouseWheel (event: EventMouse, captureListeners?: INode[]) { if (!this.enabledInHierarchy) { return; } @@ -857,8 +850,7 @@ export class ScrollViewComponent extends ViewGroupComponent { this._stopPropagationIfTargetIsMe(event); } - // touch event handler - protected _onTouchBegan (event: EventTouch, captureListeners?: any) { + protected _onTouchBegan (event: EventTouch, captureListeners?: INode[]) { if (!this.enabledInHierarchy || !this._content) { return; } if (this._hasNestedViewGroup(event, captureListeners)) { return; } @@ -870,15 +862,11 @@ export class ScrollViewComponent extends ViewGroupComponent { this._stopPropagationIfTargetIsMe(event); } - protected _onTouchMoved (event: EventTouch, captureListeners?: any) { + protected _onTouchMoved (event: EventTouch, captureListeners?: INode[]) { if (!this.enabledInHierarchy || !this._content) { return; } if (this._hasNestedViewGroup(event, captureListeners)) { return; } - if (!event || !event.touch) { - return; - } - - const touch = event.touch; + const touch = event.touch!; if (this._content) { this._handleMoveLogic(touch); } @@ -887,14 +875,14 @@ export class ScrollViewComponent extends ViewGroupComponent { return; } - const deltaMove = new Vec2(touch.getUILocation()); - deltaMove.subtract(touch.getUIStartLocation()); + const deltaMove = touch.getUILocation(_tempVec2); + deltaMove.subtract(touch.getUIStartLocation(_tempVec2_1)); // FIXME: touch move delta should be calculated by DPI. if (deltaMove.length() > 7) { if (!this._touchMoved && event.target !== this.node) { // Simulate touch cancel for target node const cancelEvent = new EventTouch(event.getTouches(), event.bubbles); - cancelEvent.type = NodeEvent.TOUCH_CANCEL; + cancelEvent.type = Node.EventType.TOUCH_CANCEL; cancelEvent.touch = event.touch; cancelEvent.simulate = true; (event.target as INode)!.dispatchEvent(cancelEvent); @@ -904,13 +892,13 @@ export class ScrollViewComponent extends ViewGroupComponent { this._stopPropagationIfTargetIsMe(event); } - protected _onTouchEnded (event: EventTouch, captureListeners?: any) { + protected _onTouchEnded (event: EventTouch, captureListeners?: INode[]) { if (!this.enabledInHierarchy || !this._content || !event) { return; } if (this._hasNestedViewGroup(event, captureListeners)) { return; } this._dispatchEvent('touch-up'); - const touch = event.touch; + const touch = event.touch!; if (this._content) { this._handleReleaseLogic(touch); } @@ -921,13 +909,13 @@ export class ScrollViewComponent extends ViewGroupComponent { } } - protected _onTouchCancelled (event: EventTouch, captureListeners?: any) { + protected _onTouchCancelled (event: EventTouch, captureListeners?: INode[]) { if (!this.enabledInHierarchy || !this._content) { return; } if (this._hasNestedViewGroup(event, captureListeners)) { return; } // Filte touch cancel event send from self if (event && !event.simulate) { - const touch = event.touch; + const touch = event.touch!; if (this._content) { this._handleReleaseLogic(touch); } @@ -935,14 +923,10 @@ export class ScrollViewComponent extends ViewGroupComponent { this._stopPropagationIfTargetIsMe(event); } - /** - * @zh - * 重新计算内容活动边界(view) - */ protected _calculateBoundary () { if (this.content) { // refresh content size - const layout:LayoutComponent = this.content.getComponent(LayoutComponent); + const layout: LayoutComponent = this.content.getComponent(LayoutComponent); if (layout && layout.enabledInHierarchy) { layout.updateLayout(); } @@ -962,8 +946,7 @@ export class ScrollViewComponent extends ViewGroupComponent { } - // this is for nested scrollview - protected _hasNestedViewGroup (event?: Event, captureListeners?: any) { + protected _hasNestedViewGroup (event: Event, captureListeners?: INode[]) { if (!event || event.eventPhase !== Event.CAPTURING_PHASE) { return; } @@ -971,7 +954,7 @@ export class ScrollViewComponent extends ViewGroupComponent { if (captureListeners) { // captureListeners are arranged from child to parent for (const listerner of captureListeners) { - const item = listerner as INode; + const item = listerner; if (this.node === item) { if (event.target && (event.target as INode).getComponent(ViewGroupComponent)) { @@ -988,7 +971,7 @@ export class ScrollViewComponent extends ViewGroupComponent { return false; } - protected _handleReleaseLogic (touch) { + protected _handleReleaseLogic (touch: Touch) { const delta = touch.getUIDelta(); Vec3.set(this._deltaPos, delta.x, delta.y, 0); this._gatherTouchMove(this._deltaPos); @@ -1059,7 +1042,7 @@ export class ScrollViewComponent extends ViewGroupComponent { this._startAutoScroll(targetDelta, time, true); } - protected _calculateAutoScrollTimeByInitalSpeed (initalSpeed) { + protected _calculateAutoScrollTimeByInitalSpeed (initalSpeed: number) { return Math.sqrt(Math.sqrt(initalSpeed / 5)); } @@ -1202,7 +1185,7 @@ export class ScrollViewComponent extends ViewGroupComponent { } } - protected _dispatchEvent (event) { + protected _dispatchEvent (event: string) { if (event === 'scroll-ended') { this._scrollEventEmitMask = 0; @@ -1230,11 +1213,11 @@ export class ScrollViewComponent extends ViewGroupComponent { this._outOfBoundaryAmountDirty = true; if (this._isOutOfBoundary()) { - const outOfBoundary = this._getHowMuchOutOfBoundary(new Vec3()); - const newPosition = new Vec3(this.getContentPosition()); - newPosition.add(outOfBoundary); + const outOfBoundary = this._getHowMuchOutOfBoundary(); + _tempPos.set(this.getContentPosition()); + _tempPos.add(outOfBoundary); if (this._content) { - this._content.setPosition(newPosition); + this._content.setPosition(_tempPos); // this._updateScrollBar(0); this._updateScrollBar(ZERO); } @@ -1262,8 +1245,8 @@ export class ScrollViewComponent extends ViewGroupComponent { } // This is for Scrollview as children of a Button - protected _stopPropagationIfTargetIsMe (event?: Event) { - if (event && event.eventPhase === Event.AT_TARGET && event.target === this.node) { + protected _stopPropagationIfTargetIsMe (event: Event) { + if (event.eventPhase === Event.AT_TARGET && event.target === this.node) { event.propagationStopped = true; } } @@ -1346,6 +1329,7 @@ export class ScrollViewComponent extends ViewGroupComponent { if (this._autoScrolling) { this._dispatchEvent('scroll-ended'); } + this._autoScrolling = false; this._isBouncing = false; @@ -1370,14 +1354,15 @@ export class ScrollViewComponent extends ViewGroupComponent { } protected _gatherTouchMove (delta: Vec3) { - delta = this._clampDelta(delta); + const clampDt = delta.clone(); + this._clampDelta(clampDt); while (this._touchMoveDisplacements.length >= NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED) { this._touchMoveDisplacements.shift(); this._touchMoveTimeDeltas.shift(); } - this._touchMoveDisplacements.push(delta); + this._touchMoveDisplacements.push(clampDt); const timeStamp = getTimeInMilliseconds(); this._touchMoveTimeDeltas.push((timeStamp - this._touchMovePreviousTimestamp) / 1000); @@ -1555,12 +1540,6 @@ export class ScrollViewComponent extends ViewGroupComponent { return moveDelta; } - /** - * @zh - * - * - * @param scrollViewSize - 可视区域尺寸。 - */ protected _moveContentToTopLeft (scrollViewSize: Size) { const contentSize = this._content!.getContentSize(); @@ -1572,6 +1551,7 @@ export class ScrollViewComponent extends ViewGroupComponent { let leftDeta = this._getContentLeftBoundary() - this._leftBoundary; leftDeta = -leftDeta; + // 是否限制在上视区上边 if (contentSize.height < scrollViewSize.height) { totalScrollDelta = contentSize.height - scrollViewSize.height; moveDelta.y = bottomDeta - totalScrollDelta; @@ -1585,6 +1565,7 @@ export class ScrollViewComponent extends ViewGroupComponent { } } + // 是否限制在上视区左边 if (contentSize.width < scrollViewSize.width) { totalScrollDelta = contentSize.width - scrollViewSize.width; moveDelta.x = leftDeta; From 607824a963fd163d71346e56735c4a46db732929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Wed, 9 Oct 2019 17:40:07 +0800 Subject: [PATCH 02/33] expose some type definitions (#5455) --- .eslintrc.json | 2 +- .../batched-skinning-model-component.ts | 4 +- cocos/core/3d/misc/utils.ts | 8 +- cocos/core/animation/animation-clip.ts | 44 +++-- .../core/animation/skeletal-animation-clip.ts | 4 +- cocos/core/assets/mesh.ts | 178 +++++++++--------- cocos/core/assets/utils/buffer-view.ts | 31 --- 7 files changed, 126 insertions(+), 145 deletions(-) delete mode 100644 cocos/core/assets/utils/buffer-view.ts diff --git a/.eslintrc.json b/.eslintrc.json index 649d702cb5..aaad307de7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -92,7 +92,7 @@ }], "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-misused-promises": "error", - "@typescript-eslint/no-namespace": "error", + "@typescript-eslint/no-namespace": "off", "@typescript-eslint/no-non-null-assertion": "warn", "@typescript-eslint/no-parameter-properties": "off", "@typescript-eslint/no-require-imports": "error", diff --git a/cocos/core/3d/framework/batched-skinning-model-component.ts b/cocos/core/3d/framework/batched-skinning-model-component.ts index f183f245bc..17addea0ef 100644 --- a/cocos/core/3d/framework/batched-skinning-model-component.ts +++ b/cocos/core/3d/framework/batched-skinning-model-component.ts @@ -28,7 +28,7 @@ import { Filter, PixelFormat } from '../../assets/asset-enum'; import { Material } from '../../assets/material'; -import { IMeshStruct, Mesh } from '../../assets/mesh'; +import { Mesh } from '../../assets/mesh'; import { Skeleton } from '../../assets/skeleton'; import { Texture2D } from '../../assets/texture-2d'; import { ccclass, executeInEditMode, executionOrder, menu, property } from '../../data/class-decorator'; @@ -256,7 +256,7 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent { // add batch ID to this temp mesh // first, update bookkeepping - const newMeshStruct: IMeshStruct = JSON.parse(JSON.stringify(unit.mesh.struct)); + const newMeshStruct: Mesh.Struct = JSON.parse(JSON.stringify(unit.mesh.struct)); let newOffset = 0; for (const vb of newMeshStruct.vertexBundles) { vb.attributes.push(batch_id); diff --git a/cocos/core/3d/misc/utils.ts b/cocos/core/3d/misc/utils.ts index 2519585f7b..2f8458a723 100644 --- a/cocos/core/3d/misc/utils.ts +++ b/cocos/core/3d/misc/utils.ts @@ -1,7 +1,7 @@ import { GFXAttributeName, GFXFormat, GFXFormatInfos, GFXFormatType, GFXPrimitiveMode, IGFXFormatInfo } from '../../gfx/define'; export { find } from '../../scene-graph/find'; -import { IMeshStruct, IPrimitive, IVertexBundle, Mesh } from '../../assets/mesh'; +import { Mesh } from '../../assets/mesh'; import { Skeleton } from '../../assets/skeleton'; import { aabb } from '../../geom-utils'; import { IGFXAttribute } from '../../gfx/input-assembler'; @@ -156,7 +156,7 @@ export function createMesh (geometry: IGeometry, out?: Mesh, options?: ICreateMe writeBuffer(vertexBufferView, channel.data, channel.attribute.format, channel.offset, stride); } bufferBlob.setNextAlignment(0); - const vertexBundle: IVertexBundle = { + const vertexBundle: Mesh.VertexBundle = { attributes, view: { offset: bufferBlob.getLength(), @@ -180,7 +180,7 @@ export function createMesh (geometry: IGeometry, out?: Mesh, options?: ICreateMe } // Create primitive. - const primitive: IPrimitive = { + const primitive: Mesh.Submesh = { primitiveMode: geometry.primitiveMode || GFXPrimitiveMode.TRIANGLE_LIST, vertexBundelIndices: [0], }; @@ -229,7 +229,7 @@ export function createMesh (geometry: IGeometry, out?: Mesh, options?: ICreateMe } // Create mesh struct. - const meshStruct: IMeshStruct = { + const meshStruct: Mesh.Struct = { vertexBundles: [vertexBundle], primitives: [primitive], }; diff --git a/cocos/core/animation/animation-clip.ts b/cocos/core/animation/animation-clip.ts index c134a96424..7372c7f9a4 100644 --- a/cocos/core/animation/animation-clip.ts +++ b/cocos/core/animation/animation-clip.ts @@ -13,18 +13,6 @@ import { INode } from '../utils/interfaces'; import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; import { TargetModifier, HierachyModifier, ComponentModifier, isCustomTargetModifier, PropertyModifier, isPropertyModifier } from './target-modifier'; -export interface ITargetCurveData { - modifiers: TargetModifier[]; - valueAdapter?: CurveValueAdapter; - data: IPropertyCurveData; -} - -interface IAnimationEventData { - frame: number; - func: string; - params: string[]; -} - export interface IObjectCurveData { [propertyName: string]: IPropertyCurveData; } @@ -38,10 +26,6 @@ export interface INodeCurveData { comps?: IComponentsCurveData; } -export interface ICurveData { - [path: string]: INodeCurveData; -} - export interface IRuntimeCurve { /** * 属性曲线。 @@ -73,6 +57,26 @@ export interface IAnimationEventGroup { events: IAnimationEvent[]; } +export declare namespace AnimationClip { + export interface ICurveData { + [path: string]: INodeCurveData; + } + + export type PropertyCurveData = IPropertyCurveData; + + export interface Curve { + modifiers: TargetModifier[]; + valueAdapter?: CurveValueAdapter; + data: PropertyCurveData; + } + + export interface Event { + frame: number; + func: string; + params: string[]; + } +} + /** * 动画剪辑。 */ @@ -143,16 +147,16 @@ export class AnimationClip extends Asset { * @deprecated 请转用 `this.curves` */ @property - private curveDatas?: ICurveData = {}; + private curveDatas?: AnimationClip.ICurveData = {}; @property - private _curves: ITargetCurveData[] = []; + private _curves: AnimationClip.Curve[] = []; /** * 动画包含的事件数据。 */ @property({visible: false}) - public events: IAnimationEventData[] = []; + public events: AnimationClip.Event[] = []; @property protected _duration = 0; @@ -383,7 +387,7 @@ export class AnimationClip extends Asset { } private _getDeprecatedCurveDatas () { - const result: ICurveData = {}; + const result: AnimationClip.ICurveData = {}; for (const curve of this._curves) { if (curve.modifiers.length === 0 || !isCustomTargetModifier(curve.modifiers[0], HierachyModifier)) { diff --git a/cocos/core/animation/skeletal-animation-clip.ts b/cocos/core/animation/skeletal-animation-clip.ts index 22f76fd6c5..a2cd8d77e8 100644 --- a/cocos/core/animation/skeletal-animation-clip.ts +++ b/cocos/core/animation/skeletal-animation-clip.ts @@ -31,7 +31,7 @@ import { SkinningModelComponent } from '../3d/framework/skinning-model-component import { ccclass } from '../data/class-decorator'; import { Mat4 } from '../math'; import { INode } from '../utils/interfaces'; -import { AnimationClip, IObjectCurveData, IRuntimeCurve, ITargetCurveData } from './animation-clip'; +import { AnimationClip, IObjectCurveData, IRuntimeCurve } from './animation-clip'; import { IPropertyCurveData } from './animation-curve'; import { ComponentModifier, HierachyModifier, isCustomTargetModifier, isPropertyModifier } from './target-modifier'; @@ -98,7 +98,7 @@ export class SkeletalAnimationClip extends AnimationClip { const values: number[] = new Array(Math.ceil(this.sample * this._duration / this.speed) + 1); for (let i = 0; i < values.length; i++) { values[i] = i; } // create frameID animation - const curves: ITargetCurveData[] = [{ + const curves: AnimationClip.Curve[] = [{ modifiers: [ new HierachyModifier(''), new ComponentModifier('cc.SkeletalAnimationComponent'), diff --git a/cocos/core/assets/mesh.ts b/cocos/core/assets/mesh.ts index 9026d2ca33..85d49e34c9 100644 --- a/cocos/core/assets/mesh.ts +++ b/cocos/core/assets/mesh.ts @@ -45,7 +45,6 @@ import { GFXDevice } from '../gfx/device'; import { IGFXAttribute } from '../gfx/input-assembler'; import { Root } from '../root'; import { Asset } from './asset'; -import { IBufferView } from './utils/buffer-view'; import { postLoadMesh } from './utils/mesh-utils'; function getIndexStrideCtor (stride: number) { @@ -57,76 +56,6 @@ function getIndexStrideCtor (stride: number) { return Uint8Array; } -/** - * @zh - * 顶点块。顶点块描述了一组**交错排列**(interleaved)的顶点属性并存储了顶点属性的实际数据。
- * 交错排列是指在实际数据的缓冲区中,每个顶点的所有属性总是依次排列,并总是出现在下一个顶点的所有属性之前。 - */ -export interface IVertexBundle { - /** - * 所有顶点属性的实际数据块。 - */ - view: IBufferView; - - /** - * 包含的所有顶点属性。 - */ - attributes: IGFXAttribute[]; -} - -/** - * 子网格。子网格由一系列相同类型的图元组成(例如点、线、面等)。 - */ -export interface IPrimitive { - /** - * 此子网格引用的顶点块,索引至网格的顶点块数组。 - */ - vertexBundelIndices: number[]; - - /** - * 此子网格的图元类型。 - */ - primitiveMode: GFXPrimitiveMode; - - /** - * 此子网格使用的索引数据。 - */ - indexView?: IBufferView; - - /** - * (用于射线检测的)几何信息。 - */ - geometricInfo?: { - doubleSided?: boolean; - view: IBufferView; - }; -} - -/** - * 描述了网格的结构。 - */ -export interface IMeshStruct { - /** - * 此网格所有的顶点块。 - */ - vertexBundles: IVertexBundle[]; - - /** - * 此网格的所有子网格。 - */ - primitives: IPrimitive[]; - - /** - * (各分量都)小于等于此网格任何顶点位置的最大位置。 - */ - minPosition?: Vec3; - - /** - * (各分量都)大于等于此网格任何顶点位置的最小位置。 - */ - maxPosition?: Vec3; -} - /** * 允许存储索引的数组视图。 */ @@ -253,16 +182,95 @@ export class RenderingMesh { } } -export interface IMeshCreateInfo { - /** - * 网格结构。 - */ - struct: IMeshStruct; +export declare namespace Mesh { + export interface BufferView { + offset: number; + length: number; + count: number; + stride: number; + } /** - * 网格二进制数据。 + * @zh + * 顶点块。顶点块描述了一组**交错排列**(interleaved)的顶点属性并存储了顶点属性的实际数据。
+ * 交错排列是指在实际数据的缓冲区中,每个顶点的所有属性总是依次排列,并总是出现在下一个顶点的所有属性之前。 */ - data: Uint8Array; + export interface VertexBundle { + /** + * 所有顶点属性的实际数据块。 + */ + view: BufferView; + + /** + * 包含的所有顶点属性。 + */ + attributes: IGFXAttribute[]; + } + + /** + * 子网格。子网格由一系列相同类型的图元组成(例如点、线、面等)。 + */ + export interface Submesh { + /** + * 此子网格引用的顶点块,索引至网格的顶点块数组。 + */ + vertexBundelIndices: number[]; + + /** + * 此子网格的图元类型。 + */ + primitiveMode: GFXPrimitiveMode; + + /** + * 此子网格使用的索引数据。 + */ + indexView?: BufferView; + + /** + * (用于射线检测的)几何信息。 + */ + geometricInfo?: { + doubleSided?: boolean; + view: BufferView; + }; + } + + /** + * 描述了网格的结构。 + */ + export interface Struct { + /** + * 此网格所有的顶点块。 + */ + vertexBundles: VertexBundle[]; + + /** + * 此网格的所有子网格。 + */ + primitives: Submesh[]; + + /** + * (各分量都)小于等于此网格任何顶点位置的最大位置。 + */ + minPosition?: Vec3; + + /** + * (各分量都)大于等于此网格任何顶点位置的最小位置。 + */ + maxPosition?: Vec3; + } + + export interface CreateInfo { + /** + * 网格结构。 + */ + struct: Mesh.Struct; + + /** + * 网格二进制数据。 + */ + data: Uint8Array; + } } /** @@ -336,7 +344,7 @@ export class Mesh extends Asset { } @property - private _struct: IMeshStruct = { + private _struct: Mesh.Struct = { vertexBundles: [], primitives: [], }; @@ -458,7 +466,7 @@ export class Mesh extends Asset { * @param data 新的数据。 * @deprecated 将在 V1.0.0 移除,请转用 `this.reset()`。 */ - public assign (struct: IMeshStruct, data: Uint8Array) { + public assign (struct: Mesh.Struct, data: Uint8Array) { this.reset({ struct, data, @@ -469,7 +477,7 @@ export class Mesh extends Asset { * 重置此网格。 * @param info 网格重置选项。 */ - public reset (info: IMeshCreateInfo) { + public reset (info: Mesh.CreateInfo) { this.destroyRenderingMesh(); this._struct = info.struct; this._data = info.data; @@ -535,7 +543,7 @@ export class Mesh extends Asset { let dstAttrView: Uint8Array; let hasAttr = false; - const vertexBundles = new Array(this._struct.vertexBundles.length); + const vertexBundles = new Array(this._struct.vertexBundles.length); for (let i = 0; i < this._struct.vertexBundles.length; ++i) { const bundle = this._struct.vertexBundles[i]; const dstBundle = mesh._struct.vertexBundles[i]; @@ -600,7 +608,7 @@ export class Mesh extends Asset { let srcIBView: Uint8Array | Uint16Array | Uint32Array; let dstIBView: Uint8Array | Uint16Array | Uint32Array; - const primitives: IPrimitive[] = new Array(this._struct.primitives.length); + const primitives: Mesh.Submesh[] = new Array(this._struct.primitives.length); for (let i = 0; i < this._struct.primitives.length; ++i) { const prim = this._struct.primitives[i]; const dstPrim = mesh._struct.primitives[i]; @@ -704,7 +712,7 @@ export class Mesh extends Asset { } // Create mesh struct. - const meshStruct: IMeshStruct = { + const meshStruct: Mesh.Struct = { vertexBundles, primitives, minPosition: this._struct.minPosition, @@ -1024,7 +1032,7 @@ export class Mesh extends Asset { private _accessAttribute ( primitiveIndex: number, attributeName: GFXAttributeName, - accessor: (vertexBundle: IVertexBundle, iAttribute: number) => void) { + accessor: (vertexBundle: Mesh.VertexBundle, iAttribute: number) => void) { if (!this._data || primitiveIndex >= this._struct.primitives.length) { return; diff --git a/cocos/core/assets/utils/buffer-view.ts b/cocos/core/assets/utils/buffer-view.ts deleted file mode 100644 index 5fc32b0b12..0000000000 --- a/cocos/core/assets/utils/buffer-view.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -export interface IBufferView { - offset: number; - length: number; - count: number; - stride: number; -} From 224cea23abc8fda6b033d2ac6a44e758f54f4a4b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 12 Oct 2019 14:29:48 +0800 Subject: [PATCH 03/33] Improve error maps (#5527) # Conflicts: # cocos/core/platform/debug.ts --- EngineErrorMap.md | 782 +----------------------------- cocos/core/assets/sprite-frame.ts | 2 +- 2 files changed, 3 insertions(+), 781 deletions(-) diff --git a/EngineErrorMap.md b/EngineErrorMap.md index 2d6c2816b8..3da16d5bca 100644 --- a/EngineErrorMap.md +++ b/EngineErrorMap.md @@ -8,133 +8,6 @@ You should specify a valid DOM canvas element. -### 1000 - - -cc.ActionManager.addAction(): action must be non-null - -### 1001 - -cocos2d: removeAction: Target not found - -### 1002 - -cc.ActionManager.removeActionByTag(): an invalid tag - -### 1003 - -cc.ActionManager.removeActionByTag(): target must be non-null - -### 1004 - -cc.ActionManager.getActionByTag(): an invalid tag - -### 1005 - -cocos2d : getActionByTag(tag = %s): Action not found - -### 1006 - -[Action step]. override me - -### 1007 - -[Action update]. override me - -### 1008 - -cocos2d: FiniteTimeAction#reverse: Implement me - -### 1009 - -cc.EaseElastic.reverse(): it should be overridden in subclass. - -### 1010 - -cc.IntervalAction: reverse not implemented. - -### 1011 - -cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass. - -### 1012 - -cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass. - -### 1013 - -The speed parameter error - -### 1014 - -The repeat parameter error - -### 1015 - -parameters should not be ending with null in Javascript - -### 1016 - -cc.RotateTo.reverse(): it should be overridden in subclass. - -### 1017 - - -cc.GridAction.getGrid(): it should be overridden in subclass. - -### 1018 - - -Grid size must be (1,1) - -### 1019 - -Failed to construct, Sequence construction needs two or more actions. - -### 1020 - -Failed to construct, Spawn construction needs two or more actions. - -### 1021 - -cc.Speed.initWithAction(): action must be non nil - -### 1022 - -cc.Follow.initWithAction(): followedNode must be non nil - -### 1023 - -cc.ActionEase.initWithAction(): action must be non nil - -### 1024 - -Invalid configuration. It must at least have one control point - -### 1025 - -cc.Sequence.initWithTwoActions(): arguments must all be non nil - -### 1026 - -cc.RepeatForever.initWithAction(): action must be non null - -### 1027 - -cc.Spawn.initWithTwoActions(): arguments must all be non null - -### 1028 - -cc.ReverseTime.initWithAction(): action must be non null - -### 1029 - -cc.ReverseTime.initWithAction(): the action was already passed in. - -### 1030 - -cc.Animate.initWithAnimation(): animation must be non-NULL - ### 1100 Expected 'data' dict, but not found. Config file: %s @@ -147,19 +20,6 @@ Please load the resource first : %s cocos2d: Director: Error in gettimeofday -### 1201 - -cocos2d: Director: unrecognized projection - -### 1202 - - -cocos2d: Director: unrecognized projection - -### 1203 - -cocos2d: Director: Error in gettimeofday - ### 1204 running scene should not null @@ -248,16 +108,6 @@ The '%s' will be removed in v2.0, please use '%s' instead. cc.pool is being removed from v2.0, you are getting cc.js.Pool instead -### 1500 - - -CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s - -### 1501 - - -cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null. - ### 1502 cc.scheduler.scheduleCallbackForTarget(): target should be non-null. @@ -306,27 +156,6 @@ cc.Scheduler: updateFunc parameter is deprecated in scheduleUpdate function, and cc.Scheduler: scheduler stopped using `__instanceId` as id since v2.0, you should do Scheduler.enableForTarget(target) before all scheduler API usage on target -### 1600 - -getZOrder is deprecated. Please use getLocalZOrder instead. - -### 1601 - -setZOrder is deprecated. Please use setLocalZOrder instead. - -### 1602 - -RotationX != RotationY. Don't know which one to return - -### 1603 - -ScaleX != ScaleY. Don't know which one to return - -### 1604 - - -An Node can't be added as a child of itself. - ### 1605 child already added. It can't be added again @@ -347,44 +176,6 @@ boundingBox is deprecated. Use getBoundingBox instead argument tag is an invalid tag -### 1610 - -cocos2d: removeChildByTag(tag = %s): child not found! - -### 1611 - - -removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead - -### 1612 - -cc.Node.stopActionBy(): argument tag an invalid tag - -### 1613 - -cc.Node.getActionByTag(): argument tag is an invalid tag - -### 1614 - -resumeSchedulerAndActions is deprecated, please use resume instead. - -### 1615 - -pauseSchedulerAndActions is deprecated, please use pause instead. - -### 1616 - - -Unknown callback function - -### 1617 - -child must be non-null - -### 1618 - -cc.Node.runAction(): action must be non-null - ### 1619 callback function must be non-null @@ -393,16 +184,6 @@ callback function must be non-null interval must be positive -### 1621 - - -cocos2d: Could not initialize cc.AtlasNode. Invalid Texture. - -### 1622 - - -_ccsg.Node._requestDirtyFlag: failed to satisfy the request, key (%s) for flag have already been taken - ### 1623 Set '%s' to normal node (not persist root node). @@ -471,25 +252,6 @@ Node's zIndex value can't be smaller than cc.macro.MIN_ZINDEX, setting to the mi Private node's zIndex can't be set, it will keep cc.macro.MIN_ZINDEX as its value -### 1700 - - -cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses - -### 1701 - - - -### 1702 - - -cocos2d: Could not initialize cc.AtlasNode. Invalid Texture. - -### 1703 - - -The new text must be String - ### 1800 cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard! @@ -510,30 +272,6 @@ cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non Invalid parameter. -### 2000 - -Don't call this method if the event is for touch. - -### 2100 - - -parameters should not be ending with null in Javascript - -### 2101 - - -Invalid index in MultiplexLayer switchTo message - -### 2102 - - -Invalid index in MultiplexLayer switchTo message - -### 2103 - - -cc.Layer.addLayer(): layer should be non-null - ### 2200 Resolution not valid @@ -546,535 +284,19 @@ should set resolutionPolicy The touches is more than MAX_TOUCHES, nUnusedIndex = %s -### 2400 - -WebGL error %s - -### 2401 - - -Too many graphics vertices generated, only 65536 vertices support. - -### 2500 - - -cocos2d: cc.SpriteFrameAnimationCache: No animations were found in provided dictionary. - -### 2501 - - -cc.SpriteFrameAnimationCache. Invalid animation format - -### 2502 - - -cc.SpriteFrameAnimationCache.addAnimations(): File could not be found - -### 2503 - - -cocos2d: cc.SpriteFrameAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache. - -### 2504 - - -cocos2d: cc.SpriteFrameAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation. - -### 2505 - - -cocos2d: cc.SpriteFrameAnimationCache: None of the frames for animation '%s' were found in the cc.SpriteFrameCache. Animation is not being added to the Animation Cache. - -### 2506 - - -cocos2d: cc.SpriteFrameAnimationCache: An animation in your dictionary refers to a frame which is not in the cc.SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing. - -### 2507 - - -cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache. - -### 2508 - - -cocos2d: cc.SpriteFrameAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation. - -### 2509 - - -cc.SpriteFrameAnimationCache.addAnimations(): Invalid texture file name - -### 2600 - - -cc.Sprite.reorderChild(): this child is not in children list - -### 2601 - - -cc.Sprite.setIgnoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode - -### 2602 - -cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found - -### 2603 - -cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index - -### 2604 - -setDisplayFrame is deprecated, please use setSpriteFrame instead. - -### 2605 - - -cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode - -### 2606 - -cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null - -### 2607 - -cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null - -### 2608 - -%s is null, please check. - -### 2609 - -cc.Sprite.initWithFile(): filename should be non-null - -### 2610 - -cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null - -### 2611 - - -cc.Sprite.reorderChild(): child should be non-null - -### 2612 - - -cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode - -### 2613 - - -cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode - -### 2614 - -cc.Sprite.addChild(): child should be non-null - -### 2615 - - -cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode - -### 2616 - -cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children - -### 2617 - -cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children - -### 2618 - -cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children - -### 2619 - -cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture - -### 2620 - - -Sprite.initWithTexture(): Argument must be non-nil - -### 2621 - - -Invalid spriteFrameName - -### 2622 - - -Invalid argument: cc.Sprite.texture setter expects a cc.Texture2D. - -### 2623 - -cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null - -### 2624 - - -cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null - -### 2625 - -too many tiles, only 16384 tiles will be show - -### 2626 - -Unrecognized fill type in bar fill - -### 2627 - -Can not generate quad - -### 2628 - -%s does not exist - -### 2700 - - -cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children - -### 2701 - - -cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s. - -### 2702 - - -cocos2d: WARNING: Not enough memory to resize the atlas - -### 2703 - - -cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite - -### 2704 - - -cc.SpriteBatchNode.addChild(): sprite batch node should contain the child - -### 2705 - - -cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null - -### 2706 - - -cc.SpriteBatchNode.addChild(): child should be non-null - -### 2707 - - -cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children - -### 2708 - - -cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children - -### 2709 - - -cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children - -### 2710 - -Sprite.initWithTexture(): Argument must be non-nil - -### 2711 - - -cc.Sprite.addChild(): child should be non-null - -### 2712 - -Invalid spriteFrameName - -### 2713 - - -Invalid argument: cc.Sprite texture setter expects a cc.Texture2D. - -### 2714 - - -cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null - -### 2715 - - -cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null - -### 2716 - - -cc.SpriteBatchNode.addChild(): child should be non-null - -### 2728 - - -%s does not exist - -### 2800 - - -cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist - -### 2801 - - -cocos2d: WARNING: an alias with name %s already exists - -### 2802 - - -cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit - -### 2803 - - -cocos2d: cc.SpriteFrameCahce: Frame %s not found - -### 2804 - - -Please load the resource first : %s - -### 2805 - - -cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null - -### 2806 - - -Argument must be non-nil - -### 2900 - - -cocos2d: Could not open file: %s - -### 2901 - - -cc.TextureAtlas.insertQuad(): invalid totalQuads - -### 2902 - - -cc.TextureAtlas.initWithTexture():texture should be non-null - -### 2903 - - -cc.TextureAtlas.updateQuad(): quad should be non-null - -### 2904 - - -cc.TextureAtlas.updateQuad(): Invalid index - -### 2905 - - -cc.TextureAtlas.insertQuad(): Invalid index - -### 2906 - - -cc.TextureAtlas.insertQuad(): Invalid index + amount - -### 2907 - - -cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex - -### 2908 - - -cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex - -### 2909 - - -cc.TextureAtlas.removeQuadAtIndex(): Invalid index - -### 2910 - - -cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds - -### 2911 - - -cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds - -### 2912 - - -cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex - -### 2913 - - -cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex - -### 3000 - - -TextureCache:addPVRTCImage does not support on HTML5 - -### 3001 - - -TextureCache:addPVRTCImage does not support on HTML5 - -### 3002 - -textureForKey is deprecated. Please use getTextureForKey instead. - -### 3003 - - -addPVRImage does not support on HTML5 - -### 3004 - - -cocos2d: Couldn't add UIImage in TextureCache - -### 3005 - -cocos2d: '%s' id=%s %s x %s - -### 3006 - -cocos2d: '%s' id= HTMLCanvasElement %s x %s - -### 3007 - -cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB) - -### 3008 - - -cc.Texture.addUIImage(): image should be non-null - -### 3009 - - -TextureCache: url should be non-null - -### 3100 - - -initWithETCFile does not support on HTML5 - -### 3101 - - -initWithPVRFile does not support on HTML5 - -### 3102 - - -initWithPVRTCData does not support on HTML5 - ### 3103 -cc.Texture.addImage(): path should be non-null - -### 3104 - - -cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil - -### 3105 - - -cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s - -### 3106 - - -initWithString isn't supported on cocos2d-html5 - -### 3107 - - -initWithETCFile does not support on HTML5 - -### 3108 - - -initWithPVRFile does not support on HTML5 - -### 3109 - - -initWithPVRTCData does not support on HTML5 - -### 3110 - - -bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format - -### 3111 - - -cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha - -### 3112 - -cc.Texture.addImage(): path should be non-null - -### 3113 - -NSInternalInconsistencyException - -### 3114 - - -SpriteFrame: Failed to load sprite texture '%s' - -### 3115 - - -Frame Grabber: could not attach texture to framebuffer - -### 3116 - -WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures - -### 3117 - -Mimpap texture only works in POT textures - -### 3118 - - -contentSize parameter is deprecated and ignored for cc.Texture2D initWithData function. +textureUtil.addImage(): path should be non-null ### 3119 Lazy init texture with image element failed due to image loading failure: %s -### 3200 - - -Missing file: %s - ### 3300 Rect width exceeds maximum margin: %s -### 3400 +### 3301 Rect height exceeds maximum margin: %s diff --git a/cocos/core/assets/sprite-frame.ts b/cocos/core/assets/sprite-frame.ts index c3f23f35d4..d91bfe8d74 100644 --- a/cocos/core/assets/sprite-frame.ts +++ b/cocos/core/assets/sprite-frame.ts @@ -603,7 +603,7 @@ export class SpriteFrame extends Asset { } if (maxY > texture.height) { - cc.errorID(3400, this.name + '/' + texture.name, maxY, texture.height); + cc.errorID(3301, this.name + '/' + texture.name, maxY, texture.height); return false; } From d1878c0c26018e25951b6ff5ea08cf96f1e734df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Sat, 12 Oct 2019 14:31:45 +0800 Subject: [PATCH 04/33] fix cubic spline interpolation (#5518) --- cocos/core/animation/cubic-spline-value.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cocos/core/animation/cubic-spline-value.ts b/cocos/core/animation/cubic-spline-value.ts index b174dd02f2..9a07e0df6a 100644 --- a/cocos/core/animation/cubic-spline-value.ts +++ b/cocos/core/animation/cubic-spline-value.ts @@ -50,8 +50,8 @@ function makeCubicSplineValueConstructor ( const p0 = this.dataPoint; const p1 = to.dataPoint; // dt => t_k+1 - t_k - m0 = scaleFx(m0, this.outTangent, dt); - m1 = scaleFx(m1, to.inTangent, dt); + m0 = scaleFx(m0, this.inTangent, dt); + m1 = scaleFx(m1, to.outTangent, dt); const t_3 = t * t * t; const t_2 = t * t; const f_0 = 2 * t_3 - 3 * t_2 + 1; @@ -70,6 +70,16 @@ function makeCubicSplineValueConstructor ( } } + // @ts-ignore TS2367 + if (constructorX === Quat) { + const lerp = CubicSplineValueClass.prototype.lerp; + CubicSplineValueClass.prototype.lerp = function (this: CubicSplineValueClass, to: CubicSplineValueClass, t: number, dt: number) { + const result = lerp.call(this, to, t, dt) as Quat; + Quat.normalize(result, result); + return result; + }; + } + return CubicSplineValueClass; } From b6a546c2ff50bb21d4a689c4fb233aa8b1afb212 Mon Sep 17 00:00:00 2001 From: Myway Date: Mon, 14 Oct 2019 22:55:56 +0800 Subject: [PATCH 05/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=94=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=AE=9A=E4=B9=89=E7=9A=84=E9=94=99=E8=AF=AF=20(#5539?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/terrain/terrain.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/terrain/terrain.ts b/cocos/terrain/terrain.ts index e0ae17ab65..47586cfb0f 100644 --- a/cocos/terrain/terrain.ts +++ b/cocos/terrain/terrain.ts @@ -250,6 +250,7 @@ export class TerrainBlock { attributes: gfxAttributes, vertexBuffers: [vertexBuffer], indexBuffer : this._terrain.getSharedIndexBuffer(), + flatBuffers : [], primitiveMode: GFXPrimitiveMode.TRIANGLE_LIST, }; From a722483d2d44647463d7f644c9c7f4094c8c1c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Mon, 14 Oct 2019 22:58:15 +0800 Subject: [PATCH 06/33] fix typing errors (#5538) * fix typing errors * disable eslint rule: prefer-readonly --- .eslintrc.json | 2 +- .vscode/settings.json | 4 +- @types/globals.d.ts | 2 +- .../WebGL.d.ts => @types/webGL.extras.d.ts | 0 @types/webGL2.extras.d.ts | 23 + cocos/core/gfx/webgl2/WebGL2.d.ts | 1554 ----------------- package.json | 2 +- .../generate-declarations-cli.js | 22 +- .../generate-declarations.js | 116 +- tsconfig.json | 4 +- 10 files changed, 98 insertions(+), 1631 deletions(-) rename cocos/core/gfx/webgl/WebGL.d.ts => @types/webGL.extras.d.ts (100%) create mode 100644 @types/webGL2.extras.d.ts delete mode 100644 cocos/core/gfx/webgl2/WebGL2.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index aaad307de7..7bf5419794 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -108,7 +108,7 @@ "@typescript-eslint/prefer-function-type": "off", "@typescript-eslint/prefer-includes": "warn", "@typescript-eslint/prefer-namespace-keyword": "off", - "@typescript-eslint/prefer-readonly": "warn", + "@typescript-eslint/prefer-readonly": "off", "@typescript-eslint/prefer-regexp-exec": "warn", "@typescript-eslint/prefer-string-starts-ends-with": "warn", "@typescript-eslint/promise-function-async": "off", diff --git a/.vscode/settings.json b/.vscode/settings.json index b66390e7de..3644279203 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,8 +13,6 @@ "javascript.implicitProjectConfig.experimentalDecorators": true, "eslint.validate": [ "javascript", - "javascriptreact", - "typescript", - "typescriptreact" + { "language": "typescript", "autoFix": true }, ] } diff --git a/@types/globals.d.ts b/@types/globals.d.ts index dd9dda8c08..c8f1cc0546 100644 --- a/@types/globals.d.ts +++ b/@types/globals.d.ts @@ -109,7 +109,7 @@ declare type Getter = () => any; declare type Setter = (value: any) => void; declare namespace Editor { - function require (str: String): any; + function require (str: string): any; const isMainProcess: boolean | undefined; const Utils: any; const serialize: any; diff --git a/cocos/core/gfx/webgl/WebGL.d.ts b/@types/webGL.extras.d.ts similarity index 100% rename from cocos/core/gfx/webgl/WebGL.d.ts rename to @types/webGL.extras.d.ts diff --git a/@types/webGL2.extras.d.ts b/@types/webGL2.extras.d.ts new file mode 100644 index 0000000000..4468a18ad4 --- /dev/null +++ b/@types/webGL2.extras.d.ts @@ -0,0 +1,23 @@ +interface EXT_color_buffer_float { +} + +interface EXT_disjoint_timer_query_webgl2 { + readonly QUERY_COUNTER_BITS_EXT: GLenum; + readonly TIME_ELAPSED_EXT: GLenum; + readonly TIMESTAMP_EXT: GLenum; + readonly GPU_DISJOINT_EXT: GLenum; + + queryCounterEXT(query: WebGLQuery, target: GLenum): void; +} + +interface WEBGL_texture_storage_multisample { + readonly TEXTURE_2D_MULTISAMPLE: number; + + texStorage2DMultisample( + target: GLenum, + samples: GLsizei, + internalformat: GLenum, + width: GLsizei, + height: GLsizei, + fixedsamplelocations: GLboolean): void; +} \ No newline at end of file diff --git a/cocos/core/gfx/webgl2/WebGL2.d.ts b/cocos/core/gfx/webgl2/WebGL2.d.ts deleted file mode 100644 index a40f6c1351..0000000000 --- a/cocos/core/gfx/webgl2/WebGL2.d.ts +++ /dev/null @@ -1,1554 +0,0 @@ -declare type GLint64 = number; -declare type GLuint64 = GLint64; - -interface EXT_color_buffer_float { -} - -interface EXT_disjoint_timer_query_webgl2 { - readonly QUERY_COUNTER_BITS_EXT: GLenum; - readonly TIME_ELAPSED_EXT: GLenum; - readonly TIMESTAMP_EXT: GLenum; - readonly GPU_DISJOINT_EXT: GLenum; - - queryCounterEXT(query: WebGLQuery, target: GLenum): void; -} - -interface WebGLQuery extends WebGLObject { -} - -declare var WebGLQuery: { - prototype: WebGLQuery; - new(): WebGLQuery; -} - -interface WebGLSampler extends WebGLObject { -} - -declare var WebGLSampler: { - prototype: WebGLSampler; - new(): WebGLSampler; -} - -interface WebGLSync extends WebGLObject { -} - -declare var WebGLSync: { - prototype: WebGLSync; - new(): WebGLSync; -} - -interface WebGLTransformFeedback extends WebGLObject { -} - -declare var WebGLTransformFeedback: { - prototype: WebGLTransformFeedback; - new(): WebGLTransformFeedback; -} - -interface WebGLVertexArrayObject extends WebGLObject { -} - -declare var WebGLVertexArrayObject: { - prototype: WebGLVertexArrayObject; - new(): WebGLVertexArrayObject; -} - -interface WebGLTimerQueryEXT extends WebGLQuery { -} - -declare var WebGLTimerQueryEXT: { - prototype: WebGLTimerQueryEXT; - new(): WebGLTimerQueryEXT; -} - -interface EXT_disjoint_timer_query { - createQueryEXT(): WebGLTimerQueryEXT | null; - deleteQueryEXT(query: WebGLTimerQueryEXT | null): void; - isQueryEXT(query: WebGLTimerQueryEXT | null): boolean; - beginQueryEXT(target: number, query: WebGLTimerQueryEXT | null): void; - endQueryEXT(target: number): void; - queryCounterEXT(query: WebGLTimerQueryEXT | null, target: number): number; - getQueryEXT(target: number, pname: number): WebGLTimerQueryEXT | number | null; - getQueryObjectEXT(query: WebGLTimerQueryEXT | null, pname: number): number | boolean; - - readonly QUERY_COUNTER_BITS_EXT: number; - readonly CURRENT_QUERY_EXT: number; - readonly QUERY_RESULT_EXT: number; - readonly QUERY_RESULT_AVAILABLE_EXT: number; - readonly TIME_ELAPSED_EXT: number; - readonly TIMESTAMP_EXT: number; - readonly GPU_DISJOINT_EXT: number; -} - -declare var EXT_disjoint_timer_query: { - prototype: EXT_disjoint_timer_query; - new(): EXT_disjoint_timer_query; - - readonly QUERY_COUNTER_BITS_EXT: number; - readonly CURRENT_QUERY_EXT: number; - readonly QUERY_RESULT_EXT: number; - readonly QUERY_RESULT_AVAILABLE_EXT: number; - readonly TIME_ELAPSED_EXT: number; - readonly TIMESTAMP_EXT: number; - readonly GPU_DISJOINT_EXT: number; -} - -interface WEBGL_texture_storage_multisample { - readonly TEXTURE_2D_MULTISAMPLE: number; - - texStorage2DMultisample( - target: GLenum, - samples: GLsizei, - internalformat: GLenum, - width: GLsizei, - height: GLsizei, - fixedsamplelocations: GLboolean): void; -} - -interface HTMLCanvasElement { - getContext(contextId: "webgl2" | "experimental-webgl2", contextAttributes?: WebGLContextAttributes): WebGL2RenderingContext | null; -} - -interface WebGL2RenderingContext extends WebGL2RenderingContextBase { -} - -declare var WebGL2RenderingContext: { - prototype: WebGLRenderingContext; - new(): WebGLRenderingContext; - readonly ACTIVE_ATTRIBUTES: GLenum; - readonly ACTIVE_TEXTURE: GLenum; - readonly ACTIVE_UNIFORMS: GLenum; - readonly ALIASED_LINE_WIDTH_RANGE: GLenum; - readonly ALIASED_POINT_SIZE_RANGE: GLenum; - readonly ALPHA: GLenum; - readonly ALPHA_BITS: GLenum; - readonly ALWAYS: GLenum; - readonly ARRAY_BUFFER: GLenum; - readonly ARRAY_BUFFER_BINDING: GLenum; - readonly ATTACHED_SHADERS: GLenum; - readonly BACK: GLenum; - readonly BLEND: GLenum; - readonly BLEND_COLOR: GLenum; - readonly BLEND_DST_ALPHA: GLenum; - readonly BLEND_DST_RGB: GLenum; - readonly BLEND_EQUATION: GLenum; - readonly BLEND_EQUATION_ALPHA: GLenum; - readonly BLEND_EQUATION_RGB: GLenum; - readonly BLEND_SRC_ALPHA: GLenum; - readonly BLEND_SRC_RGB: GLenum; - readonly BLUE_BITS: GLenum; - readonly BOOL: GLenum; - readonly BOOL_VEC2: GLenum; - readonly BOOL_VEC3: GLenum; - readonly BOOL_VEC4: GLenum; - readonly BROWSER_DEFAULT_WEBGL: GLenum; - readonly BUFFER_SIZE: GLenum; - readonly BUFFER_USAGE: GLenum; - readonly BYTE: GLenum; - readonly CCW: GLenum; - readonly CLAMP_TO_EDGE: GLenum; - readonly COLOR_ATTACHMENT0: GLenum; - readonly COLOR_BUFFER_BIT: GLenum; - readonly COLOR_CLEAR_VALUE: GLenum; - readonly COLOR_WRITEMASK: GLenum; - readonly COMPILE_STATUS: GLenum; - readonly COMPRESSED_TEXTURE_FORMATS: GLenum; - readonly CONSTANT_ALPHA: GLenum; - readonly CONSTANT_COLOR: GLenum; - readonly CONTEXT_LOST_WEBGL: GLenum; - readonly CULL_FACE: GLenum; - readonly CULL_FACE_MODE: GLenum; - readonly CURRENT_PROGRAM: GLenum; - readonly CURRENT_VERTEX_ATTRIB: GLenum; - readonly CW: GLenum; - readonly DECR: GLenum; - readonly DECR_WRAP: GLenum; - readonly DELETE_STATUS: GLenum; - readonly DEPTH_ATTACHMENT: GLenum; - readonly DEPTH_BITS: GLenum; - readonly DEPTH_BUFFER_BIT: GLenum; - readonly DEPTH_CLEAR_VALUE: GLenum; - readonly DEPTH_COMPONENT: GLenum; - readonly DEPTH_COMPONENT16: GLenum; - readonly DEPTH_FUNC: GLenum; - readonly DEPTH_RANGE: GLenum; - readonly DEPTH_STENCIL: GLenum; - readonly DEPTH_STENCIL_ATTACHMENT: GLenum; - readonly DEPTH_TEST: GLenum; - readonly DEPTH_WRITEMASK: GLenum; - readonly DITHER: GLenum; - readonly DONT_CARE: GLenum; - readonly DST_ALPHA: GLenum; - readonly DST_COLOR: GLenum; - readonly DYNAMIC_DRAW: GLenum; - readonly ELEMENT_ARRAY_BUFFER: GLenum; - readonly ELEMENT_ARRAY_BUFFER_BINDING: GLenum; - readonly EQUAL: GLenum; - readonly FASTEST: GLenum; - readonly FLOAT: GLenum; - readonly FLOAT_MAT2: GLenum; - readonly FLOAT_MAT3: GLenum; - readonly FLOAT_MAT4: GLenum; - readonly FLOAT_VEC2: GLenum; - readonly FLOAT_VEC3: GLenum; - readonly FLOAT_VEC4: GLenum; - readonly FRAGMENT_SHADER: GLenum; - readonly FRAMEBUFFER: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: GLenum; - readonly FRAMEBUFFER_BINDING: GLenum; - readonly FRAMEBUFFER_COMPLETE: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLenum; - readonly FRAMEBUFFER_UNSUPPORTED: GLenum; - readonly FRONT: GLenum; - readonly FRONT_AND_BACK: GLenum; - readonly FRONT_FACE: GLenum; - readonly FUNC_ADD: GLenum; - readonly FUNC_REVERSE_SUBTRACT: GLenum; - readonly FUNC_SUBTRACT: GLenum; - readonly GENERATE_MIPMAP_HINT: GLenum; - readonly GEQUAL: GLenum; - readonly GREATER: GLenum; - readonly GREEN_BITS: GLenum; - readonly HIGH_FLOAT: GLenum; - readonly HIGH_INT: GLenum; - readonly IMPLEMENTATION_COLOR_READ_FORMAT: GLenum; - readonly IMPLEMENTATION_COLOR_READ_TYPE: GLenum; - readonly INCR: GLenum; - readonly INCR_WRAP: GLenum; - readonly INT: GLenum; - readonly INT_VEC2: GLenum; - readonly INT_VEC3: GLenum; - readonly INT_VEC4: GLenum; - readonly INVALID_ENUM: GLenum; - readonly INVALID_FRAMEBUFFER_OPERATION: GLenum; - readonly INVALID_OPERATION: GLenum; - readonly INVALID_VALUE: GLenum; - readonly INVERT: GLenum; - readonly KEEP: GLenum; - readonly LEQUAL: GLenum; - readonly LESS: GLenum; - readonly LINEAR: GLenum; - readonly LINEAR_MIPMAP_LINEAR: GLenum; - readonly LINEAR_MIPMAP_NEAREST: GLenum; - readonly LINES: GLenum; - readonly LINE_LOOP: GLenum; - readonly LINE_STRIP: GLenum; - readonly LINE_WIDTH: GLenum; - readonly LINK_STATUS: GLenum; - readonly LOW_FLOAT: GLenum; - readonly LOW_INT: GLenum; - readonly LUMINANCE: GLenum; - readonly LUMINANCE_ALPHA: GLenum; - readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: GLenum; - readonly MAX_CUBE_MAP_TEXTURE_SIZE: GLenum; - readonly MAX_FRAGMENT_UNIFORM_VECTORS: GLenum; - readonly MAX_RENDERBUFFER_SIZE: GLenum; - readonly MAX_TEXTURE_IMAGE_UNITS: GLenum; - readonly MAX_TEXTURE_SIZE: GLenum; - readonly MAX_VARYING_VECTORS: GLenum; - readonly MAX_VERTEX_ATTRIBS: GLenum; - readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: GLenum; - readonly MAX_VERTEX_UNIFORM_VECTORS: GLenum; - readonly MAX_VIEWPORT_DIMS: GLenum; - readonly MEDIUM_FLOAT: GLenum; - readonly MEDIUM_INT: GLenum; - readonly MIRRORED_REPEAT: GLenum; - readonly NEAREST: GLenum; - readonly NEAREST_MIPMAP_LINEAR: GLenum; - readonly NEAREST_MIPMAP_NEAREST: GLenum; - readonly NEVER: GLenum; - readonly NICEST: GLenum; - readonly NONE: GLenum; - readonly NOTEQUAL: GLenum; - readonly NO_ERROR: GLenum; - readonly ONE: GLenum; - readonly ONE_MINUS_CONSTANT_ALPHA: GLenum; - readonly ONE_MINUS_CONSTANT_COLOR: GLenum; - readonly ONE_MINUS_DST_ALPHA: GLenum; - readonly ONE_MINUS_DST_COLOR: GLenum; - readonly ONE_MINUS_SRC_ALPHA: GLenum; - readonly ONE_MINUS_SRC_COLOR: GLenum; - readonly OUT_OF_MEMORY: GLenum; - readonly PACK_ALIGNMENT: GLenum; - readonly POINTS: GLenum; - readonly POLYGON_OFFSET_FACTOR: GLenum; - readonly POLYGON_OFFSET_FILL: GLenum; - readonly POLYGON_OFFSET_UNITS: GLenum; - readonly RED_BITS: GLenum; - readonly RENDERBUFFER: GLenum; - readonly RENDERBUFFER_ALPHA_SIZE: GLenum; - readonly RENDERBUFFER_BINDING: GLenum; - readonly RENDERBUFFER_BLUE_SIZE: GLenum; - readonly RENDERBUFFER_DEPTH_SIZE: GLenum; - readonly RENDERBUFFER_GREEN_SIZE: GLenum; - readonly RENDERBUFFER_HEIGHT: GLenum; - readonly RENDERBUFFER_INTERNAL_FORMAT: GLenum; - readonly RENDERBUFFER_RED_SIZE: GLenum; - readonly RENDERBUFFER_STENCIL_SIZE: GLenum; - readonly RENDERBUFFER_WIDTH: GLenum; - readonly RENDERER: GLenum; - readonly REPEAT: GLenum; - readonly REPLACE: GLenum; - readonly RGB: GLenum; - readonly RGB565: GLenum; - readonly RGB5_A1: GLenum; - readonly RGBA: GLenum; - readonly RGBA4: GLenum; - readonly SAMPLER_2D: GLenum; - readonly SAMPLER_CUBE: GLenum; - readonly SAMPLES: GLenum; - readonly SAMPLE_ALPHA_TO_COVERAGE: GLenum; - readonly SAMPLE_BUFFERS: GLenum; - readonly SAMPLE_COVERAGE: GLenum; - readonly SAMPLE_COVERAGE_INVERT: GLenum; - readonly SAMPLE_COVERAGE_VALUE: GLenum; - readonly SCISSOR_BOX: GLenum; - readonly SCISSOR_TEST: GLenum; - readonly SHADER_TYPE: GLenum; - readonly SHADING_LANGUAGE_VERSION: GLenum; - readonly SHORT: GLenum; - readonly SRC_ALPHA: GLenum; - readonly SRC_ALPHA_SATURATE: GLenum; - readonly SRC_COLOR: GLenum; - readonly STATIC_DRAW: GLenum; - readonly STENCIL_ATTACHMENT: GLenum; - readonly STENCIL_BACK_FAIL: GLenum; - readonly STENCIL_BACK_FUNC: GLenum; - readonly STENCIL_BACK_PASS_DEPTH_FAIL: GLenum; - readonly STENCIL_BACK_PASS_DEPTH_PASS: GLenum; - readonly STENCIL_BACK_REF: GLenum; - readonly STENCIL_BACK_VALUE_MASK: GLenum; - readonly STENCIL_BACK_WRITEMASK: GLenum; - readonly STENCIL_BITS: GLenum; - readonly STENCIL_BUFFER_BIT: GLenum; - readonly STENCIL_CLEAR_VALUE: GLenum; - readonly STENCIL_FAIL: GLenum; - readonly STENCIL_FUNC: GLenum; - readonly STENCIL_INDEX8: GLenum; - readonly STENCIL_PASS_DEPTH_FAIL: GLenum; - readonly STENCIL_PASS_DEPTH_PASS: GLenum; - readonly STENCIL_REF: GLenum; - readonly STENCIL_TEST: GLenum; - readonly STENCIL_VALUE_MASK: GLenum; - readonly STENCIL_WRITEMASK: GLenum; - readonly STREAM_DRAW: GLenum; - readonly SUBPIXEL_BITS: GLenum; - readonly TEXTURE: GLenum; - readonly TEXTURE0: GLenum; - readonly TEXTURE1: GLenum; - readonly TEXTURE10: GLenum; - readonly TEXTURE11: GLenum; - readonly TEXTURE12: GLenum; - readonly TEXTURE13: GLenum; - readonly TEXTURE14: GLenum; - readonly TEXTURE15: GLenum; - readonly TEXTURE16: GLenum; - readonly TEXTURE17: GLenum; - readonly TEXTURE18: GLenum; - readonly TEXTURE19: GLenum; - readonly TEXTURE2: GLenum; - readonly TEXTURE20: GLenum; - readonly TEXTURE21: GLenum; - readonly TEXTURE22: GLenum; - readonly TEXTURE23: GLenum; - readonly TEXTURE24: GLenum; - readonly TEXTURE25: GLenum; - readonly TEXTURE26: GLenum; - readonly TEXTURE27: GLenum; - readonly TEXTURE28: GLenum; - readonly TEXTURE29: GLenum; - readonly TEXTURE3: GLenum; - readonly TEXTURE30: GLenum; - readonly TEXTURE31: GLenum; - readonly TEXTURE4: GLenum; - readonly TEXTURE5: GLenum; - readonly TEXTURE6: GLenum; - readonly TEXTURE7: GLenum; - readonly TEXTURE8: GLenum; - readonly TEXTURE9: GLenum; - readonly TEXTURE_2D: GLenum; - readonly TEXTURE_BINDING_2D: GLenum; - readonly TEXTURE_BINDING_CUBE_MAP: GLenum; - readonly TEXTURE_CUBE_MAP: GLenum; - readonly TEXTURE_CUBE_MAP_NEGATIVE_X: GLenum; - readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: GLenum; - readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: GLenum; - readonly TEXTURE_CUBE_MAP_POSITIVE_X: GLenum; - readonly TEXTURE_CUBE_MAP_POSITIVE_Y: GLenum; - readonly TEXTURE_CUBE_MAP_POSITIVE_Z: GLenum; - readonly TEXTURE_MAG_FILTER: GLenum; - readonly TEXTURE_MIN_FILTER: GLenum; - readonly TEXTURE_WRAP_S: GLenum; - readonly TEXTURE_WRAP_T: GLenum; - readonly TRIANGLES: GLenum; - readonly TRIANGLE_FAN: GLenum; - readonly TRIANGLE_STRIP: GLenum; - readonly UNPACK_ALIGNMENT: GLenum; - readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: GLenum; - readonly UNPACK_FLIP_Y_WEBGL: GLenum; - readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: GLenum; - readonly UNSIGNED_BYTE: GLenum; - readonly UNSIGNED_INT: GLenum; - readonly UNSIGNED_SHORT: GLenum; - readonly UNSIGNED_SHORT_4_4_4_4: GLenum; - readonly UNSIGNED_SHORT_5_5_5_1: GLenum; - readonly UNSIGNED_SHORT_5_6_5: GLenum; - readonly VALIDATE_STATUS: GLenum; - readonly VENDOR: GLenum; - readonly VERSION: GLenum; - readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: GLenum; - readonly VERTEX_ATTRIB_ARRAY_ENABLED: GLenum; - readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: GLenum; - readonly VERTEX_ATTRIB_ARRAY_POINTER: GLenum; - readonly VERTEX_ATTRIB_ARRAY_SIZE: GLenum; - readonly VERTEX_ATTRIB_ARRAY_STRIDE: GLenum; - readonly VERTEX_ATTRIB_ARRAY_TYPE: GLenum; - readonly VERTEX_SHADER: GLenum; - readonly VIEWPORT: GLenum; - readonly ZERO: GLenum; - - readonly READ_BUFFER: GLenum; - readonly UNPACK_ROW_LENGTH: GLenum; - readonly UNPACK_SKIP_ROWS: GLenum; - readonly UNPACK_SKIP_PIXELS: GLenum; - readonly PACK_ROW_LENGTH: GLenum; - readonly PACK_SKIP_ROWS: GLenum; - readonly PACK_SKIP_PIXELS: GLenum; - readonly COLOR: GLenum; - readonly DEPTH: GLenum; - readonly STENCIL: GLenum; - readonly RED: GLenum; - readonly RGB8: GLenum; - readonly RGBA8: GLenum; - readonly RGB10_A2: GLenum; - readonly TEXTURE_BINDING_3D: GLenum; - readonly UNPACK_SKIP_IMAGES: GLenum; - readonly UNPACK_IMAGE_HEIGHT: GLenum; - readonly TEXTURE_3D: GLenum; - readonly TEXTURE_WRAP_R: GLenum; - readonly MAX_3D_TEXTURE_SIZE: GLenum; - readonly UNSIGNED_INT_2_10_10_10_REV: GLenum; - readonly MAX_ELEMENTS_VERTICES: GLenum; - readonly MAX_ELEMENTS_INDICES: GLenum; - readonly TEXTURE_MIN_LOD: GLenum; - readonly TEXTURE_MAX_LOD: GLenum; - readonly TEXTURE_BASE_LEVEL: GLenum; - readonly TEXTURE_MAX_LEVEL: GLenum; - readonly MIN: GLenum; - readonly MAX: GLenum; - readonly DEPTH_COMPONENT24: GLenum; - readonly MAX_TEXTURE_LOD_BIAS: GLenum; - readonly TEXTURE_COMPARE_MODE: GLenum; - readonly TEXTURE_COMPARE_FUNC: GLenum; - readonly CURRENT_QUERY: GLenum; - readonly QUERY_RESULT: GLenum; - readonly QUERY_RESULT_AVAILABLE: GLenum; - readonly STREAM_READ: GLenum; - readonly STREAM_COPY: GLenum; - readonly STATIC_READ: GLenum; - readonly STATIC_COPY: GLenum; - readonly DYNAMIC_READ: GLenum; - readonly DYNAMIC_COPY: GLenum; - readonly MAX_DRAW_BUFFERS: GLenum; - readonly DRAW_BUFFER0: GLenum; - readonly DRAW_BUFFER1: GLenum; - readonly DRAW_BUFFER2: GLenum; - readonly DRAW_BUFFER3: GLenum; - readonly DRAW_BUFFER4: GLenum; - readonly DRAW_BUFFER5: GLenum; - readonly DRAW_BUFFER6: GLenum; - readonly DRAW_BUFFER7: GLenum; - readonly DRAW_BUFFER8: GLenum; - readonly DRAW_BUFFER9: GLenum; - readonly DRAW_BUFFER10: GLenum; - readonly DRAW_BUFFER11: GLenum; - readonly DRAW_BUFFER12: GLenum; - readonly DRAW_BUFFER13: GLenum; - readonly DRAW_BUFFER14: GLenum; - readonly DRAW_BUFFER15: GLenum; - readonly MAX_FRAGMENT_UNIFORM_COMPONENTS: GLenum; - readonly MAX_VERTEX_UNIFORM_COMPONENTS: GLenum; - readonly SAMPLER_3D: GLenum; - readonly SAMPLER_2D_SHADOW: GLenum; - readonly FRAGMENT_SHADER_DERIVATIVE_HINT: GLenum; - readonly PIXEL_PACK_BUFFER: GLenum; - readonly PIXEL_UNPACK_BUFFER: GLenum; - readonly PIXEL_PACK_BUFFER_BINDING: GLenum; - readonly PIXEL_UNPACK_BUFFER_BINDING: GLenum; - readonly FLOAT_MAT2x3: GLenum; - readonly FLOAT_MAT2x4: GLenum; - readonly FLOAT_MAT3x2: GLenum; - readonly FLOAT_MAT3x4: GLenum; - readonly FLOAT_MAT4x2: GLenum; - readonly FLOAT_MAT4x3: GLenum; - readonly SRGB: GLenum; - readonly SRGB8: GLenum; - readonly SRGB8_ALPHA8: GLenum; - readonly COMPARE_REF_TO_TEXTURE: GLenum; - readonly RGBA32F: GLenum; - readonly RGB32F: GLenum; - readonly RGBA16F: GLenum; - readonly RGB16F: GLenum; - readonly VERTEX_ATTRIB_ARRAY_INTEGER: GLenum; - readonly MAX_ARRAY_TEXTURE_LAYERS: GLenum; - readonly MIN_PROGRAM_TEXEL_OFFSET: GLenum; - readonly MAX_PROGRAM_TEXEL_OFFSET: GLenum; - readonly MAX_VARYING_COMPONENTS: GLenum; - readonly TEXTURE_2D_ARRAY: GLenum; - readonly TEXTURE_BINDING_2D_ARRAY: GLenum; - readonly R11F_G11F_B10F: GLenum; - readonly UNSIGNED_INT_10F_11F_11F_REV: GLenum; - readonly RGB9_E5: GLenum; - readonly UNSIGNED_INT_5_9_9_9_REV: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_MODE: GLenum; - readonly MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: GLenum; - readonly TRANSFORM_FEEDBACK_VARYINGS: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_START: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_SIZE: GLenum; - readonly TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: GLenum; - readonly RASTERIZER_DISCARD: GLenum; - readonly MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: GLenum; - readonly MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: GLenum; - readonly INTERLEAVED_ATTRIBS: GLenum; - readonly SEPARATE_ATTRIBS: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_BINDING: GLenum; - readonly RGBA32UI: GLenum; - readonly RGB32UI: GLenum; - readonly RGBA16UI: GLenum; - readonly RGB16UI: GLenum; - readonly RGBA8UI: GLenum; - readonly RGB8UI: GLenum; - readonly RGBA32I: GLenum; - readonly RGB32I: GLenum; - readonly RGBA16I: GLenum; - readonly RGB16I: GLenum; - readonly RGBA8I: GLenum; - readonly RGB8I: GLenum; - readonly RED_INTEGER: GLenum; - readonly RGB_INTEGER: GLenum; - readonly RGBA_INTEGER: GLenum; - readonly SAMPLER_2D_ARRAY: GLenum; - readonly SAMPLER_2D_ARRAY_SHADOW: GLenum; - readonly SAMPLER_CUBE_SHADOW: GLenum; - readonly UNSIGNED_INT_VEC2: GLenum; - readonly UNSIGNED_INT_VEC3: GLenum; - readonly UNSIGNED_INT_VEC4: GLenum; - readonly INT_SAMPLER_2D: GLenum; - readonly INT_SAMPLER_3D: GLenum; - readonly INT_SAMPLER_CUBE: GLenum; - readonly INT_SAMPLER_2D_ARRAY: GLenum; - readonly UNSIGNED_INT_SAMPLER_2D: GLenum; - readonly UNSIGNED_INT_SAMPLER_3D: GLenum; - readonly UNSIGNED_INT_SAMPLER_CUBE: GLenum; - readonly UNSIGNED_INT_SAMPLER_2D_ARRAY: GLenum; - readonly DEPTH_COMPONENT32F: GLenum; - readonly DEPTH32F_STENCIL8: GLenum; - readonly FLOAT_32_UNSIGNED_INT_24_8_REV: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_RED_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: GLenum; - readonly FRAMEBUFFER_DEFAULT: GLenum; - readonly UNSIGNED_INT_24_8: GLenum; - readonly DEPTH24_STENCIL8: GLenum; - readonly UNSIGNED_NORMALIZED: GLenum; - readonly DRAW_FRAMEBUFFER_BINDING: GLenum; - readonly READ_FRAMEBUFFER: GLenum; - readonly DRAW_FRAMEBUFFER: GLenum; - readonly READ_FRAMEBUFFER_BINDING: GLenum; - - readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: GLenum; - readonly MAX_COLOR_ATTACHMENTS: GLenum; - readonly COLOR_ATTACHMENT1: GLenum; - readonly COLOR_ATTACHMENT2: GLenum; - readonly COLOR_ATTACHMENT3: GLenum; - readonly COLOR_ATTACHMENT4: GLenum; - readonly COLOR_ATTACHMENT5: GLenum; - readonly COLOR_ATTACHMENT6: GLenum; - readonly COLOR_ATTACHMENT7: GLenum; - readonly COLOR_ATTACHMENT8: GLenum; - readonly COLOR_ATTACHMENT9: GLenum; - readonly COLOR_ATTACHMENT10: GLenum; - readonly COLOR_ATTACHMENT11: GLenum; - readonly COLOR_ATTACHMENT12: GLenum; - readonly COLOR_ATTACHMENT13: GLenum; - readonly COLOR_ATTACHMENT14: GLenum; - readonly COLOR_ATTACHMENT15: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: GLenum; - readonly MAX_SAMPLES: GLenum; - readonly HALF_FLOAT: GLenum; - readonly RG: GLenum; - readonly RG_INTEGER: GLenum; - readonly R8: GLenum; - readonly RG8: GLenum; - readonly R16F: GLenum; - - readonly R32F: GLenum; - readonly RG16F: GLenum; - readonly RG32F: GLenum; - readonly R8I: GLenum; - readonly R8UI: GLenum; - readonly R16I: GLenum; - readonly R16UI: GLenum; - readonly R32I: GLenum; - readonly R32UI: GLenum; - readonly RG8I: GLenum; - readonly RG8UI: GLenum; - readonly RG16I: GLenum; - readonly RG16UI: GLenum; - readonly RG32I: GLenum; - readonly RG32UI: GLenum; - readonly VERTEX_ARRAY_BINDING: GLenum; - readonly R8_SNORM: GLenum; - readonly RG8_SNORM: GLenum; - readonly RGB8_SNORM: GLenum; - readonly RGBA8_SNORM: GLenum; - readonly SIGNED_NORMALIZED: GLenum; - readonly COPY_READ_BUFFER: GLenum; - readonly COPY_WRITE_BUFFER: GLenum; - readonly COPY_READ_BUFFER_BINDING: GLenum; /* Same as COPY_READ_BUFFER */ - readonly COPY_WRITE_BUFFER_BINDING: GLenum; /* Same as COPY_WRITE_BUFFER */ - readonly UNIFORM_BUFFER: GLenum; - readonly UNIFORM_BUFFER_BINDING: GLenum; - readonly UNIFORM_BUFFER_START: GLenum; - readonly UNIFORM_BUFFER_SIZE: GLenum; - readonly MAX_VERTEX_UNIFORM_BLOCKS: GLenum; - readonly MAX_FRAGMENT_UNIFORM_BLOCKS: GLenum; - readonly MAX_COMBINED_UNIFORM_BLOCKS: GLenum; - readonly MAX_UNIFORM_BUFFER_BINDINGS: GLenum; - readonly MAX_UNIFORM_BLOCK_SIZE: GLenum; - readonly MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: GLenum; - readonly MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: GLenum; - readonly UNIFORM_BUFFER_OFFSET_ALIGNMENT: GLenum; - readonly ACTIVE_UNIFORM_BLOCKS: GLenum; - readonly UNIFORM_TYPE: GLenum; - readonly UNIFORM_SIZE: GLenum; - readonly UNIFORM_BLOCK_INDEX: GLenum; - readonly UNIFORM_OFFSET: GLenum; - readonly UNIFORM_ARRAY_STRIDE: GLenum; - readonly UNIFORM_MATRIX_STRIDE: GLenum; - readonly UNIFORM_IS_ROW_MAJOR: GLenum; - readonly UNIFORM_BLOCK_BINDING: GLenum; - readonly UNIFORM_BLOCK_DATA_SIZE: GLenum; - readonly UNIFORM_BLOCK_ACTIVE_UNIFORMS: GLenum; - readonly UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: GLenum; - readonly UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: GLenum; - readonly UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: GLenum; - readonly INVALID_INDEX: GLenum; - readonly MAX_VERTEX_OUTPUT_COMPONENTS: GLenum; - readonly MAX_FRAGMENT_INPUT_COMPONENTS: GLenum; - readonly MAX_SERVER_WAIT_TIMEOUT: GLenum; - readonly OBJECT_TYPE: GLenum; - readonly SYNC_CONDITION: GLenum; - readonly SYNC_STATUS: GLenum; - readonly SYNC_FLAGS: GLenum; - readonly SYNC_FENCE: GLenum; - readonly SYNC_GPU_COMMANDS_COMPLETE: GLenum; - readonly UNSIGNALED: GLenum; - readonly SIGNALED: GLenum; - readonly ALREADY_SIGNALED: GLenum; - readonly TIMEOUT_EXPIRED: GLenum; - readonly CONDITION_SATISFIED: GLenum; - readonly WAIT_FAILED: GLenum; - readonly SYNC_FLUSH_COMMANDS_BIT: GLenum; - readonly VERTEX_ATTRIB_ARRAY_DIVISOR: GLenum; - readonly ANY_SAMPLES_PASSED: GLenum; - readonly ANY_SAMPLES_PASSED_CONSERVATIVE: GLenum; - readonly SAMPLER_BINDING: GLenum; - readonly RGB10_A2UI: GLenum; - readonly INT_2_10_10_10_REV: GLenum; - readonly TRANSFORM_FEEDBACK: GLenum; - readonly TRANSFORM_FEEDBACK_PAUSED: GLenum; - readonly TRANSFORM_FEEDBACK_ACTIVE: GLenum; - readonly TRANSFORM_FEEDBACK_BINDING: GLenum; - readonly TEXTURE_IMMUTABLE_FORMAT: GLenum; - readonly MAX_ELEMENT_INDEX: GLenum; - readonly TEXTURE_IMMUTABLE_LEVELS: GLenum; - - readonly TIMEOUT_IGNORED: GLint64; - - /* WebGL-specific enums */ - readonly MAX_CLIENT_WAIT_TIMEOUT_WEBGL: GLenum; -}; - -interface WebGL2RenderingContextBase { - readonly canvas: HTMLCanvasElement; - readonly drawingBufferHeight: GLsizei; - readonly drawingBufferWidth: GLsizei; - - /* Buffer objects */ - // WebGL1: - bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum): void; - bufferData(target: GLenum, data: BufferSource | null, usage: GLenum): void; - bufferSubData(target: GLenum, dstOffset: GLintptr, data: BufferSource): void; - - // WebGL2: - bufferData(target: GLenum, data: BufferSource, usage: GLenum, srcOffset: GLintptr, length?: GLuint): void; - bufferSubData(target: GLenum, dstOffset: GLintptr, data: ArrayBufferView, srcOffset: GLintptr, length?: GLuint): void; - - copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr): void; - // MapBufferRange, in particular its read-only and write-only modes, - // can not be exposed safely to JavaScript. GetBufferSubData - // replaces it for the purpose of fetching data back from the GPU. - getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: BufferSource, dstOffset?: GLuint, length?: GLuint): void; - - /* Framebuffer objects */ - blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum): void; - framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture | null, level: GLint, layer: GLint): void; - invalidateFramebuffer(target: GLenum, attachments: GLenum[]): void; - invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; - readBuffer(src: GLenum): void; - - /* Renderbuffer objects */ - getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum): any; - renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei): void; - - /* Texture objects */ - texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei): void; - texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei): void; - - // WebGL1 legacy entrypoints: - texImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void; - texImage2D(target: GLenum, level: GLint, internalformat: GLenum, format: GLenum, type: GLenum, source: TexImageSource): void; // May throw DOMException - - texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void; - texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; // May throw DOMException - - // WebGL2 entrypoints: - texImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr): void; - texImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; // May throw DOMException - texImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint): void; - - texImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr): void; - texImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; // May throw DOMException - texImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView): void; - texImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint): void; - - texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr): void; - texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource): void; // May throw DOMException - texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint): void; - - texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr): void; - texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource): void; // May throw DOMException - texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView | null, srcOffset?: GLuint): void; - - copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; - - compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr): void; - compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; - compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr): void; - compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; - - compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr): void; - compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; - compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr): void; - compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; - - /* Programs and shaders */ - getFragDataLocation(program: WebGLProgram, name: string): GLint; - - /* Uniforms */ - uniform1ui(location: WebGLUniformLocation, v0: GLuint): void; - uniform2ui(location: WebGLUniformLocation, v0: GLuint, v1: GLuint): void; - uniform3ui(location: WebGLUniformLocation, v0: GLuint, v1: GLuint, v2: GLuint): void; - uniform4ui(location: WebGLUniformLocation, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint): void; - - uniform1fv(location: WebGLUniformLocation, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform2fv(location: WebGLUniformLocation, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform3fv(location: WebGLUniformLocation, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform4fv(location: WebGLUniformLocation, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - - uniform1iv(location: WebGLUniformLocation, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform2iv(location: WebGLUniformLocation, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform3iv(location: WebGLUniformLocation, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform4iv(location: WebGLUniformLocation, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; - - uniform1uiv(location: WebGLUniformLocation, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform2uiv(location: WebGLUniformLocation, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform3uiv(location: WebGLUniformLocation, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform4uiv(location: WebGLUniformLocation, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; - - uniformMatrix2fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix3x2fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4x2fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix2x3fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4x3fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix2x4fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix3x4fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; - - /* Vertex attribs */ - vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint): void; - vertexAttribI4iv(index: GLuint, values: Int32List): void; - vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint): void; - vertexAttribI4uiv(index: GLuint, values: Uint32List): void; - vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr): void; - - /* Writing to the drawing buffer */ - vertexAttribDivisor(index: GLuint, divisor: GLuint): void; - drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei): void; - drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei): void; - drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr): void; - - /* Reading back pixels */ - // WebGL1: - readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView | null): void; - // WebGL2: - readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr): void; - readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint): void; - - /* Multiple Render Targets */ - drawBuffers(buffers: GLenum[]): void; - clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint): void; - clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint): void; - clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint): void; - clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint): void; - - /* Query Objects */ - createQuery(): WebGLQuery | null; - deleteQuery(query: WebGLQuery | null): void; - isQuery(query: WebGLQuery): GLboolean; - beginQuery(target: GLenum, query: WebGLQuery): void; - endQuery(target: GLenum): void; - getQuery(target: GLenum, pname: GLenum): WebGLQuery | null; - getQueryParameter(query: WebGLQuery, pname: GLenum): any; - - /* Sampler Objects */ - createSampler(): WebGLSampler | null; - deleteSampler(sampler: WebGLSampler | null): void; - isSampler(sampler: WebGLSampler | null): GLboolean; - bindSampler(unit: GLuint, sampler: WebGLSampler | null): void; - samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint): void; - samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat): void; - getSamplerParameter(sampler: WebGLSampler, pname: GLenum): any; - - /* Sync objects */ - fenceSync(condition: GLenum, flags: GLbitfield): WebGLSync | null; - isSync(sync: WebGLSync | null): GLboolean; - deleteSync(sync: WebGLSync | null): void; - clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64): GLenum; - waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64): void; - getSyncParameter(sync: WebGLSync, pname: GLenum): any; - - /* Transform Feedback */ - createTransformFeedback(): WebGLTransformFeedback | null; - deleteTransformFeedback(tf: WebGLTransformFeedback | null): void; - isTransformFeedback(tf: WebGLTransformFeedback | null): GLboolean; - bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback | null): void; - beginTransformFeedback(primitiveMode: GLenum): void; - endTransformFeedback(): void; - transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum): void; - getTransformFeedbackVarying(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null; - pauseTransformFeedback(): void; - resumeTransformFeedback(): void; - - /* Uniform Buffer Objects and Transform Feedback Buffers */ - bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer | null): void; - bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer | null, offset: GLintptr, size: GLsizeiptr): void; - getIndexedParameter(target: GLenum, index: GLuint): any; - getUniformIndices(program: WebGLProgram, uniformNames: string[]): GLuint[] | null; - getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum): any; - getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): GLuint; - getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum): any; - getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint): string | null; - uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint): void; - - /* Vertex Array Objects */ - createVertexArray(): WebGLVertexArrayObject | null; - deleteVertexArray(vertexArray: WebGLVertexArrayObject | null): void; - isVertexArray(vertexArray: WebGLVertexArrayObject | null): GLboolean; - bindVertexArray(array: WebGLVertexArrayObject | null): void; - - activeTexture(texture: GLenum): void; - attachShader(program: WebGLProgram, shader: WebGLShader): void; - bindAttribLocation(program: WebGLProgram, index: GLuint, name: string): void; - bindBuffer(target: GLenum, buffer: WebGLBuffer | null): void; - bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer | null): void; - bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer | null): void; - bindTexture(target: GLenum, texture: WebGLTexture | null): void; - blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void; - blendEquation(mode: GLenum): void; - blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum): void; - blendFunc(sfactor: GLenum, dfactor: GLenum): void; - blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum): void; - bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum): void; - bufferData(target: GLenum, data: BufferSource | null, usage: GLenum): void; - bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource): void; - checkFramebufferStatus(target: GLenum): GLenum; - clear(mask: GLbitfield): void; - clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void; - clearDepth(depth: GLclampf): void; - clearStencil(s: GLint): void; - colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean): void; - compileShader(shader: WebGLShader): void; - copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint): void; - copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; - createBuffer(): WebGLBuffer | null; - createFramebuffer(): WebGLFramebuffer | null; - createProgram(): WebGLProgram | null; - createRenderbuffer(): WebGLRenderbuffer | null; - createShader(type: GLenum): WebGLShader | null; - createTexture(): WebGLTexture | null; - cullFace(mode: GLenum): void; - deleteBuffer(buffer: WebGLBuffer | null): void; - deleteFramebuffer(framebuffer: WebGLFramebuffer | null): void; - deleteProgram(program: WebGLProgram | null): void; - deleteRenderbuffer(renderbuffer: WebGLRenderbuffer | null): void; - deleteShader(shader: WebGLShader | null): void; - deleteTexture(texture: WebGLTexture | null): void; - depthFunc(func: GLenum): void; - depthMask(flag: GLboolean): void; - depthRange(zNear: GLclampf, zFar: GLclampf): void; - detachShader(program: WebGLProgram, shader: WebGLShader): void; - disable(cap: GLenum): void; - disableVertexAttribArray(index: GLuint): void; - drawArrays(mode: GLenum, first: GLint, count: GLsizei): void; - drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr): void; - enable(cap: GLenum): void; - enableVertexAttribArray(index: GLuint): void; - finish(): void; - flush(): void; - framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer | null): void; - framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture | null, level: GLint): void; - frontFace(mode: GLenum): void; - generateMipmap(target: GLenum): void; - getActiveAttrib(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null; - getActiveUniform(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null; - getAttachedShaders(program: WebGLProgram): WebGLShader[] | null; - getAttribLocation(program: WebGLProgram, name: string): GLint; - getBufferParameter(target: GLenum, pname: GLenum): any; - getContextAttributes(): WebGLContextAttributes | null; - getError(): GLenum; - getExtension(extensionName: string): any; - getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum): any; - getParameter(pname: GLenum): any; - getProgramInfoLog(program: WebGLProgram): string | null; - getProgramParameter(program: WebGLProgram, pname: GLenum): any; - getRenderbufferParameter(target: GLenum, pname: GLenum): any; - getShaderInfoLog(shader: WebGLShader): string | null; - getShaderParameter(shader: WebGLShader, pname: GLenum): any; - getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum): WebGLShaderPrecisionFormat | null; - getShaderSource(shader: WebGLShader): string | null; - getSupportedExtensions(): string[] | null; - getTexParameter(target: GLenum, pname: GLenum): any; - getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; - getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation | null; - getVertexAttrib(index: GLuint, pname: GLenum): any; - getVertexAttribOffset(index: GLuint, pname: GLenum): GLintptr; - hint(target: GLenum, mode: GLenum): void; - isBuffer(buffer: WebGLBuffer | null): GLboolean; - isContextLost(): boolean; - isEnabled(cap: GLenum): GLboolean; - isFramebuffer(framebuffer: WebGLFramebuffer | null): GLboolean; - isProgram(program: WebGLProgram | null): GLboolean; - isRenderbuffer(renderbuffer: WebGLRenderbuffer | null): GLboolean; - isShader(shader: WebGLShader | null): GLboolean; - isTexture(texture: WebGLTexture | null): GLboolean; - lineWidth(width: GLfloat): void; - linkProgram(program: WebGLProgram): void; - pixelStorei(pname: GLenum, param: GLint): void; - polygonOffset(factor: GLfloat, units: GLfloat): void; - readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void; - renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei): void; - sampleCoverage(value: GLclampf, invert: GLboolean): void; - scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; - shaderSource(shader: WebGLShader, source: string): void; - stencilFunc(func: GLenum, ref: GLint, mask: GLuint): void; - stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint): void; - stencilMask(mask: GLuint): void; - stencilMaskSeparate(face: GLenum, mask: GLuint): void; - stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum): void; - stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum): void; - texParameterf(target: GLenum, pname: GLenum, param: GLfloat): void; - texParameteri(target: GLenum, pname: GLenum, param: GLint): void; - - useProgram(program: WebGLProgram | null): void; - validateProgram(program: WebGLProgram): void; - vertexAttrib1f(index: GLuint, x: GLfloat): void; - vertexAttrib1fv(index: GLuint, values: Float32List): void; - vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat): void; - vertexAttrib2fv(index: GLuint, values: Float32List): void; - vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat): void; - vertexAttrib3fv(index: GLuint, values: Float32List): void; - vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void; - vertexAttrib4fv(index: GLuint, values: Float32List): void; - vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr): void; - viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; - readonly ACTIVE_ATTRIBUTES: GLenum; - readonly ACTIVE_TEXTURE: GLenum; - readonly ACTIVE_UNIFORMS: GLenum; - readonly ALIASED_LINE_WIDTH_RANGE: GLenum; - readonly ALIASED_POINT_SIZE_RANGE: GLenum; - readonly ALPHA: GLenum; - readonly ALPHA_BITS: GLenum; - readonly ALWAYS: GLenum; - readonly ARRAY_BUFFER: GLenum; - readonly ARRAY_BUFFER_BINDING: GLenum; - readonly ATTACHED_SHADERS: GLenum; - readonly BACK: GLenum; - readonly BLEND: GLenum; - readonly BLEND_COLOR: GLenum; - readonly BLEND_DST_ALPHA: GLenum; - readonly BLEND_DST_RGB: GLenum; - readonly BLEND_EQUATION: GLenum; - readonly BLEND_EQUATION_ALPHA: GLenum; - readonly BLEND_EQUATION_RGB: GLenum; - readonly BLEND_SRC_ALPHA: GLenum; - readonly BLEND_SRC_RGB: GLenum; - readonly BLUE_BITS: GLenum; - readonly BOOL: GLenum; - readonly BOOL_VEC2: GLenum; - readonly BOOL_VEC3: GLenum; - readonly BOOL_VEC4: GLenum; - readonly BROWSER_DEFAULT_WEBGL: GLenum; - readonly BUFFER_SIZE: GLenum; - readonly BUFFER_USAGE: GLenum; - readonly BYTE: GLenum; - readonly CCW: GLenum; - readonly CLAMP_TO_EDGE: GLenum; - readonly COLOR_ATTACHMENT0: GLenum; - readonly COLOR_BUFFER_BIT: GLenum; - readonly COLOR_CLEAR_VALUE: GLenum; - readonly COLOR_WRITEMASK: GLenum; - readonly COMPILE_STATUS: GLenum; - readonly COMPRESSED_TEXTURE_FORMATS: GLenum; - readonly CONSTANT_ALPHA: GLenum; - readonly CONSTANT_COLOR: GLenum; - readonly CONTEXT_LOST_WEBGL: GLenum; - readonly CULL_FACE: GLenum; - readonly CULL_FACE_MODE: GLenum; - readonly CURRENT_PROGRAM: GLenum; - readonly CURRENT_VERTEX_ATTRIB: GLenum; - readonly CW: GLenum; - readonly DECR: GLenum; - readonly DECR_WRAP: GLenum; - readonly DELETE_STATUS: GLenum; - readonly DEPTH_ATTACHMENT: GLenum; - readonly DEPTH_BITS: GLenum; - readonly DEPTH_BUFFER_BIT: GLenum; - readonly DEPTH_CLEAR_VALUE: GLenum; - readonly DEPTH_COMPONENT: GLenum; - readonly DEPTH_COMPONENT16: GLenum; - readonly DEPTH_FUNC: GLenum; - readonly DEPTH_RANGE: GLenum; - readonly DEPTH_STENCIL: GLenum; - readonly DEPTH_STENCIL_ATTACHMENT: GLenum; - readonly DEPTH_TEST: GLenum; - readonly DEPTH_WRITEMASK: GLenum; - readonly DITHER: GLenum; - readonly DONT_CARE: GLenum; - readonly DST_ALPHA: GLenum; - readonly DST_COLOR: GLenum; - readonly DYNAMIC_DRAW: GLenum; - readonly ELEMENT_ARRAY_BUFFER: GLenum; - readonly ELEMENT_ARRAY_BUFFER_BINDING: GLenum; - readonly EQUAL: GLenum; - readonly FASTEST: GLenum; - readonly FLOAT: GLenum; - readonly FLOAT_MAT2: GLenum; - readonly FLOAT_MAT3: GLenum; - readonly FLOAT_MAT4: GLenum; - readonly FLOAT_VEC2: GLenum; - readonly FLOAT_VEC3: GLenum; - readonly FLOAT_VEC4: GLenum; - readonly FRAGMENT_SHADER: GLenum; - readonly FRAMEBUFFER: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: GLenum; - readonly FRAMEBUFFER_BINDING: GLenum; - readonly FRAMEBUFFER_COMPLETE: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLenum; - readonly FRAMEBUFFER_UNSUPPORTED: GLenum; - readonly FRONT: GLenum; - readonly FRONT_AND_BACK: GLenum; - readonly FRONT_FACE: GLenum; - readonly FUNC_ADD: GLenum; - readonly FUNC_REVERSE_SUBTRACT: GLenum; - readonly FUNC_SUBTRACT: GLenum; - readonly GENERATE_MIPMAP_HINT: GLenum; - readonly GEQUAL: GLenum; - readonly GREATER: GLenum; - readonly GREEN_BITS: GLenum; - readonly HIGH_FLOAT: GLenum; - readonly HIGH_INT: GLenum; - readonly IMPLEMENTATION_COLOR_READ_FORMAT: GLenum; - readonly IMPLEMENTATION_COLOR_READ_TYPE: GLenum; - readonly INCR: GLenum; - readonly INCR_WRAP: GLenum; - readonly INT: GLenum; - readonly INT_VEC2: GLenum; - readonly INT_VEC3: GLenum; - readonly INT_VEC4: GLenum; - readonly INVALID_ENUM: GLenum; - readonly INVALID_FRAMEBUFFER_OPERATION: GLenum; - readonly INVALID_OPERATION: GLenum; - readonly INVALID_VALUE: GLenum; - readonly INVERT: GLenum; - readonly KEEP: GLenum; - readonly LEQUAL: GLenum; - readonly LESS: GLenum; - readonly LINEAR: GLenum; - readonly LINEAR_MIPMAP_LINEAR: GLenum; - readonly LINEAR_MIPMAP_NEAREST: GLenum; - readonly LINES: GLenum; - readonly LINE_LOOP: GLenum; - readonly LINE_STRIP: GLenum; - readonly LINE_WIDTH: GLenum; - readonly LINK_STATUS: GLenum; - readonly LOW_FLOAT: GLenum; - readonly LOW_INT: GLenum; - readonly LUMINANCE: GLenum; - readonly LUMINANCE_ALPHA: GLenum; - readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: GLenum; - readonly MAX_CUBE_MAP_TEXTURE_SIZE: GLenum; - readonly MAX_FRAGMENT_UNIFORM_VECTORS: GLenum; - readonly MAX_RENDERBUFFER_SIZE: GLenum; - readonly MAX_TEXTURE_IMAGE_UNITS: GLenum; - readonly MAX_TEXTURE_SIZE: GLenum; - readonly MAX_VARYING_VECTORS: GLenum; - readonly MAX_VERTEX_ATTRIBS: GLenum; - readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: GLenum; - readonly MAX_VERTEX_UNIFORM_VECTORS: GLenum; - readonly MAX_VIEWPORT_DIMS: GLenum; - readonly MEDIUM_FLOAT: GLenum; - readonly MEDIUM_INT: GLenum; - readonly MIRRORED_REPEAT: GLenum; - readonly NEAREST: GLenum; - readonly NEAREST_MIPMAP_LINEAR: GLenum; - readonly NEAREST_MIPMAP_NEAREST: GLenum; - readonly NEVER: GLenum; - readonly NICEST: GLenum; - readonly NONE: GLenum; - readonly NOTEQUAL: GLenum; - readonly NO_ERROR: GLenum; - readonly ONE: GLenum; - readonly ONE_MINUS_CONSTANT_ALPHA: GLenum; - readonly ONE_MINUS_CONSTANT_COLOR: GLenum; - readonly ONE_MINUS_DST_ALPHA: GLenum; - readonly ONE_MINUS_DST_COLOR: GLenum; - readonly ONE_MINUS_SRC_ALPHA: GLenum; - readonly ONE_MINUS_SRC_COLOR: GLenum; - readonly OUT_OF_MEMORY: GLenum; - readonly PACK_ALIGNMENT: GLenum; - readonly POINTS: GLenum; - readonly POLYGON_OFFSET_FACTOR: GLenum; - readonly POLYGON_OFFSET_FILL: GLenum; - readonly POLYGON_OFFSET_UNITS: GLenum; - readonly RED_BITS: GLenum; - readonly RENDERBUFFER: GLenum; - readonly RENDERBUFFER_ALPHA_SIZE: GLenum; - readonly RENDERBUFFER_BINDING: GLenum; - readonly RENDERBUFFER_BLUE_SIZE: GLenum; - readonly RENDERBUFFER_DEPTH_SIZE: GLenum; - readonly RENDERBUFFER_GREEN_SIZE: GLenum; - readonly RENDERBUFFER_HEIGHT: GLenum; - readonly RENDERBUFFER_INTERNAL_FORMAT: GLenum; - readonly RENDERBUFFER_RED_SIZE: GLenum; - readonly RENDERBUFFER_STENCIL_SIZE: GLenum; - readonly RENDERBUFFER_WIDTH: GLenum; - readonly RENDERER: GLenum; - readonly REPEAT: GLenum; - readonly REPLACE: GLenum; - readonly RGB: GLenum; - readonly RGB565: GLenum; - readonly RGB5_A1: GLenum; - readonly RGBA: GLenum; - readonly RGBA4: GLenum; - readonly SAMPLER_2D: GLenum; - readonly SAMPLER_CUBE: GLenum; - readonly SAMPLES: GLenum; - readonly SAMPLE_ALPHA_TO_COVERAGE: GLenum; - readonly SAMPLE_BUFFERS: GLenum; - readonly SAMPLE_COVERAGE: GLenum; - readonly SAMPLE_COVERAGE_INVERT: GLenum; - readonly SAMPLE_COVERAGE_VALUE: GLenum; - readonly SCISSOR_BOX: GLenum; - readonly SCISSOR_TEST: GLenum; - readonly SHADER_TYPE: GLenum; - readonly SHADING_LANGUAGE_VERSION: GLenum; - readonly SHORT: GLenum; - readonly SRC_ALPHA: GLenum; - readonly SRC_ALPHA_SATURATE: GLenum; - readonly SRC_COLOR: GLenum; - readonly STATIC_DRAW: GLenum; - readonly STENCIL_ATTACHMENT: GLenum; - readonly STENCIL_BACK_FAIL: GLenum; - readonly STENCIL_BACK_FUNC: GLenum; - readonly STENCIL_BACK_PASS_DEPTH_FAIL: GLenum; - readonly STENCIL_BACK_PASS_DEPTH_PASS: GLenum; - readonly STENCIL_BACK_REF: GLenum; - readonly STENCIL_BACK_VALUE_MASK: GLenum; - readonly STENCIL_BACK_WRITEMASK: GLenum; - readonly STENCIL_BITS: GLenum; - readonly STENCIL_BUFFER_BIT: GLenum; - readonly STENCIL_CLEAR_VALUE: GLenum; - readonly STENCIL_FAIL: GLenum; - readonly STENCIL_FUNC: GLenum; - readonly STENCIL_INDEX8: GLenum; - readonly STENCIL_PASS_DEPTH_FAIL: GLenum; - readonly STENCIL_PASS_DEPTH_PASS: GLenum; - readonly STENCIL_REF: GLenum; - readonly STENCIL_TEST: GLenum; - readonly STENCIL_VALUE_MASK: GLenum; - readonly STENCIL_WRITEMASK: GLenum; - readonly STREAM_DRAW: GLenum; - readonly SUBPIXEL_BITS: GLenum; - readonly TEXTURE: GLenum; - readonly TEXTURE0: GLenum; - readonly TEXTURE1: GLenum; - readonly TEXTURE10: GLenum; - readonly TEXTURE11: GLenum; - readonly TEXTURE12: GLenum; - readonly TEXTURE13: GLenum; - readonly TEXTURE14: GLenum; - readonly TEXTURE15: GLenum; - readonly TEXTURE16: GLenum; - readonly TEXTURE17: GLenum; - readonly TEXTURE18: GLenum; - readonly TEXTURE19: GLenum; - readonly TEXTURE2: GLenum; - readonly TEXTURE20: GLenum; - readonly TEXTURE21: GLenum; - readonly TEXTURE22: GLenum; - readonly TEXTURE23: GLenum; - readonly TEXTURE24: GLenum; - readonly TEXTURE25: GLenum; - readonly TEXTURE26: GLenum; - readonly TEXTURE27: GLenum; - readonly TEXTURE28: GLenum; - readonly TEXTURE29: GLenum; - readonly TEXTURE3: GLenum; - readonly TEXTURE30: GLenum; - readonly TEXTURE31: GLenum; - readonly TEXTURE4: GLenum; - readonly TEXTURE5: GLenum; - readonly TEXTURE6: GLenum; - readonly TEXTURE7: GLenum; - readonly TEXTURE8: GLenum; - readonly TEXTURE9: GLenum; - readonly TEXTURE_2D: GLenum; - readonly TEXTURE_BINDING_2D: GLenum; - readonly TEXTURE_BINDING_CUBE_MAP: GLenum; - readonly TEXTURE_CUBE_MAP: GLenum; - readonly TEXTURE_CUBE_MAP_NEGATIVE_X: GLenum; - readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: GLenum; - readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: GLenum; - readonly TEXTURE_CUBE_MAP_POSITIVE_X: GLenum; - readonly TEXTURE_CUBE_MAP_POSITIVE_Y: GLenum; - readonly TEXTURE_CUBE_MAP_POSITIVE_Z: GLenum; - readonly TEXTURE_MAG_FILTER: GLenum; - readonly TEXTURE_MIN_FILTER: GLenum; - readonly TEXTURE_WRAP_S: GLenum; - readonly TEXTURE_WRAP_T: GLenum; - readonly TRIANGLES: GLenum; - readonly TRIANGLE_FAN: GLenum; - readonly TRIANGLE_STRIP: GLenum; - readonly UNPACK_ALIGNMENT: GLenum; - readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: GLenum; - readonly UNPACK_FLIP_Y_WEBGL: GLenum; - readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: GLenum; - readonly UNSIGNED_BYTE: GLenum; - readonly UNSIGNED_INT: GLenum; - readonly UNSIGNED_SHORT: GLenum; - readonly UNSIGNED_SHORT_4_4_4_4: GLenum; - readonly UNSIGNED_SHORT_5_5_5_1: GLenum; - readonly UNSIGNED_SHORT_5_6_5: GLenum; - readonly VALIDATE_STATUS: GLenum; - readonly VENDOR: GLenum; - readonly VERSION: GLenum; - readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: GLenum; - readonly VERTEX_ATTRIB_ARRAY_ENABLED: GLenum; - readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: GLenum; - readonly VERTEX_ATTRIB_ARRAY_POINTER: GLenum; - readonly VERTEX_ATTRIB_ARRAY_SIZE: GLenum; - readonly VERTEX_ATTRIB_ARRAY_STRIDE: GLenum; - readonly VERTEX_ATTRIB_ARRAY_TYPE: GLenum; - readonly VERTEX_SHADER: GLenum; - readonly VIEWPORT: GLenum; - readonly ZERO: GLenum; - - readonly READ_BUFFER: GLenum; - readonly UNPACK_ROW_LENGTH: GLenum; - readonly UNPACK_SKIP_ROWS: GLenum; - readonly UNPACK_SKIP_PIXELS: GLenum; - readonly PACK_ROW_LENGTH: GLenum; - readonly PACK_SKIP_ROWS: GLenum; - readonly PACK_SKIP_PIXELS: GLenum; - readonly COLOR: GLenum; - readonly DEPTH: GLenum; - readonly STENCIL: GLenum; - readonly RED: GLenum; - readonly RGB8: GLenum; - readonly RGBA8: GLenum; - readonly RGB10_A2: GLenum; - readonly TEXTURE_BINDING_3D: GLenum; - readonly UNPACK_SKIP_IMAGES: GLenum; - readonly UNPACK_IMAGE_HEIGHT: GLenum; - readonly TEXTURE_3D: GLenum; - readonly TEXTURE_WRAP_R: GLenum; - readonly MAX_3D_TEXTURE_SIZE: GLenum; - readonly UNSIGNED_INT_2_10_10_10_REV: GLenum; - readonly MAX_ELEMENTS_VERTICES: GLenum; - readonly MAX_ELEMENTS_INDICES: GLenum; - readonly TEXTURE_MIN_LOD: GLenum; - readonly TEXTURE_MAX_LOD: GLenum; - readonly TEXTURE_BASE_LEVEL: GLenum; - readonly TEXTURE_MAX_LEVEL: GLenum; - readonly MIN: GLenum; - readonly MAX: GLenum; - readonly DEPTH_COMPONENT24: GLenum; - readonly MAX_TEXTURE_LOD_BIAS: GLenum; - readonly TEXTURE_COMPARE_MODE: GLenum; - readonly TEXTURE_COMPARE_FUNC: GLenum; - readonly CURRENT_QUERY: GLenum; - readonly QUERY_RESULT: GLenum; - readonly QUERY_RESULT_AVAILABLE: GLenum; - readonly STREAM_READ: GLenum; - readonly STREAM_COPY: GLenum; - readonly STATIC_READ: GLenum; - readonly STATIC_COPY: GLenum; - readonly DYNAMIC_READ: GLenum; - readonly DYNAMIC_COPY: GLenum; - readonly MAX_DRAW_BUFFERS: GLenum; - readonly DRAW_BUFFER0: GLenum; - readonly DRAW_BUFFER1: GLenum; - readonly DRAW_BUFFER2: GLenum; - readonly DRAW_BUFFER3: GLenum; - readonly DRAW_BUFFER4: GLenum; - readonly DRAW_BUFFER5: GLenum; - readonly DRAW_BUFFER6: GLenum; - readonly DRAW_BUFFER7: GLenum; - readonly DRAW_BUFFER8: GLenum; - readonly DRAW_BUFFER9: GLenum; - readonly DRAW_BUFFER10: GLenum; - readonly DRAW_BUFFER11: GLenum; - readonly DRAW_BUFFER12: GLenum; - readonly DRAW_BUFFER13: GLenum; - readonly DRAW_BUFFER14: GLenum; - readonly DRAW_BUFFER15: GLenum; - readonly MAX_FRAGMENT_UNIFORM_COMPONENTS: GLenum; - readonly MAX_VERTEX_UNIFORM_COMPONENTS: GLenum; - readonly SAMPLER_3D: GLenum; - readonly SAMPLER_2D_SHADOW: GLenum; - readonly FRAGMENT_SHADER_DERIVATIVE_HINT: GLenum; - readonly PIXEL_PACK_BUFFER: GLenum; - readonly PIXEL_UNPACK_BUFFER: GLenum; - readonly PIXEL_PACK_BUFFER_BINDING: GLenum; - readonly PIXEL_UNPACK_BUFFER_BINDING: GLenum; - readonly FLOAT_MAT2x3: GLenum; - readonly FLOAT_MAT2x4: GLenum; - readonly FLOAT_MAT3x2: GLenum; - readonly FLOAT_MAT3x4: GLenum; - readonly FLOAT_MAT4x2: GLenum; - readonly FLOAT_MAT4x3: GLenum; - readonly SRGB: GLenum; - readonly SRGB8: GLenum; - readonly SRGB8_ALPHA8: GLenum; - readonly COMPARE_REF_TO_TEXTURE: GLenum; - readonly RGBA32F: GLenum; - readonly RGB32F: GLenum; - readonly RGBA16F: GLenum; - readonly RGB16F: GLenum; - readonly VERTEX_ATTRIB_ARRAY_INTEGER: GLenum; - readonly MAX_ARRAY_TEXTURE_LAYERS: GLenum; - readonly MIN_PROGRAM_TEXEL_OFFSET: GLenum; - readonly MAX_PROGRAM_TEXEL_OFFSET: GLenum; - readonly MAX_VARYING_COMPONENTS: GLenum; - readonly TEXTURE_2D_ARRAY: GLenum; - readonly TEXTURE_BINDING_2D_ARRAY: GLenum; - readonly R11F_G11F_B10F: GLenum; - readonly UNSIGNED_INT_10F_11F_11F_REV: GLenum; - readonly RGB9_E5: GLenum; - readonly UNSIGNED_INT_5_9_9_9_REV: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_MODE: GLenum; - readonly MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: GLenum; - readonly TRANSFORM_FEEDBACK_VARYINGS: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_START: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_SIZE: GLenum; - readonly TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: GLenum; - readonly RASTERIZER_DISCARD: GLenum; - readonly MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: GLenum; - readonly MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: GLenum; - readonly INTERLEAVED_ATTRIBS: GLenum; - readonly SEPARATE_ATTRIBS: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER: GLenum; - readonly TRANSFORM_FEEDBACK_BUFFER_BINDING: GLenum; - readonly RGBA32UI: GLenum; - readonly RGB32UI: GLenum; - readonly RGBA16UI: GLenum; - readonly RGB16UI: GLenum; - readonly RGBA8UI: GLenum; - readonly RGB8UI: GLenum; - readonly RGBA32I: GLenum; - readonly RGB32I: GLenum; - readonly RGBA16I: GLenum; - readonly RGB16I: GLenum; - readonly RGBA8I: GLenum; - readonly RGB8I: GLenum; - readonly RED_INTEGER: GLenum; - readonly RGB_INTEGER: GLenum; - readonly RGBA_INTEGER: GLenum; - readonly SAMPLER_2D_ARRAY: GLenum; - readonly SAMPLER_2D_ARRAY_SHADOW: GLenum; - readonly SAMPLER_CUBE_SHADOW: GLenum; - readonly UNSIGNED_INT_VEC2: GLenum; - readonly UNSIGNED_INT_VEC3: GLenum; - readonly UNSIGNED_INT_VEC4: GLenum; - readonly INT_SAMPLER_2D: GLenum; - readonly INT_SAMPLER_3D: GLenum; - readonly INT_SAMPLER_CUBE: GLenum; - readonly INT_SAMPLER_2D_ARRAY: GLenum; - readonly UNSIGNED_INT_SAMPLER_2D: GLenum; - readonly UNSIGNED_INT_SAMPLER_3D: GLenum; - readonly UNSIGNED_INT_SAMPLER_CUBE: GLenum; - readonly UNSIGNED_INT_SAMPLER_2D_ARRAY: GLenum; - readonly DEPTH_COMPONENT32F: GLenum; - readonly DEPTH32F_STENCIL8: GLenum; - readonly FLOAT_32_UNSIGNED_INT_24_8_REV: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_RED_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: GLenum; - readonly FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: GLenum; - readonly FRAMEBUFFER_DEFAULT: GLenum; - readonly UNSIGNED_INT_24_8: GLenum; - readonly DEPTH24_STENCIL8: GLenum; - readonly UNSIGNED_NORMALIZED: GLenum; - readonly DRAW_FRAMEBUFFER_BINDING: GLenum; - readonly READ_FRAMEBUFFER: GLenum; - readonly DRAW_FRAMEBUFFER: GLenum; - readonly READ_FRAMEBUFFER_BINDING: GLenum; - - readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: GLenum; - readonly MAX_COLOR_ATTACHMENTS: GLenum; - readonly COLOR_ATTACHMENT1: GLenum; - readonly COLOR_ATTACHMENT2: GLenum; - readonly COLOR_ATTACHMENT3: GLenum; - readonly COLOR_ATTACHMENT4: GLenum; - readonly COLOR_ATTACHMENT5: GLenum; - readonly COLOR_ATTACHMENT6: GLenum; - readonly COLOR_ATTACHMENT7: GLenum; - readonly COLOR_ATTACHMENT8: GLenum; - readonly COLOR_ATTACHMENT9: GLenum; - readonly COLOR_ATTACHMENT10: GLenum; - readonly COLOR_ATTACHMENT11: GLenum; - readonly COLOR_ATTACHMENT12: GLenum; - readonly COLOR_ATTACHMENT13: GLenum; - readonly COLOR_ATTACHMENT14: GLenum; - readonly COLOR_ATTACHMENT15: GLenum; - readonly FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: GLenum; - readonly MAX_SAMPLES: GLenum; - readonly HALF_FLOAT: GLenum; - readonly RG: GLenum; - readonly RG_INTEGER: GLenum; - readonly R8: GLenum; - readonly RG8: GLenum; - readonly R16F: GLenum; - - readonly R32F: GLenum; - readonly RG16F: GLenum; - readonly RG32F: GLenum; - readonly R8I: GLenum; - readonly R8UI: GLenum; - readonly R16I: GLenum; - readonly R16UI: GLenum; - readonly R32I: GLenum; - readonly R32UI: GLenum; - readonly RG8I: GLenum; - readonly RG8UI: GLenum; - readonly RG16I: GLenum; - readonly RG16UI: GLenum; - readonly RG32I: GLenum; - readonly RG32UI: GLenum; - readonly VERTEX_ARRAY_BINDING: GLenum; - readonly R8_SNORM: GLenum; - readonly RG8_SNORM: GLenum; - readonly RGB8_SNORM: GLenum; - readonly RGBA8_SNORM: GLenum; - readonly SIGNED_NORMALIZED: GLenum; - readonly COPY_READ_BUFFER: GLenum; - readonly COPY_WRITE_BUFFER: GLenum; - readonly COPY_READ_BUFFER_BINDING: GLenum; /* Same as COPY_READ_BUFFER */ - readonly COPY_WRITE_BUFFER_BINDING: GLenum; /* Same as COPY_WRITE_BUFFER */ - readonly UNIFORM_BUFFER: GLenum; - readonly UNIFORM_BUFFER_BINDING: GLenum; - readonly UNIFORM_BUFFER_START: GLenum; - readonly UNIFORM_BUFFER_SIZE: GLenum; - readonly MAX_VERTEX_UNIFORM_BLOCKS: GLenum; - readonly MAX_FRAGMENT_UNIFORM_BLOCKS: GLenum; - readonly MAX_COMBINED_UNIFORM_BLOCKS: GLenum; - readonly MAX_UNIFORM_BUFFER_BINDINGS: GLenum; - readonly MAX_UNIFORM_BLOCK_SIZE: GLenum; - readonly MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: GLenum; - readonly MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: GLenum; - readonly UNIFORM_BUFFER_OFFSET_ALIGNMENT: GLenum; - readonly ACTIVE_UNIFORM_BLOCKS: GLenum; - readonly UNIFORM_TYPE: GLenum; - readonly UNIFORM_SIZE: GLenum; - readonly UNIFORM_BLOCK_INDEX: GLenum; - readonly UNIFORM_OFFSET: GLenum; - readonly UNIFORM_ARRAY_STRIDE: GLenum; - readonly UNIFORM_MATRIX_STRIDE: GLenum; - readonly UNIFORM_IS_ROW_MAJOR: GLenum; - readonly UNIFORM_BLOCK_BINDING: GLenum; - readonly UNIFORM_BLOCK_DATA_SIZE: GLenum; - readonly UNIFORM_BLOCK_ACTIVE_UNIFORMS: GLenum; - readonly UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: GLenum; - readonly UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: GLenum; - readonly UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: GLenum; - readonly INVALID_INDEX: GLenum; - readonly MAX_VERTEX_OUTPUT_COMPONENTS: GLenum; - readonly MAX_FRAGMENT_INPUT_COMPONENTS: GLenum; - readonly MAX_SERVER_WAIT_TIMEOUT: GLenum; - readonly OBJECT_TYPE: GLenum; - readonly SYNC_CONDITION: GLenum; - readonly SYNC_STATUS: GLenum; - readonly SYNC_FLAGS: GLenum; - readonly SYNC_FENCE: GLenum; - readonly SYNC_GPU_COMMANDS_COMPLETE: GLenum; - readonly UNSIGNALED: GLenum; - readonly SIGNALED: GLenum; - readonly ALREADY_SIGNALED: GLenum; - readonly TIMEOUT_EXPIRED: GLenum; - readonly CONDITION_SATISFIED: GLenum; - readonly WAIT_FAILED: GLenum; - readonly SYNC_FLUSH_COMMANDS_BIT: GLenum; - readonly VERTEX_ATTRIB_ARRAY_DIVISOR: GLenum; - readonly ANY_SAMPLES_PASSED: GLenum; - readonly ANY_SAMPLES_PASSED_CONSERVATIVE: GLenum; - readonly SAMPLER_BINDING: GLenum; - readonly RGB10_A2UI: GLenum; - readonly INT_2_10_10_10_REV: GLenum; - readonly TRANSFORM_FEEDBACK: GLenum; - readonly TRANSFORM_FEEDBACK_PAUSED: GLenum; - readonly TRANSFORM_FEEDBACK_ACTIVE: GLenum; - readonly TRANSFORM_FEEDBACK_BINDING: GLenum; - readonly TEXTURE_IMMUTABLE_FORMAT: GLenum; - readonly MAX_ELEMENT_INDEX: GLenum; - readonly TEXTURE_IMMUTABLE_LEVELS: GLenum; - - readonly TIMEOUT_IGNORED: GLint64; - - /* WebGL-specific enums */ - readonly MAX_CLIENT_WAIT_TIMEOUT_WEBGL: GLenum; -} - -type Uint32List = Uint32Array | GLuint[]; \ No newline at end of file diff --git a/package.json b/package.json index c6d860f5de..def46ebf1e 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "rollup-plugin-terser": "^5.1.1", "rollup-plugin-uglify": "^6.0.2", "rollup-watch": "^4.3.1", - "tfig": "^1.0.25", + "tfig": "^1.0.28", "ts-jest": "^24.0.2", "tween.js": "github:cocos-creator/tween.js#cocos-master", "typedoc": "^0.14.2", diff --git a/scripts/generate-declarations/generate-declarations-cli.js b/scripts/generate-declarations/generate-declarations-cli.js index 648a1e8d24..cb8ca5a080 100644 --- a/scripts/generate-declarations/generate-declarations-cli.js +++ b/scripts/generate-declarations/generate-declarations-cli.js @@ -1,11 +1,11 @@ -const { generate } = require('./generate-declarations'); - -generate({ - outDir: './bin/.declarations', -}).then((successed) => { - if (successed) { - console.log(`Successed.`); - } else { - console.error(`Failed to generate declaration files.`); - } -}); \ No newline at end of file +/* eslint-disable @typescript-eslint/no-require-imports */ +/* eslint-disable @typescript-eslint/no-var-requires */ + +const { generate } = require('./generate-declarations'); +const fs = require('fs-extra'); + +const outDir = './bin/.declarations'; +(async () => { + await fs.emptyDir(outDir); + await generate({ outDir }); +})(); \ No newline at end of file diff --git a/scripts/generate-declarations/generate-declarations.js b/scripts/generate-declarations/generate-declarations.js index a647ca8aea..3290f2db44 100644 --- a/scripts/generate-declarations/generate-declarations.js +++ b/scripts/generate-declarations/generate-declarations.js @@ -1,30 +1,39 @@ -const { spawn, execSync } = require('child_process'); +/* eslint-disable no-console */ +/* eslint-disable @typescript-eslint/no-require-imports */ +/* eslint-disable @typescript-eslint/no-var-requires */ + const { join, extname, basename, dirname, isAbsolute } = require('path'); const { copyFileSync, existsSync, readFileSync, unlinkSync, writeFileSync, ensureDirSync } = require('fs-extra'); const ts = require('typescript'); const gift = require('tfig'); -const tscExecutableName = process.platform === 'win32' ? 'tsc.cmd' : 'tsc'; -const tscExecutablePath = join(__dirname, '..', '..', 'node_modules', '.bin', tscExecutableName); const tsConfigDir = join(__dirname, '..', '..'); const tsConfigPath = join(tsConfigDir, 'tsconfig.json'); -const tempTsConfigPath = join(tsConfigDir, '__tsconfig-gendecls.json'); async function generate (options) { - const tsConfig = ts.readConfigFile(tsConfigPath, (path) => readFileSync(path).toString()); - if (tsConfig.error) { - console.error(`Bad tsconfig.json: ${tsConfig.error.messageText}`); - return undefined; - } + console.log(`Typescript version: ${ts.version}`); const { outDir } = options; ensureDirSync(outDir); - tsConfig.config.compilerOptions.declaration = true; - tsConfig.config.compilerOptions.emitDeclarationOnly = true; - tsConfig.config.compilerOptions.outFile = join(outDir, `index.js`); + const unbundledOutFile = join(outDir, `cc-before-rollup.js`); + const parsedCommandLine = ts.getParsedCommandLineOfConfigFile( + tsConfigPath, { + declaration: true, + emitDeclarationOnly: true, + outFile: unbundledOutFile, + outDir: undefined, + }, { + onUnRecoverableConfigFileDiagnostic: () => {}, + useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames, + readDirectory: ts.sys.readDirectory, + getCurrentDirectory: ts.sys.getCurrentDirectory, + fileExists: ts.sys.fileExists, + readFile: ts.sys.readFile, + } + ); - const outputJSPath = join(tsConfigDir, tsConfig.config.compilerOptions.outFile); + const outputJSPath = join(tsConfigDir, unbundledOutFile); // console.log(outputJSPath); const extName = extname(outputJSPath); @@ -46,52 +55,43 @@ async function generate (options) { } } - console.log(`Make temp config file ${tempTsConfigPath}.`); - - writeFileSync(tempTsConfigPath, JSON.stringify(tsConfig.config, undefined, 4)); - console.log(`Generating...`); - await new Promise((resolve) => { - const tscProcess = spawn(tscExecutablePath, [ - '--version', - ]); - tscProcess.on('exit', (code) => { - resolve(code); - }); - tscProcess.stdout.on('data', (data) => { - console.log(`Typescript version: ${data.toString()}`); - }); - tscProcess.stderr.on('data', (data) => { - console.error(data.toString()); - }); - }); - - const tscExitCode = await new Promise((resolve) => { - const tscProcess = spawn(tscExecutablePath, [ - '-p', - tempTsConfigPath, - ], { - cwd: process.cwd(), - env: process.env, - }); - tscProcess.on('exit', (code) => { - resolve(code); - }); - tscProcess.stdout.on('data', (data) => { - console.log(data.toString()); - }); - tscProcess.stderr.on('data', (data) => { - console.error(data.toString()); - }); - }); - - console.log(`Delete temp config file ${tempTsConfigPath}.`); - - unlinkSync(tempTsConfigPath); - - if (tscExitCode !== 0) { - console.warn(`tsc exited with non-zero status code ${tscExitCode}.`); + const program = ts.createProgram(parsedCommandLine.fileNames, parsedCommandLine.options); + const emitResult = program.emit( + undefined, // targetSourceFile + undefined, // writeFile + undefined, // cancellationToken, + true, // emitOnlyDtsFiles + undefined, // customTransformers + ); + + let allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + for (const diagnostic of allDiagnostics) { + let printer; + switch (diagnostic.category) { + case ts.DiagnosticCategory.Error: + printer = console.error; + break; + case ts.DiagnosticCategory.Warning: + printer = console.warn; + break; + case ts.DiagnosticCategory.Message: + case ts.DiagnosticCategory.Suggestion: + default: + printer = console.log; + break; + } + if (!printer) { + continue; + } + if (diagnostic.file) { + let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + let message = ts.flattenDiagnosticMessageText(diagnostic.messageText); + printer(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + } else { + printer(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); + } } const tscOutputDtsFile = join(dirName, baseName + '.d.ts'); @@ -100,7 +100,7 @@ async function generate (options) { return false; } - const types = tsConfig.config.compilerOptions.types.map((typeFile) => `${typeFile}.d.ts`); + const types = parsedCommandLine.options.types.map((typeFile) => `${typeFile}.d.ts`); types.forEach((file) => { const destPath = join(outDir, isAbsolute(file) ? basename(file) : file); ensureDirSync(dirname(destPath)); diff --git a/tsconfig.json b/tsconfig.json index 413523d594..556d7bd801 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,8 +16,8 @@ "./@types/editor-extends", "./@types/ammo.js", "./@types/wx", - "./cocos/core/gfx/webgl/WebGL", - "./cocos/core/gfx/webgl2/WebGL2", + "./@types/webGL.extras", + "./@types/webGL2.extras", "./node_modules/tween.js/TWEEN", "./node_modules/@types/jest/index" ] From fc1c066eac1acaa7952d76b09a83334440234494 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Mon, 14 Oct 2019 23:05:42 +0800 Subject: [PATCH 07/33] tweaks of render-scene raycast (#5406) * rename UI to UI_3D * fix getComputeAABB in ui-transform-component * tweaks of render-scene raycast --- .../ui-base/ui-transfrom-component.ts | 24 ++- cocos/core/renderer/scene/deprecated.ts | 25 ++- cocos/core/renderer/scene/render-scene.ts | 157 +++++++++++------- 3 files changed, 135 insertions(+), 71 deletions(-) diff --git a/cocos/core/components/ui-base/ui-transfrom-component.ts b/cocos/core/components/ui-base/ui-transfrom-component.ts index 839c8c7ebe..bac6f5638b 100644 --- a/cocos/core/components/ui-base/ui-transfrom-component.ts +++ b/cocos/core/components/ui-base/ui-transfrom-component.ts @@ -42,7 +42,7 @@ const _vec2b = new Vec2(); const _mat4_temp = new Mat4(); const _matrix = new Mat4(); const _worldMatrix = new Mat4(); - +const _rect = new Rect(); /** * @zh * UI 变换组件。 @@ -477,16 +477,26 @@ export class UITransformComponent extends Component { } /** + * @en * compute the corresponding aabb in world space for raycast + * @zh + * 计算出此 UI_2D 节点在世界空间下的 aabb 包围盒 */ public getComputeAABB (out?: aabb) { - const rectWorld = this.getBoundingBoxToWorld(); - const px = rectWorld.center.x; - const py = rectWorld.center.y; + const width = this._contentSize.width; + const height = this._contentSize.height; + _rect.set( + -this._anchorPoint.x * width, + -this._anchorPoint.y * height, + width, + height); + _rect.transformMat4(this.node.worldMatrix); + const px = _rect.x + _rect.width * 0.5; + const py = _rect.y + _rect.height * 0.5;; const pz = this.node.worldPosition.z; - const w = rectWorld.width / 2; - const h = rectWorld.height / 2; - const l = 0.01; + const w = _rect.width / 2; + const h = _rect.height / 2; + const l = 0.001; if (out != null) { aabb.set(out, px, py, pz, w, h, l); } else { diff --git a/cocos/core/renderer/scene/deprecated.ts b/cocos/core/renderer/scene/deprecated.ts index 3139bef921..e6ed79d4f5 100644 --- a/cocos/core/renderer/scene/deprecated.ts +++ b/cocos/core/renderer/scene/deprecated.ts @@ -5,15 +5,32 @@ import { Layers } from "../../scene-graph"; replaceProperty(RenderScene.prototype, 'RenderScene.prototype', [ { 'name': 'raycastUI', - 'newName': 'raycastUI2D' + 'newName': 'raycastAllCanvas' }, { - 'name': 'raycastUINode', - 'newName': 'raycastUI2DNode' + 'name': 'raycastUI2D', + 'newName': 'raycastAllCanvas' }, { 'name': 'raycast', - 'newName': 'raycastModels' + 'newName': 'raycastAllModels' + }, + { + 'name': 'raycastModels', + 'newName': 'raycastAllModels' + }, + { + 'name': 'raycastModel', + 'newName': 'raycastSingleModel' + }, +]); + +removeProperty(RenderScene.prototype, 'RenderScene.prototype', [ + { + 'name': 'raycastUI2DNode' + }, + { + 'name': 'raycastUINode', } ]); diff --git a/cocos/core/renderer/scene/render-scene.ts b/cocos/core/renderer/scene/render-scene.ts index f02b47362f..46594a3f87 100644 --- a/cocos/core/renderer/scene/render-scene.ts +++ b/cocos/core/renderer/scene/render-scene.ts @@ -82,6 +82,38 @@ export class RenderScene { return this._texturePool; } + /** + * @zh + * 获取 raycastAllCanvas 后的检测结果 + */ + get rayResultCanvas () { + return resultCanvas; + } + + /** + * @zh + * 获取 raycastAllModels 后的检测结果 + */ + get rayResultModels () { + return resultModels; + } + + /** + * @zh + * 获取 raycastAll 后的检测结果 + */ + get rayResultAll () { + return resultAll; + } + + /** + * @zh + * 获取 raycastSingleModel 后的检测结果 + */ + get rayResultSingleModel () { + return this.rayResultSingleModel; + } + public static registerCreateFunc (root: Root) { root._createSceneFun = (_root: Root): RenderScene => new RenderScene(_root); } @@ -223,20 +255,51 @@ export class RenderScene { return this._modelId++; } + /** + * @en + * Cast a ray into the scene, record all the intersected models and ui2d nodes in the result array + * @param worldRay the testing ray + * @param mask the layer mask to filter the models + * @param distance the max distance , Infinity by default + * @returns boolean , ray is hit or not + * @note getter of this.rayResultAll can get recently result + * @zh + * 传入一条射线检测场景中所有的 3D 模型和 UI2D Node + * @param worldRay 世界射线 + * @param mask mask 用于标记所有要检测的层,默认为 Default | UI2D + * @param distance 射线检测的最大距离, 默认为 Infinity + * @returns boolean , 射线是否有击中 + * @nete 通过 this.rayResultAll 可以获取到最近的结果 + */ + public raycastAll (worldRay: ray, mask = Layers.Enum.DEFAULT | Layers.Enum.UI_2D, distance = Infinity): boolean { + const r_3d = this.raycastAllModels(worldRay, mask, distance); + const r_ui2d = this.raycastAllCanvas(worldRay, mask, distance); + const isHit = r_3d || r_ui2d; + resultAll.length = 0; + if (isHit) { + Array.prototype.push.apply(resultAll, resultModels); + Array.prototype.push.apply(resultAll, resultCanvas); + } + return isHit; + } + /** * @en * Cast a ray into the scene, record all the intersected models in the result array * @param worldRay the testing ray * @param mask the layer mask to filter the models * @param distance the max distance , Infinity by default + * @returns boolean , ray is hit or not + * @note getter of this.rayResultModels can get recently result * @zh * 传入一条射线检测场景中所有的 3D 模型。 * @param worldRay 世界射线 * @param mask 用于标记所有要检测的层,默认为 Default * @param distance 射线检测的最大距离, 默认为 Infinity - * @returns IRaycastResult[] + * @returns boolean , 射线是否有击中 + * @nete 通过 this.rayResultModels 可以获取到最近的结果 */ - public raycastModels (worldRay: ray, mask = Layers.Enum.DEFAULT, distance = Infinity): IRaycastResult[] { + public raycastAllModels (worldRay: ray, mask = Layers.Enum.DEFAULT, distance = Infinity): boolean { pool.reset(); for (const m of this._models) { const transform = m.transform; @@ -258,43 +321,45 @@ export class RenderScene { const r = pool.add(); r.node = m.node; r.distance = narrowDis * Vec3.multiply(v3, modelRay.d, transform.worldScale).length(); - results[pool.length - 1] = r; + resultModels[pool.length - 1] = r; } } } - results.length = pool.length; - return results; + resultModels.length = pool.length; + return resultModels.length > 0; } /** * @en * Before you raycast the model, make sure the model is not null * @param worldRay the testing ray + * @param model the testing model * @param mask the layer mask to filter the models * @param distance the max distance , Infinity by default + * @returns boolean , ray is hit or not * @zh * 传入一条射线和一个 3D 模型进行射线检测。 * @param worldRay 世界射线 + * @param model 进行检测的模型 * @param mask 用于标记所有要检测的层,默认为 Default * @param distance 射线检测的最大距离, 默认为 Infinity - * @returns IRaycastResult[] + * @returns boolean , 射线是否有击中 */ - public raycastModel (worldRay: ray, model: Model, mask = Layers.Enum.DEFAULT, distance = Infinity): IRaycastResult[] { + public raycastSingleModel (worldRay: ray, model: Model, mask = Layers.Enum.DEFAULT, distance = Infinity): boolean { if (CC_PREVIEW) { if (model == null) console.error(" 检测前请保证 model 不为 null "); } pool.reset(); - results.length = 0; const m = model; const transform = m.transform; - if (!transform || !m.enabled || m.node.layer & Layers.Enum.IGNORE_RAYCAST || !(m.node.layer & mask) || !m.modelBounds) { return results; } + if (!transform || !m.enabled || m.node.layer & Layers.Enum.IGNORE_RAYCAST || !(m.node.layer & mask) || !m.modelBounds) { return false; } // transform ray back to model space Mat4.invert(m4, transform.getWorldMatrix(m4)); Vec3.transformMat4(modelRay.o, worldRay.o, m4); Vec3.normalize(modelRay.d, Vec3.transformMat4Normal(modelRay.d, worldRay.d, m4)); // broadphase const d = intersect.ray_aabb(modelRay, m.modelBounds); - if (d <= 0 || d > distance) { return results; } + if (d <= 0 || d > distance) { return false; } for (let i = 0; i < m.subModelNum; ++i) { const subModel = m.getSubModel(i).subMeshData; if (subModel && subModel.geometricInfo) { @@ -305,27 +370,30 @@ export class RenderScene { const r = pool.add(); r.node = m.node; r.distance = narrowDis * Vec3.multiply(v3, modelRay.d, transform.worldScale).length(); - results[pool.length - 1] = r; + resultSingleModel[pool.length - 1] = r; } } - return results; + resultSingleModel.length = pool.length; + return resultSingleModel.length > 0; } /** * @en - * Cast a ray into the scene, record all the intersected ui aabb in the result array + * Cast a ray into the scene, detect all canvas and its children * @param worldRay the testing ray * @param mask the layer mask to filter all ui2d aabb * @param distance the max distance , Infinity by default - * @returns IRaycastResult[] + * @returns boolean , ray is hit or not + * @note getter of this.rayResultCanvas can get recently result * @zh - * 传入一条射线检测场景中所有的 UI2D Node,mask 标记了要检测的所有的层,默认为 UI2D* + * 传入一条射线检测场景中所有的 Canvas 以及 Canvas 下的 Node * @param worldRay 世界射线 * @param mask 用于标记所有要检测的层,默认为 UI2D * @param distance 射线检测的最大距离, 默认为 Infinity - * @returns IRaycastResult[] + * @returns boolean , 射线是否有击中 + * @nete 通过 this.rayResultCanvas 可以获取到最近的结果 */ - public raycastUI2D (worldRay: ray, mask = Layers.Enum.UI_2D, distance = Infinity): IRaycastResult[] { + public raycastAllCanvas (worldRay: ray, mask = Layers.Enum.UI_2D, distance = Infinity): boolean { poolUI.reset(); const canvasComs = cc.director.getScene().getComponentsInChildren(cc.CanvasComponent); if (canvasComs != null && canvasComs.length > 0) { @@ -336,26 +404,11 @@ export class RenderScene { } } } - resultUIs.length = poolUI.length; - return resultUIs; + resultCanvas.length = poolUI.length; + return resultCanvas.length > 0; } - /** - * @en - * Before you raycast the ui node, make sure the node is not null - * @param worldRay the testing ray - * @param ui2dNode the ui2d node - * @param mask the layer mask to filter the ui2d node aabb - * @param distance the max distance , Infinity by default - * @returns IRaycastResult | undefined - * @zh - * 传入一条射线和一个 UI2D Node 进行射线检测。 - * @param worldRay 世界射线 - * @param ui2dNode UI2D 的节点 - * @param mask 用于标记所有要检测的层,默认为 UI2D - * @param distance 射线检测的最大距离, 默认为 Infinity - */ - public raycastUI2DNode (worldRay: ray, ui2dNode: INode, mask = Layers.Enum.UI_2D, distance = Infinity) { + private _raycastUI2DNode (worldRay: ray, ui2dNode: INode, mask = Layers.Enum.UI_2D, distance = Infinity) { if (CC_PREVIEW) { if (ui2dNode == null) console.error(" 检测前请保证 uiNode 不为 null "); } @@ -374,30 +427,10 @@ export class RenderScene { } } - // /** - // * @en - // * Cast a ray into the scene, record all the intersected models and ui2d nodes in the result array - // * @param worldRay the testing ray - // * @param mask the layer mask to filter the models - // * @param distance the max distance , Infinity by default - // * @returns IRaycastResult[] - // * @zh - // * 传入一条射线检测场景中所有的 3D 模型和 UI2D Node - // * @param worldRay 世界射线 - // * @param mask mask 用于标记所有要检测的层,默认为 Default | UI2D - // * @param distance 射线检测的最大距离, 默认为 Infinity - // * @returns IRaycastResult[] - // */ - // public raycastAll (worldRay: ray, mask = Layers.Default | Layers.UI2D, distance = Infinity): IRaycastResult[] { - // const r_3d = this.raycastModels(worldRay, mask, distance); - // const r_ui2d = this.raycastUI2D(worldRay, mask, distance); - // return r_3d.concat(r_ui2d); - // } - private _raycastUI2DNodeRecursiveChildren (worldRay: ray, parent: INode, mask = Layers.Enum.UI_2D, distance = Infinity) { - const result = this.raycastUI2DNode(worldRay, parent, mask, distance); + const result = this._raycastUI2DNode(worldRay, parent, mask, distance); if (result != null) { - resultUIs[poolUI.length - 1] = result; + resultCanvas[poolUI.length - 1] = result; } for (const node of parent.children) { if (node != null && node.active) { @@ -415,13 +448,17 @@ const tri = triangle.create(); const pool = new RecyclePool(() => { return { node: null!, distance: Infinity }; }, 8); -const results: IRaycastResult[] = []; -/** UI raycast result pool */ +const resultModels: IRaycastResult[] = []; +/** Canavas raycast result pool */ const aabbUI = new aabb(); const poolUI = new RecyclePool(() => { return { node: null!, distance: Infinity }; }, 8); -const resultUIs: IRaycastResult[] = []; +const resultCanvas: IRaycastResult[] = []; +/** raycast all */ +const resultAll: IRaycastResult[] = []; +/** raycast single model */ +const resultSingleModel: IRaycastResult[] = []; const narrowphase = (vb: Float32Array, ib: IBArray, pm: GFXPrimitiveMode, sides: boolean, distance = Infinity) => { narrowDis = distance; From 80f8be21f7a38d0ee604471981082638ae0830b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Tue, 15 Oct 2019 16:07:19 +0800 Subject: [PATCH 08/33] Bump package gift (#5544) --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4cc3a71670..92d2ab0ae7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12350,9 +12350,9 @@ "dev": true }, "tfig": { - "version": "1.0.25", - "resolved": "https://registry.npm.taobao.org/tfig/download/tfig-1.0.25.tgz", - "integrity": "sha1-ySivNQRq8QFyceyzhk/+3O4i+78=", + "version": "1.1.0", + "resolved": "https://registry.npm.taobao.org/tfig/download/tfig-1.1.0.tgz", + "integrity": "sha1-fxOXsBiTYfDv3MgmTOyEO/Gp0Ug=", "dev": true, "requires": { "fs-extra": "^7.0.1", @@ -12362,7 +12362,7 @@ "dependencies": { "ansi-regex": { "version": "4.1.0", - "resolved": "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-4.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-4.1.0.tgz?cache=0&sync_timestamp=1570188663907&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-regex%2Fdownload%2Fansi-regex-4.1.0.tgz", "integrity": "sha1-i5+PCM8ay4Q3Vqg5yox+MWjFGZc=", "dev": true }, @@ -12449,7 +12449,7 @@ }, "yargs": { "version": "13.3.0", - "resolved": "https://registry.npm.taobao.org/yargs/download/yargs-13.3.0.tgz?cache=0&sync_timestamp=1567812307271&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-13.3.0.tgz", + "resolved": "https://registry.npm.taobao.org/yargs/download/yargs-13.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-13.3.0.tgz", "integrity": "sha1-TGV6VeB+Xyz5R/ijZlZ8BKDe3IM=", "dev": true, "requires": { diff --git a/package.json b/package.json index def46ebf1e..298df73099 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "rollup-plugin-terser": "^5.1.1", "rollup-plugin-uglify": "^6.0.2", "rollup-watch": "^4.3.1", - "tfig": "^1.0.28", + "tfig": "^1.1.0", "ts-jest": "^24.0.2", "tween.js": "github:cocos-creator/tween.js#cocos-master", "typedoc": "^0.14.2", From 1d50bd54969f72c589fa81372b052c712172d215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Tue, 15 Oct 2019 16:07:46 +0800 Subject: [PATCH 09/33] export cc.isValid() (#5546) --- cocos/core/data/index.ts | 2 +- cocos/core/data/object.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos/core/data/index.ts b/cocos/core/data/index.ts index 38e544f6c3..a2b8b61d68 100644 --- a/cocos/core/data/index.ts +++ b/cocos/core/data/index.ts @@ -31,7 +31,7 @@ import * as _decorator from './class-decorator'; cc._decorator = _decorator; export { _decorator }; export { default as CCClass } from './class'; -export { CCObject } from './object'; +export { CCObject, isValid } from './object'; export { default as deserialize } from './deserialize'; export { default as instantiate } from './instantiate'; export { CCInteger, CCFloat, CCBoolean, CCString} from './utils/attribute'; diff --git a/cocos/core/data/object.ts b/cocos/core/data/object.ts index adf2c0d28a..92f766295a 100644 --- a/cocos/core/data/object.ts +++ b/cocos/core/data/object.ts @@ -534,11 +534,12 @@ js.value(CCObject, 'Flags', { * 如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 * * @method isValid - * @param {any} value - * @param {Boolean} [strictMode=false] - If true, Object called destroy() in this frame will also treated as invalid. - * @return {Boolean} whether is valid + * @param value + * @param [strictMode=false] - If true, Object called destroy() in this frame will also treated as invalid. + * @return whether is valid * @example * ``` + * import * as cc from 'cc'; * var node = new cc.Node(); * cc.log(cc.isValid(node)); // true * node.destroy(); @@ -547,14 +548,15 @@ js.value(CCObject, 'Flags', { * cc.log(cc.isValid(node)); // false, destroyed in the end of last frame * ``` */ -cc.isValid = (value, strictMode) => { +export function isValid (value: any, strictMode?: boolean) { if (typeof value === 'object') { return !!value && !(value._objFlags & (strictMode ? (Destroyed | ToDestroy) : Destroyed)); } else { return typeof value !== 'undefined'; } -}; +} +cc.isValid = isValid; if (CC_EDITOR || CC_TEST) { js.value(CCObject, '_willDestroy', (obj) => { From 1e62004e1221d9e05c17a90591ad793db4d9407e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Thu, 17 Oct 2019 09:57:17 +0800 Subject: [PATCH 10/33] add extendsEnum() to support extending of enumerations (#5454) typo update update Update button-component.ts Update toggle-component.ts Update toggle-component.ts Update toggle-component.ts Update button-component.ts Update toggle-component.ts Update button-component.ts --- EngineErrorMap.md | 4 +++ cocos/core/data/utils/extends-enum.ts | 48 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 cocos/core/data/utils/extends-enum.ts diff --git a/EngineErrorMap.md b/EngineErrorMap.md index 3da16d5bca..19e3d509d5 100644 --- a/EngineErrorMap.md +++ b/EngineErrorMap.md @@ -632,6 +632,10 @@ you can declare a texture object directly in properties by using: browser does not support getters +### 3659 + +Violation error: extending enumerations shall have non-overlaped member names or member values + ### 3700 internal error: _prefab is undefined diff --git a/cocos/core/data/utils/extends-enum.ts b/cocos/core/data/utils/extends-enum.ts new file mode 100644 index 0000000000..12b2edb8b3 --- /dev/null +++ b/cocos/core/data/utils/extends-enum.ts @@ -0,0 +1,48 @@ + +import { errorID } from '../../platform/debug'; + +/** + * @zh + * 组合任意多个枚举。 + * 此函数的行为等价于返回了一个新的枚举,其成员囊括了所有源枚举的成员。 + * 这些枚举的成员必须各不相同(包括成员名和值),否则行为是未定义的。 + * @en + * Combine arbitray number of enumerations. + * It behaves like an enumeration having members that is a combination of members of the source enumerations + * is returned. + * These enumerations shall have non-overlaped member names or member values. + * If not, the behavior is undefined. + * @example + * ```ts + * enum Apple { apple = 'apple', } + * enum Pen { pen = 'pen' } + * // As if `enum ApplePen { apple = 'apple'; pen = 'pen'; }` + * const ApplePen = extendsEnum(Apple, Pen); + * ``` + */ +export function extendsEnum (): {}; + +export function extendsEnum (e0: E0): E0; + +export function extendsEnum (e0: E0, e1: E1): E0 & E1; + +export function extendsEnum (e0: E0, e1: E1, e2: E2): E0 & E1 & E2; + +export function extendsEnum (e0: E0, e1: E1, e2: E2, e3: E3): E0 & E1 & E2 & E3; + +export function extendsEnum (...enums: any[]): any { + if (CC_DEV) { + const kvs: PropertyKey[] = []; + for (const e of enums) { + for (const kv of Object.keys(e)) { + if (kvs.indexOf(kv) >= 0) { + errorID(3659); + } else { + kvs.push(kv); + } + } + } + + } + return Object.assign({}, ...enums); +} \ No newline at end of file From f4596ab5cb99fd2d6e0f7954276c8f411052d843 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Fri, 18 Oct 2019 11:17:22 +0800 Subject: [PATCH 11/33] fix node setWorldScale API (#5562) --- cocos/core/scene-graph/node.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/core/scene-graph/node.ts b/cocos/core/scene-graph/node.ts index 21d52e648f..549ded7245 100644 --- a/cocos/core/scene-graph/node.ts +++ b/cocos/core/scene-graph/node.ts @@ -853,7 +853,9 @@ export class Node extends BaseNode implements INode { parent.updateWorldTransform(); Mat3.fromQuat(m3_1, Quat.conjugate(qt_1, parent._rot)); Mat3.multiplyMat4(m3_1, m3_1, parent._mat); - m3_scaling.m00 = this._scale.x; m3_scaling.m04 = this._scale.x; m3_scaling.m08 = this._scale.z; + m3_scaling.m00 = this._scale.x; + m3_scaling.m04 = this._scale.y; + m3_scaling.m08 = this._scale.z; Mat3.multiply(m3_1, m3_scaling, Mat3.invert(m3_1, m3_1)); this._lscale.x = m3_1.m00; this._lscale.y = m3_1.m04; From a120ccbd05bf8fc827a0c51a420e12d236bbd694 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Fri, 18 Oct 2019 11:26:04 +0800 Subject: [PATCH 12/33] unify animation clips (#5523) --- .../3d/framework/skinning-model-component.ts | 7 +- cocos/core/3d/misc/utils.ts | 3 +- cocos/core/animation/animation-clip.ts | 122 ++++---------- cocos/core/animation/animation-state.ts | 25 ++- cocos/core/animation/cross-fade.ts | 35 ++-- cocos/core/animation/index.ts | 4 +- .../animation/skeletal-animation-component.ts | 5 +- .../animation/skeletal-animation-data-hub.ts | 151 +++++++++++++++++ .../animation/skeletal-animation-state.ts | 12 +- cocos/core/assets/material.ts | 2 +- .../platform/event-manager/input-manager.ts | 7 +- .../renderer/models/joints-texture-utils.ts | 7 +- cocos/core/renderer/models/skinning-model.ts | 8 +- .../core/scene-graph/node-event-processor.ts | 19 +-- cocos/core/scene-graph/node.ts | 2 +- cocos/core/splash-image.ts | 157 +++++++++--------- tslint.json | 1 + 17 files changed, 339 insertions(+), 228 deletions(-) create mode 100644 cocos/core/animation/skeletal-animation-data-hub.ts diff --git a/cocos/core/3d/framework/skinning-model-component.ts b/cocos/core/3d/framework/skinning-model-component.ts index 39c1c4af8e..c91c792284 100644 --- a/cocos/core/3d/framework/skinning-model-component.ts +++ b/cocos/core/3d/framework/skinning-model-component.ts @@ -27,11 +27,10 @@ * @category model */ -import { SkeletalAnimationClip } from '../../animation/skeletal-animation-clip'; +import { AnimationClip } from '../../animation'; import { Material } from '../../assets/material'; import { Skeleton } from '../../assets/skeleton'; import { ccclass, executeInEditMode, executionOrder, menu, property } from '../../data/class-decorator'; -import { director } from '../../director'; import { GFXDevice } from '../../gfx/device'; import { selectJointsMediumType } from '../../renderer/models/joints-texture-utils'; import { SkinningModel } from '../../renderer/models/skinning-model'; @@ -87,7 +86,7 @@ export class SkinningModelComponent extends ModelComponent { return (this._model as SkinningModel); } - public uploadAnimation (clip: SkeletalAnimationClip | null) { + public uploadAnimation (clip: AnimationClip | null) { if (this._model) { (this._model as SkinningModel).uploadAnimation(clip); } } @@ -98,7 +97,7 @@ export class SkinningModelComponent extends ModelComponent { } protected _onMaterialModified (index: number, material: Material | null) { - const device: GFXDevice = director.root!.device; + const device: GFXDevice = cc.director.root!.device; const type = selectJointsMediumType(device); const mat = this.getMaterial(index) || this._getBuiltinMaterial(); mat.recompileShaders({ CC_USE_SKINNING: type }); diff --git a/cocos/core/3d/misc/utils.ts b/cocos/core/3d/misc/utils.ts index 2f8458a723..4c7fca5d27 100644 --- a/cocos/core/3d/misc/utils.ts +++ b/cocos/core/3d/misc/utils.ts @@ -1,6 +1,7 @@ import { GFXAttributeName, GFXFormat, GFXFormatInfos, GFXFormatType, GFXPrimitiveMode, IGFXFormatInfo } from '../../gfx/define'; export { find } from '../../scene-graph/find'; +import { SkelAnimDataHub } from '../../animation/skeletal-animation-data-hub'; import { Mesh } from '../../assets/mesh'; import { Skeleton } from '../../assets/skeleton'; import { aabb } from '../../geom-utils'; @@ -471,7 +472,7 @@ export function calculateSkinnedBounds (out: aabb, comp: SkinningModelComponent) root.getWorldMatrix(m4_1); const boundList = boneSpaceBoundsManager.use(comp.mesh, skeleton); const len = skeleton.joints.length; - const data = clip.convertedData; + const data = SkelAnimDataHub.getOrExtract(clip); const fid = animInfo.data[1]; for (let i = 0; i < len; ++i) { const bounds = boundList[i]; diff --git a/cocos/core/animation/animation-clip.ts b/cocos/core/animation/animation-clip.ts index f196e50c5c..b3976c6a8e 100644 --- a/cocos/core/animation/animation-clip.ts +++ b/cocos/core/animation/animation-clip.ts @@ -3,15 +3,15 @@ * @category animation */ -import { Asset, SpriteFrame } from '../assets'; +import { Asset } from '../assets/asset'; +import { SpriteFrame } from '../assets/sprite-frame'; import { ccclass, property } from '../data/class-decorator'; import { errorID } from '../platform/debug'; import binarySearchEpsilon from '../utils/binary-search'; -import { AnimCurve, IPropertyCurveData, RatioSampler, CurveValueAdapter } from './animation-curve'; -import { WrapMode as AnimationWrapMode } from './types'; -import { INode } from '../utils/interfaces'; import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; -import { TargetModifier, HierachyModifier, ComponentModifier, isCustomTargetModifier, PropertyModifier, isPropertyModifier } from './target-modifier'; +import { AnimCurve, CurveValueAdapter, IPropertyCurveData, RatioSampler } from './animation-curve'; +import { ComponentModifier, HierachyModifier, TargetModifier } from './target-modifier'; +import { WrapMode as AnimationWrapMode } from './types'; export interface IObjectCurveData { [propertyName: string]: IPropertyCurveData; @@ -40,7 +40,7 @@ export interface IRuntimeCurve { /** * 曲线值适配器。 */ - valueAdapter?: CurveValueAdapter; + valueAdapter?: CurveValueAdapter; /** * 曲线采样器。 @@ -64,13 +64,13 @@ export declare namespace AnimationClip { export type PropertyCurveData = IPropertyCurveData; - export interface Curve { + export interface ICurve { modifiers: TargetModifier[]; valueAdapter?: CurveValueAdapter; data: PropertyCurveData; } - export interface Event { + export interface IEvent { frame: number; func: string; params: string[]; @@ -82,6 +82,7 @@ export declare namespace AnimationClip { */ @ccclass('cc.AnimationClip') export class AnimationClip extends Asset { + public static WrapMode = AnimationWrapMode; /** @@ -113,12 +114,12 @@ export class AnimationClip extends Asset { clip.curves = [{ modifiers: [ new ComponentModifier('cc.SpriteComponent'), - 'spriteFrame' + 'spriteFrame', ], data: { keys: 0, values, - } + }, }]; return clip; @@ -142,6 +143,21 @@ export class AnimationClip extends Asset { @property public wrapMode = AnimationWrapMode.Normal; + /** + * @zh 动画包含的事件数据。 + */ + @property({visible: false}) + public events: AnimationClip.IEvent[] = []; + + @property + private _duration = 0; + + @property + private _keys: number[][] = []; + + @property + private _stepness = 0; + /** * @zh 动画的曲线数据。 * @deprecated 请转用 `this.curves` @@ -150,36 +166,17 @@ export class AnimationClip extends Asset { private curveDatas?: AnimationClip.ICurveData = {}; @property - private _curves: AnimationClip.Curve[] = []; + private _curves: AnimationClip.ICurve[] = []; - /** - * @zh 动画包含的事件数据。 - */ - @property({visible: false}) - public events: AnimationClip.Event[] = []; - - @property - protected _duration = 0; - - @property - protected _keys: number[][] = []; - - protected _ratioSamplers: RatioSampler[] = []; - - protected _runtimeCurves?: IRuntimeCurve[]; - - protected _runtimeEvents?: { + private _hash = 0; + private frameRate = 0; + private _ratioSamplers: RatioSampler[] = []; + private _runtimeCurves?: IRuntimeCurve[]; + private _runtimeEvents?: { ratios: number[]; eventGroups: IAnimationEventGroup[]; }; - protected frameRate = 0; - - @property - protected _stepness = 0; - - protected _hash = 0; - /** * @zh 动画的周期。 */ @@ -228,7 +225,7 @@ export class AnimationClip extends Asset { } get hash () { - if (!this._hash) { this._hash = murmurhash2_32_gc(JSON.stringify(this._getDeprecatedCurveDatas()), 666); } + if (!this._hash) { this._hash = murmurhash2_32_gc(JSON.stringify(this._curves), 666); } return this._hash; } @@ -246,7 +243,7 @@ export class AnimationClip extends Asset { this._migrateCurveDatas(); } - public getPropertyCurves (root: INode): ReadonlyArray { + public getPropertyCurves (): ReadonlyArray { if (!this._runtimeCurves) { this._createPropertyCurves(); } @@ -309,7 +306,7 @@ export class AnimationClip extends Asset { sampler: this._ratioSamplers[targetCurve.data.keys], }; }); - + this._applyStepness(); } @@ -386,55 +383,6 @@ export class AnimationClip extends Asset { } delete this.curveDatas; } - - private _getDeprecatedCurveDatas () { - const result: AnimationClip.ICurveData = {}; - for (const curve of this._curves) { - if (curve.modifiers.length === 0 || - !isCustomTargetModifier(curve.modifiers[0], HierachyModifier)) { - continue; - } - - let componentName: string | null = null; - let propertyName: string | undefined; - if (curve.modifiers.length === 2 && - isPropertyModifier(curve.modifiers[1])) { - propertyName = curve.modifiers[1] as PropertyModifier; - } else if (curve.modifiers.length === 3 && - isCustomTargetModifier(curve.modifiers[1], ComponentModifier) && - isPropertyModifier(curve.modifiers[2])) { - componentName = (curve.modifiers[1] as ComponentModifier).component; - propertyName = curve.modifiers[2] as PropertyModifier; - } else { - continue; - } - - const path = (curve.modifiers[0] as HierachyModifier).path; - - if (!(path in result)) { - result[path] = {}; - } - const nodeCurveData = result[path]; - let objectCurveData: IObjectCurveData | undefined; - if (componentName) { - if (!('comps' in nodeCurveData)) { - nodeCurveData.comps = {}; - } - const componentCurveData = nodeCurveData.comps!; - if (!(componentName in componentCurveData)) { - componentCurveData[componentName] = {}; - } - objectCurveData = componentCurveData[componentName]; - } else { - if (!('props' in nodeCurveData)) { - nodeCurveData.props = {}; - } - objectCurveData = nodeCurveData.props!; - } - objectCurveData[propertyName] = curve.data; - } - return result; - } } cc.AnimationClip = AnimationClip; diff --git a/cocos/core/animation/animation-state.ts b/cocos/core/animation/animation-state.ts index 2dc95add23..7794677555 100644 --- a/cocos/core/animation/animation-state.ts +++ b/cocos/core/animation/animation-state.ts @@ -29,15 +29,14 @@ import { EventArgumentsOf, EventCallbackOf } from '../event/defines'; import { Node } from '../scene-graph/node'; +import { INode } from '../utils/interfaces'; import { AnimationBlendState, PropertyBlendState } from './animation-blend-state'; import { AnimationClip, IRuntimeCurve } from './animation-clip'; -import { AnimCurve, RatioSampler, ICurveValueProxy } from './animation-curve'; +import { AnimCurve, ICurveValueProxy, RatioSampler } from './animation-curve'; +import { additive3D, additiveQuat, BlendFunction } from './blending'; import { Playable } from './playable'; -import { WrapMode, WrapModeMask, WrappedInfo } from './types'; -import { INode } from '../utils/interfaces'; -import { BlendFunction, additive3D, additiveQuat } from './blending'; import { BoundTarget } from './target-modifier'; -import { director } from '../director'; +import { WrapMode, WrapModeMask, WrappedInfo } from './types'; enum PropertySpecialization { NodePosition, @@ -145,7 +144,7 @@ export class ICurveInstance { get propertyName () { return this._rootTargetProperty || ''; } - get curveDetail() { + get curveDetail () { return this._curveDetail; } } @@ -384,7 +383,7 @@ export class AnimationState extends Playable { this.repeatCount = 1; } - const propertyCurves = clip.getPropertyCurves(root); + const propertyCurves = clip.getPropertyCurves(); for (let iPropertyCurve = 0; iPropertyCurve < propertyCurves.length; ++iPropertyCurve) { const propertyCurve = propertyCurves[iPropertyCurve]; let samplerSharedGroup = this._samplerSharedGroups.find((value) => value.sampler === propertyCurve.sampler); @@ -414,7 +413,7 @@ export class AnimationState extends Playable { for (let i = 0, l = args.length; i < l; i++) { args[i] = restargs[i]; } - director.getAnimationManager().pushDelayEvent(this, '_emit', args); + cc.director.getAnimationManager().pushDelayEvent(this, '_emit', args); } public on (type: K, callback: EventCallbackOf, target?: any): void; @@ -678,26 +677,26 @@ export class AnimationState extends Playable { this.setTime(0); this._delayTime = this._delay; - director.getAnimationManager().addAnimation(this); + cc.director.getAnimationManager().addAnimation(this); this.emit('play', this); } protected onStop () { if (!this.isPaused) { - director.getAnimationManager().removeAnimation(this); + cc.director.getAnimationManager().removeAnimation(this); } this.emit('stop', this); } protected onResume () { - director.getAnimationManager().addAnimation(this); + cc.director.getAnimationManager().addAnimation(this); this.emit('resume', this); } protected onPause () { - director.getAnimationManager().removeAnimation(this); + cc.director.getAnimationManager().removeAnimation(this); this.emit('pause', this); } @@ -804,7 +803,7 @@ export class AnimationState extends Playable { lastIndex += direction; - director.getAnimationManager().pushDelayEvent(this, '_fireEvent', [lastIndex]); + cc.director.getAnimationManager().pushDelayEvent(this, '_fireEvent', [lastIndex]); } while (lastIndex !== eventIndex && lastIndex > -1 && lastIndex < length); } diff --git a/cocos/core/animation/cross-fade.ts b/cocos/core/animation/cross-fade.ts index 7e2d781e8e..878a706dad 100644 --- a/cocos/core/animation/cross-fade.ts +++ b/cocos/core/animation/cross-fade.ts @@ -3,10 +3,9 @@ */ import { clamp01 } from '../math/utils'; +import { remove } from '../utils/array'; import { AnimationState } from './animation-state'; import { Playable } from './playable'; -import { remove } from '../utils/array'; -import { director } from '../director'; interface IManagedState { state: AnimationState | null; @@ -85,7 +84,7 @@ export class CrossFade extends Playable { } let target = this._managedStates.find((weightedState) => weightedState.state === state); if (!target) { - target = { state, reference: 0, }; + target = { state, reference: 0 }; if (state) { state.play(); } @@ -99,9 +98,20 @@ export class CrossFade extends Playable { }); } + public clear () { + for (let iManagedState = 0; iManagedState < this._managedStates.length; ++iManagedState) { + const state = this._managedStates[iManagedState].state; + if (state) { + state.stop(); + } + } + this._managedStates.length = 0; + this._fadings.length = 0; + } + protected onPlay () { super.onPlay(); - director.getAnimationManager().addCrossFade(this); + cc.director.getAnimationManager().addCrossFade(this); } /** @@ -109,7 +119,7 @@ export class CrossFade extends Playable { */ protected onPause () { super.onPause(); - director.getAnimationManager().removeCrossFade(this); + cc.director.getAnimationManager().removeCrossFade(this); for (let iManagedState = 0; iManagedState < this._managedStates.length; ++iManagedState) { const state = this._managedStates[iManagedState].state; if (state) { @@ -123,7 +133,7 @@ export class CrossFade extends Playable { */ protected onResume () { super.onResume(); - director.getAnimationManager().addCrossFade(this); + cc.director.getAnimationManager().addCrossFade(this); for (let iManagedState = 0; iManagedState < this._managedStates.length; ++iManagedState) { const state = this._managedStates[iManagedState].state; if (state) { @@ -137,18 +147,7 @@ export class CrossFade extends Playable { */ protected onStop () { super.onStop(); - director.getAnimationManager().removeCrossFade(this); + cc.director.getAnimationManager().removeCrossFade(this); this.clear(); } - - public clear () { - for (let iManagedState = 0; iManagedState < this._managedStates.length; ++iManagedState) { - const state = this._managedStates[iManagedState].state; - if (state) { - state.stop(); - } - } - this._managedStates.length = 0; - this._fadings.length = 0; - } } diff --git a/cocos/core/animation/index.ts b/cocos/core/animation/index.ts index 8dd1b63491..40df8d13fd 100644 --- a/cocos/core/animation/index.ts +++ b/cocos/core/animation/index.ts @@ -14,7 +14,7 @@ export { } from './animation-state'; export * from './cubic-spline-value'; export * from './animation-component'; -export * from './skeletal-animation-clip'; +export * from './skeletal-animation-data-hub'; export * from './skeletal-animation-state'; export * from './skeletal-animation-component'; export * from './transform-utils'; @@ -27,4 +27,4 @@ export { } from './target-modifier'; export * from './curve-value-adapters'; -import './deprecated'; \ No newline at end of file +import './deprecated'; diff --git a/cocos/core/animation/skeletal-animation-component.ts b/cocos/core/animation/skeletal-animation-component.ts index 570a4087f5..833e381cf3 100644 --- a/cocos/core/animation/skeletal-animation-component.ts +++ b/cocos/core/animation/skeletal-animation-component.ts @@ -34,7 +34,7 @@ import { Node } from '../scene-graph/node'; import { INode } from '../utils/interfaces'; import { AnimationClip } from './animation-clip'; import { AnimationComponent } from './animation-component'; -import { SkeletalAnimationClip } from './skeletal-animation-clip'; +import { SkelAnimDataHub } from './skeletal-animation-data-hub'; import { SkeletalAnimationState } from './skeletal-animation-state'; import { getWorldTransformUntilRoot } from './transform-utils'; @@ -116,7 +116,7 @@ export class SkeletalAnimationComponent extends AnimationComponent { } public querySockets () { - const animPaths = this._defaultClip && Object.keys((this._defaultClip as SkeletalAnimationClip).convertedData).sort().reduce((acc, cur) => + const animPaths = this._defaultClip && Object.keys(SkelAnimDataHub.getOrExtract(this._defaultClip)).sort().reduce((acc, cur) => cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc), [] as string[]) || []; if (!animPaths.length) { return ['default animation clip missing/invalid']; } const out: string[] = []; @@ -164,7 +164,6 @@ export class SkeletalAnimationComponent extends AnimationComponent { } protected _doCreateState (clip: AnimationClip, name: string) { - if (!(clip instanceof SkeletalAnimationClip)) { console.warn('non-skeletal clip in skeletal component'); } const state = super._doCreateState(clip, name) as SkeletalAnimationState; state.rebuildSocketCurves(this._sockets); return state; diff --git a/cocos/core/animation/skeletal-animation-data-hub.ts b/cocos/core/animation/skeletal-animation-data-hub.ts new file mode 100644 index 0000000000..7fa206fc17 --- /dev/null +++ b/cocos/core/animation/skeletal-animation-data-hub.ts @@ -0,0 +1,151 @@ +/* + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @category animation + */ + +import { Mat4 } from '../math'; +import { getClassName } from '../utils/js'; +import { AnimationClip, IObjectCurveData } from './animation-clip'; +import { IPropertyCurveData } from './animation-curve'; +import { ComponentModifier, HierachyModifier, isCustomTargetModifier, isPropertyModifier } from './target-modifier'; + +type ConvertedData = Record; +}>; + +/** + * 骨骼动画数据转换中心。 + */ +export class SkelAnimDataHub { + + public static pool = new Map(); + + public static getOrExtract (clip: AnimationClip) { + let data = SkelAnimDataHub.pool.get(clip); + if (!data) { data = convertToSkeletalCurves(clip); SkelAnimDataHub.pool.set(clip, data); } + return data; + } +} + +function convertToSkeletalCurves (clip: AnimationClip) { + // tslint:disable-next-line: no-unused-expression + clip.hash; // calculate hash before conversion + const originalKeys = clip.keys; + const convertedData: ConvertedData = {}; + clip.curves.forEach((curve) => { + if (!curve.valueAdapter && + isCustomTargetModifier(curve.modifiers[0], HierachyModifier) && + isPropertyModifier(curve.modifiers[1])) { + const path = (curve.modifiers[0] as HierachyModifier).path; + let cs = convertedData[path]; + if (!cs) { cs = convertedData[path] = { props: {} }; } + const property = curve.modifiers[1] as string; + cs.props[property] = curve.data; + } + }); + // lazy eval the conversion due to memory-heavy ops + // many animation paths may not be actually in-use + for (const path of Object.keys(convertedData)) { + const props = convertedData[path] && convertedData[path].props; + if (!props) { continue; } + Object.defineProperty(props, 'worldMatrix', { + get: () => { + if (!props._worldMatrix) { + const { position, rotation, scale } = props; + // fixed step pre-sample + convertToUniformSample(clip, originalKeys, position); + convertToUniformSample(clip, originalKeys, rotation); + convertToUniformSample(clip, originalKeys, scale); + // transform to world space + convertToWorldSpace(convertedData, path, props); + } + return props._worldMatrix; + }, + }); + } + const values: number[] = new Array(Math.ceil(clip.sample * clip.duration / clip.speed) + 1); + for (let i = 0; i < values.length; i++) { values[i] = i; } + clip.curves = [{ // leave only frameID animation + modifiers: [ + new HierachyModifier(''), + new ComponentModifier(getClassName(cc.SkeletalAnimationComponent)), + 'frameID', + ], + data: { keys: 0, values, interpolate: false }, + }]; + clip.keys = [values.map((_, i) => i * clip.speed / clip.sample)]; + clip.duration = clip.keys[0][values.length - 1]; + return convertedData; +} + +function convertToUniformSample (clip: AnimationClip, originalKeys: number[][], curve: IPropertyCurveData) { + const keys = originalKeys[curve.keys]; curve.keys = 0; + const len = clip.keys[0].length; + const values: any[] = []; + if (!keys || keys.length === 1) { + for (let i = 0; i < len; i++) { + values[i] = curve.values[0].clone(); // never forget to clone + } + } else { + for (let i = 0, idx = 0; i < len; i++) { + let time = i * clip.speed / clip.sample; + while (keys[idx] <= time) { idx++; } + if (idx > keys.length - 1) { idx = keys.length - 1; time = keys[idx]; } + else if (idx === 0) { idx = 1; } + const from = curve.values[idx - 1].clone(); + from.lerp(curve.values[idx], (time - keys[idx - 1]) / (keys[idx] - keys[idx - 1])); + values[i] = from; + } + } + curve.values = values; +} + +function convertToWorldSpace (convertedData: ConvertedData, path: string, props: IObjectCurveData) { + const oPos = props.position.values; + const oRot = props.rotation.values; + const oScale = props.scale.values; + const matrix = oPos.map(() => new Mat4()); + const idx = path.lastIndexOf('/'); + let pMatrix: Mat4[] | null = null; + if (idx > 0) { + const name = path.substring(0, idx); + const data = convertedData[name]; + if (!data || !data.props) { console.warn('no data for parent bone?'); return; } + pMatrix = data.props.worldMatrix.values; + } + // all props should have the same length now + for (let i = 0; i < oPos.length; i++) { + const oT = oPos[i]; + const oR = oRot[i]; + const oS = oScale[i]; + const m = matrix[i]; + Mat4.fromRTS(m, oR, oT, oS); + if (pMatrix) { Mat4.multiply(m, pMatrix[i], m); } + } + Object.keys(props).forEach((k) => delete props[k]); + props._worldMatrix = { keys: 0, interpolate: false, values: matrix }; +} diff --git a/cocos/core/animation/skeletal-animation-state.ts b/cocos/core/animation/skeletal-animation-state.ts index 0ae0807208..f9e11a5c0e 100644 --- a/cocos/core/animation/skeletal-animation-state.ts +++ b/cocos/core/animation/skeletal-animation-state.ts @@ -29,11 +29,12 @@ import { SkinningModelComponent } from '../3d/framework/skinning-model-component'; import { Mat4 } from '../math'; +import { INode } from '../utils/interfaces'; import { IObjectCurveData } from './animation-clip'; import { AnimCurve } from './animation-curve'; import { AnimationState, ICurveInstance } from './animation-state'; -import { SkeletalAnimationClip } from './skeletal-animation-clip'; import { Socket } from './skeletal-animation-component'; +import { SkelAnimDataHub } from './skeletal-animation-data-hub'; import { ComponentModifier, HierachyModifier, TargetModifier } from './target-modifier'; import { getPathFromRoot, getWorldTransformUntilRoot } from './transform-utils'; @@ -48,13 +49,18 @@ function isFrameIDCurve (modifiers: TargetModifier[]) { export class SkeletalAnimationState extends AnimationState { + public initialize (root: INode) { + SkelAnimDataHub.getOrExtract(this.clip); + super.initialize(root); + } + public onPlay () { super.onPlay(); const comps = this._targetNode!.getComponentsInChildren(SkinningModelComponent); for (let i = 0; i < comps.length; ++i) { const comp = comps[i] as SkinningModelComponent; if (comp.skinningRoot === this._targetNode) { - comp.uploadAnimation(this.clip as SkeletalAnimationClip); + comp.uploadAnimation(this.clip); } } } @@ -85,7 +91,7 @@ export class SkeletalAnimationState extends AnimationState { const targetNode = root.getChildByPath(socket.path); if (!targetNode || !socket.target) { return null; } const targetPath = socket.path; - const sourceData = (this.clip as SkeletalAnimationClip).convertedData; + const sourceData = SkelAnimDataHub.getOrExtract(this.clip); // find lowest joint animation let animPath = targetPath; let source = sourceData[animPath]; diff --git a/cocos/core/assets/material.ts b/cocos/core/assets/material.ts index 9dd53f6836..438ddeec09 100644 --- a/cocos/core/assets/material.ts +++ b/cocos/core/assets/material.ts @@ -30,7 +30,7 @@ import { ccclass, property } from '../../core/data/class-decorator'; import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc'; -import { builtinResMgr } from '../3d/builtin'; +import { builtinResMgr } from '../3d/builtin/init'; import { RenderableComponent } from '../3d/framework/renderable-component'; import { GFXBindingType } from '../gfx/define'; import { GFXTextureView } from '../gfx/texture-view'; diff --git a/cocos/core/platform/event-manager/input-manager.ts b/cocos/core/platform/event-manager/input-manager.ts index 9f59d06294..7478638fec 100644 --- a/cocos/core/platform/event-manager/input-manager.ts +++ b/cocos/core/platform/event-manager/input-manager.ts @@ -28,14 +28,14 @@ * @hidden */ +import { game, Game } from '../../game'; import { Vec2 } from '../../math/index'; import { rect } from '../../math/rect'; import { macro } from '../macro'; import sys from '../sys'; +import eventManager from './event-manager'; import { EventAcceleration, EventKeyboard, EventMouse, EventTouch } from './events'; import { Touch } from './touch'; -import eventManager from './event-manager'; -import { game, Game } from '../../game'; const TOUCH_TIMEOUT = macro.TOUCH_TIMEOUT; @@ -682,6 +682,7 @@ class InputManager { MSPointerUp : this.handleTouchesEnd, MSPointerCancel : this.handleTouchesCancel, }; + // tslint:disable-next-line: forin for (const eventName in _pointerEventsMap) { const touchEvent = _pointerEventsMap[eventName]; // @ts-ignore @@ -818,7 +819,7 @@ class InputManager { const inputManager = new InputManager(); -game.on(Game.EVENT_ENGINE_INITED, function () { +game.on(Game.EVENT_ENGINE_INITED, () => { // register system events if (!CC_EDITOR && game.config.registerSystemEvent) { inputManager.registerSystemEvent(game.canvas); diff --git a/cocos/core/renderer/models/joints-texture-utils.ts b/cocos/core/renderer/models/joints-texture-utils.ts index 338ceb394e..44b31e7189 100644 --- a/cocos/core/renderer/models/joints-texture-utils.ts +++ b/cocos/core/renderer/models/joints-texture-utils.ts @@ -27,7 +27,8 @@ * @hidden */ -import { SkeletalAnimationClip } from '../../animation/skeletal-animation-clip'; +import { AnimationClip } from '../../animation/animation-clip'; +import { SkelAnimDataHub } from '../../animation/skeletal-animation-data-hub'; import { Skeleton } from '../../assets/skeleton'; import { GFXFormat, GFXFormatInfos } from '../../gfx/define'; import { GFXDevice, GFXFeature } from '../../gfx/device'; @@ -165,7 +166,7 @@ export class JointsTexturePool { /** * 获取指定动画片段的骨骼贴图 */ - public getJointsTextureWithAnimation (skeleton: Skeleton, clip: SkeletalAnimationClip) { + public getJointsTextureWithAnimation (skeleton: Skeleton, clip: AnimationClip) { const hash = skeleton.hash ^ clip.hash; let texture: IJointsTextureHandle | null = this._textureBuffers.get(hash) || null; if (texture) { texture.refCount++; return texture; } @@ -175,7 +176,7 @@ export class JointsTexturePool { if (!handle) { return null; } texture = { pixelOffset: handle.start / this._formatSize, refCount: 1, hash, handle }; const textureBuffer = new Float32Array(bufSize); - const data = clip.convertedData; + const data = SkelAnimDataHub.getOrExtract(clip); for (let i = 0; i < skeleton.joints.length; i++) { const nodeData = data[skeleton.joints[i]]; if (!nodeData || !nodeData.props) { continue; } diff --git a/cocos/core/renderer/models/skinning-model.ts b/cocos/core/renderer/models/skinning-model.ts index 13e153258c..a910a12ee3 100644 --- a/cocos/core/renderer/models/skinning-model.ts +++ b/cocos/core/renderer/models/skinning-model.ts @@ -27,7 +27,7 @@ * @hidden */ -import { SkeletalAnimationClip } from '../../animation/skeletal-animation-clip'; +import { AnimationClip } from '../../animation/animation-clip'; import { Skeleton } from '../../assets/skeleton'; import { GFXBuffer } from '../../gfx/buffer'; import { GFXAddress, GFXBufferUsageBit, GFXFilter, GFXMemoryUsageBit } from '../../gfx/define'; @@ -68,7 +68,7 @@ export class JointsAnimationInfo { JointsAnimationInfo.pool.delete(nodeID); } - public static switchClip (nodeID: string, clip: SkeletalAnimationClip | null) { + public static switchClip (nodeID: string, clip: AnimationClip | null) { const info = JointsAnimationInfo.pool.get(nodeID); if (!info) { return; } info.data[0] = clip ? clip.keys[0].length : 1; @@ -100,7 +100,7 @@ interface IJointsInfo { export class SkinningModel extends Model { - public uploadedAnim: SkeletalAnimationClip | null = null; + public uploadedAnim: AnimationClip | null = null; private _jointsMedium: IJointsInfo; private _skeleton: Skeleton | null = null; @@ -140,7 +140,7 @@ export class SkinningModel extends Model { this.uploadAnimation(this.uploadedAnim); } - public uploadAnimation (anim: SkeletalAnimationClip | null) { + public uploadAnimation (anim: AnimationClip | null) { if (!this._skeleton) { return; } this.uploadedAnim = anim; const texture = this.uploadedAnim ? diff --git a/cocos/core/scene-graph/node-event-processor.ts b/cocos/core/scene-graph/node-event-processor.ts index 22915f20b9..34d8dddd58 100644 --- a/cocos/core/scene-graph/node-event-processor.ts +++ b/cocos/core/scene-graph/node-event-processor.ts @@ -27,18 +27,17 @@ * @category scene-graph */ -import { INode } from '../utils/interfaces'; -import { ITargetImpl, EventTarget } from '../event/event-target'; -import { eventManager, EventMouse, EventTouch, Touch } from '../platform/event-manager'; +import Event from '../event/event'; +import { EventTarget } from '../event/event-target'; +import { Vec2 } from '../math/vec2'; import { SystemEventType } from '../platform/event-manager/event-enum'; import { EventListener } from '../platform/event-manager/event-listener'; -import { array } from '../utils/js'; -import Event from '../event/event'; -import { Vec2 } from '../math/vec2'; +import { eventManager } from '../platform/event-manager/event-manager'; +import { EventMouse, EventTouch } from '../platform/event-manager/events'; +import { Touch } from '../platform/event-manager/touch'; +import { INode } from '../utils/interfaces'; -const fastRemove = array.fastRemove; - -let _cachedArray = new Array(16); +const _cachedArray = new Array(16); let _currentHovered: INode | null = null; let pos = new Vec2(); @@ -349,7 +348,7 @@ export class NodeEventProcessor { public reattach (): void { if (this.touchListener) { - var mask = this.touchListener.mask = _searchMaskInParent(this._node); + const mask = this.touchListener.mask = _searchMaskInParent(this._node); if (this.mouseListener) { this.mouseListener.mask = mask; } diff --git a/cocos/core/scene-graph/node.ts b/cocos/core/scene-graph/node.ts index 549ded7245..d44b040bf5 100644 --- a/cocos/core/scene-graph/node.ts +++ b/cocos/core/scene-graph/node.ts @@ -31,8 +31,8 @@ import { UIComponent, UITransformComponent } from '../components/ui-base'; import { ccclass, property } from '../data/class-decorator'; import Event from '../event/event'; import { Mat3, Mat4, Quat, Size, Vec2, Vec3 } from '../math'; -import { eventManager } from '../platform/event-manager'; import { SystemEventType } from '../platform/event-manager/event-enum'; +import { eventManager } from '../platform/event-manager/event-manager'; import { INode } from '../utils/interfaces'; import { BaseNode } from './base-node'; import { Layers } from './layers'; diff --git a/cocos/core/splash-image.ts b/cocos/core/splash-image.ts index 5b97b69c05..a2caea0890 100644 --- a/cocos/core/splash-image.ts +++ b/cocos/core/splash-image.ts @@ -2,38 +2,56 @@ * @hidden */ -import { GFXDevice } from "./gfx/device"; -import { GFXCommandBuffer } from "./gfx/command-buffer"; -import { GFXCommandBufferType, GFXBufferUsageBit, GFXClearFlag, IGFXRect, GFXTextureType, GFXTextureUsageBit, GFXFormat, GFXTextureViewType, GFXMemoryUsageBit, GFXBufferTextureCopy } from "./gfx/define"; -import { GFXInputAssembler, IGFXAttribute } from "./gfx/input-assembler"; -import { GFXBuffer } from "./gfx/buffer"; -import { GFXPipelineState } from "./gfx/pipeline-state"; -import { GFXFramebuffer } from "./gfx/framebuffer"; -import { Material } from "./assets/material"; -import { EffectAsset } from "./assets/effect-asset"; -import { GFXTexture } from "./gfx/texture"; -import { GFXTextureView } from "./gfx/texture-view"; -import { clamp01 } from "./math/utils"; -import * as easing from "./animation/easing"; +import * as easing from './animation/easing'; +import { EffectAsset } from './assets/effect-asset'; +import { Material } from './assets/material'; +import { GFXBuffer } from './gfx/buffer'; +import { GFXCommandBuffer } from './gfx/command-buffer'; +import { GFXBufferTextureCopy, GFXBufferUsageBit, GFXClearFlag, GFXCommandBufferType, GFXFormat, + GFXMemoryUsageBit, GFXTextureType, GFXTextureUsageBit, GFXTextureViewType, IGFXRect } from './gfx/define'; +import { GFXDevice } from './gfx/device'; +import { GFXFramebuffer } from './gfx/framebuffer'; +import { GFXInputAssembler, IGFXAttribute } from './gfx/input-assembler'; +import { GFXPipelineState } from './gfx/pipeline-state'; +import { GFXTexture } from './gfx/texture'; +import { GFXTextureView } from './gfx/texture-view'; +import { clamp01 } from './math/utils'; -export type SplashEffectType = "none" | "Fade-in-out"; +export type SplashEffectType = 'none' | 'Fade-in-out'; -export interface SplashSetting { +export interface ISplashSetting { readonly totalTime: number; readonly base64src: string; readonly effect: SplashEffectType; // readonly clearColor: any; } +// tslint:disable-next-line: max-line-length const defaultSrcBase64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADqCAYAAADnPAqjAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAFbVSURBVHhe7X0HgBRF9vfrns2wu4Ql55xzBhMiiAqCqICoKGI6vVP/oud5gLiC9x2nnOE805kAAQkCAookEYkqKjnnvGR2F9g03d97r6pnemZ6ZmeX3ZnZ2fnNvKmqV9U9Fd6r1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oGPdF52n5qqvYmq+xdbC4o0zCgOzyyXAxP88+2y2AupQvN8h4ecKuj46F6v+WP2fKPhzMZzHKa2St8CWG5Wqq1fyrMIYwPtdwIbmGc8n255ITX3hLJbUA3iRy3sgBvBe2c2bN6fVRFfJjRWixUlQUsEwjN2uZeM1GD3f0GxRVzEQ39MwzcA2gN/jUED38EPtZ55hmjHhlf/biWn/MwrZeclyg74fm5j7Zs+ebTfSZJgukDyr//ACx3sn7sD0ZeHPhy2b1PoCFNXnSVqYdcdUDe5/8cUXnS3fNQPg/wNUUJtMEKHeLQAAAABJRU5ErkJggg=='; - export class SplashImage { + public set splashFinish (v: boolean) { + this._splashFinish = v; + this._tryToStart(); + } + public set loadFinish (v: boolean) { + this._loadFinish = v; + this._tryToStart(); + } + + public static get instance () { + if (SplashImage._ins == null) { + SplashImage._ins = new SplashImage(); + } + return SplashImage._ins; + } + + private static _ins: SplashImage; private handle: number = 0; private callBack: Function | null = null; private cancelAnimate: boolean = false; private startTime: number = -1; - private setting!: SplashSetting; + private setting!: ISplashSetting; private image!: HTMLImageElement; private device!: GFXDevice; private cmdBuff!: GFXCommandBuffer; @@ -49,42 +67,26 @@ export class SplashImage { private textureView!: GFXTextureView; private _splashFinish: boolean = false; - public set splashFinish (v: boolean) { - this._splashFinish = v; - this._tryToStart(); - } private _loadFinish: boolean = false; - public set loadFinish (v: boolean) { - this._loadFinish = v; - this._tryToStart(); - } - - private _tryToStart () { - if (this._splashFinish && this._loadFinish) { - if (this.callBack) { - this.callBack(); - this.hide(); - } - } - } + private constructor () { } public main (device: GFXDevice) { if (window._CCSettings && window._CCSettings.PreviewSetting) { this.setting = window._CCSettings.PreviewSetting; (this.setting.totalTime as number) = this.setting.totalTime != null ? this.setting.totalTime : 3000; (this.setting.base64src as string) = this.setting.base64src != null ? this.setting.base64src : defaultSrcBase64; - (this.setting.effect as SplashEffectType) = this.setting.effect != null ? this.setting.effect : "none"; + (this.setting.effect as SplashEffectType) = this.setting.effect != null ? this.setting.effect : 'none'; } else { this.setting = { totalTime: 3000, base64src: defaultSrcBase64, - effect: 'none' - } + effect: 'none', + }; } if (this.setting.totalTime <= 0) { - if (this.callBack) this.callBack(); + if (this.callBack) { this.callBack(); } this.callBack = null; (this.setting as any) = null; delete SplashImage._ins; @@ -105,6 +107,15 @@ export class SplashImage { this.callBack = cb; } + private _tryToStart () { + if (this._splashFinish && this._loadFinish) { + if (this.callBack) { + this.callBack(); + this.hide(); + } + } + } + private init () { this.initCMD(); this.initIA(); @@ -250,37 +261,44 @@ export class SplashImage { // }); const program = { - "name": "util/splash-image", - "techniques": [ - { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "program": "util/splash-image|splash-vs:vert|splash-fs:frag", "depthStencilState": { "depthTest": true, "depthWrite": false }, "properties": { "mainTexture": { "value": "grey", "type": 28 }, "u_precent": { "type": 13 } } }] } - ], - "shaders": [ + name: 'util/splash-image', + techniques: [ { - "name": "util/splash-image|splash-vs:vert|splash-fs:frag", - "hash": 2381344969, - "glsl3": { - "vert": `\nprecision mediump float;\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision mediump float;\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nuniform splashFrag {\n float u_precent;\n};\nvec4 frag () {\n vec4 color = texture(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` + passes: [{ blendState: { targets: [{ blend: true, blendSrc: 2, blendDst: 4, blendDstAlpha: 4 }] }, + program: 'util/splash-image|splash-vs:vert|splash-fs:frag', + depthStencilState: { depthTest: true, depthWrite: false }, + properties: { mainTexture: { value: 'grey', type: 28 }, u_precent: { type: 13 } } }], + }, + ], + shaders: [ + { + name: 'util/splash-image|splash-vs:vert|splash-fs:frag', + hash: 2381344969, + glsl3: { + // tslint:disable: max-line-length + vert: `\nprecision mediump float;\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, + frag: `\nprecision mediump float;\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nuniform splashFrag {\n float u_precent;\n};\nvec4 frag () {\n vec4 color = texture(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n`, }, - "glsl1": { - "vert": `\nprecision mediump float;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision mediump float;\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nuniform float u_precent;\nvec4 frag () {\n vec4 color = texture2D(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nvoid main() { gl_FragColor = frag(); }\n` + glsl1: { + vert: `\nprecision mediump float;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, + frag: `\nprecision mediump float;\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nuniform float u_precent;\nvec4 frag () {\n vec4 color = texture2D(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nvoid main() { gl_FragColor = frag(); }\n`, + // tslint:enable: max-line-length }, - "builtins": { "globals": { "blocks": [], "samplers": [] }, "locals": { "blocks": [], "samplers": [] } }, - "defines": [], - "blocks": [ + builtins: { globals: { blocks: [], samplers: [] }, locals: { blocks: [], samplers: [] } }, + defines: [], + blocks: [ { - "name": "splashFrag", "defines": [], "binding": 0, "members": [ - { "name": "u_precent", "type": 13, "count": 1 } - ] - } + name: 'splashFrag', defines: [], binding: 0, members: [ + { name: 'u_precent', type: 13, count: 1 }, + ], + }, ], - "samplers": [ - { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "binding": 30 } + samplers: [ + { name: 'mainTexture', type: 28, count: 1, defines: [], binding: 30 }, ], - "dependencies": {} - } - ] + dependencies: {}, + }, + ], }; const effect = new EffectAsset(); @@ -356,15 +374,4 @@ export class SplashImage { this.indicesBuffers.destroy(); (this.indicesBuffers as any) = null; } - - private static _ins: SplashImage; - - public static get instance () { - if (SplashImage._ins == null) { - SplashImage._ins = new SplashImage(); - } - return SplashImage._ins; - } - - private constructor () { }; -} \ No newline at end of file +} diff --git a/tslint.json b/tslint.json index 29895e0253..3a8e5adc83 100644 --- a/tslint.json +++ b/tslint.json @@ -13,6 +13,7 @@ true, "check-open-brace" ], + "no-namespace": false, "no-console": false, "space-before-function-paren": true, "max-classes-per-file": false, From d47ebecf1c20a1657d76a28033a739f7aab4730a Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Fri, 18 Oct 2019 11:59:02 +0800 Subject: [PATCH 13/33] joints texture: handle negative zeros on CPU (#5566) --- .../renderer/models/joints-texture-utils.ts | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/cocos/core/renderer/models/joints-texture-utils.ts b/cocos/core/renderer/models/joints-texture-utils.ts index 44b31e7189..3e6199d70c 100644 --- a/cocos/core/renderer/models/joints-texture-utils.ts +++ b/cocos/core/renderer/models/joints-texture-utils.ts @@ -60,20 +60,24 @@ const v3_1 = new Vec3(); const qt_1 = new Quat(); const v3_2 = new Vec3(); +// negative zeros cannot be decoded correctly at GLSL 100 minimum highp float precision, 1/1024 +// and it has a significant effect on the final transformation +function makeStable (n: number) { return n ? n : 0; } + // Linear Blending Skinning function uploadJointDataLBS (out: Float32Array, base: number, mat: Mat4, firstBone: boolean) { - out[base + 0] = mat.m00; - out[base + 1] = mat.m01; - out[base + 2] = mat.m02; - out[base + 3] = mat.m12; - out[base + 4] = mat.m04; - out[base + 5] = mat.m05; - out[base + 6] = mat.m06; - out[base + 7] = mat.m13; - out[base + 8] = mat.m08; - out[base + 9] = mat.m09; - out[base + 10] = mat.m10; - out[base + 11] = mat.m14; + out[base + 0] = makeStable(mat.m00); + out[base + 1] = makeStable(mat.m01); + out[base + 2] = makeStable(mat.m02); + out[base + 3] = makeStable(mat.m12); + out[base + 4] = makeStable(mat.m04); + out[base + 5] = makeStable(mat.m05); + out[base + 6] = makeStable(mat.m06); + out[base + 7] = makeStable(mat.m13); + out[base + 8] = makeStable(mat.m08); + out[base + 9] = makeStable(mat.m09); + out[base + 10] = makeStable(mat.m10); + out[base + 11] = makeStable(mat.m14); } // Dual Quaternion Skinning @@ -86,17 +90,17 @@ function uploadJointDataDQS (out: Float32Array, base: number, mat: Mat4, firstBo Quat.set(dq_1, v3_1.x, v3_1.y, v3_1.z, 0); Quat.multiplyScalar(dq_1, Quat.multiply(dq_1, dq_1, qt_1), 0.5); // upload - out[base + 0] = qt_1.x; - out[base + 1] = qt_1.y; - out[base + 2] = qt_1.z; - out[base + 3] = qt_1.w; - out[base + 4] = dq_1.x; - out[base + 5] = dq_1.y; - out[base + 6] = dq_1.z; - out[base + 7] = dq_1.w; - out[base + 8] = v3_2.x; - out[base + 9] = v3_2.y; - out[base + 10] = v3_2.z; + out[base + 0] = makeStable(qt_1.x); + out[base + 1] = makeStable(qt_1.y); + out[base + 2] = makeStable(qt_1.z); + out[base + 3] = makeStable(qt_1.w); + out[base + 4] = makeStable(dq_1.x); + out[base + 5] = makeStable(dq_1.y); + out[base + 6] = makeStable(dq_1.z); + out[base + 7] = makeStable(dq_1.w); + out[base + 8] = makeStable(v3_2.x); + out[base + 9] = makeStable(v3_2.y); + out[base + 10] = makeStable(v3_2.z); } function roundUpTextureSize (targetLength: number, formatSize: number) { From 2e59be932c5b3cbfd806d1ab73fdc212fed934c0 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Mon, 21 Oct 2019 11:06:15 +0800 Subject: [PATCH 14/33] misc pipeline fix (#5558) * fix tone mapping * linter fix * fix shadow cache * better shadow fix * draw shadow only on default visibility --- cocos/core/3d/builtin/effects.ts | 18 ++++---- .../core/pipeline/forward/forward-pipeline.ts | 1 - cocos/core/pipeline/forward/forward-stage.ts | 5 ++- cocos/core/pipeline/render-pipeline.ts | 15 +------ cocos/core/renderer/scene/camera.ts | 8 ++-- cocos/core/renderer/scene/planar-shadows.ts | 42 ++++++++++++++----- cocos/core/renderer/scene/render-scene.ts | 12 +++--- cocos/core/utils/profiler/profiler.ts | 4 +- cocos/ui/components/ui-model-component.ts | 14 +++---- 9 files changed, 67 insertions(+), 52 deletions(-) diff --git a/cocos/core/3d/builtin/effects.ts b/cocos/core/3d/builtin/effects.ts index 97f547d704..216df95d0b 100644 --- a/cocos/core/3d/builtin/effects.ts +++ b/cocos/core/3d/builtin/effects.ts @@ -169,14 +169,14 @@ export default [ "shaders": [ { "name": "builtin-standard|standard-vs:vert|standard-fs:frag", - "hash": 1071940485, + "hash": 2079211605, "glsl3": { "vert": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp mat4 cc_matWorlds[10];\n};\nstruct StandardAttributes {\n vec4 position;\n vec3 normal;\n vec4 tangent;\n int index;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec4 a_tangent;\n#if USE_BATCHING\nin float a_index;\n#endif\nvoid CCDecode (out StandardAttributes attr) {\n attr.position = vec4(a_position, 1.0);\n attr.normal = a_normal;\n attr.tangent = a_tangent;\n#if USE_BATCHING\n attr.index = int(a_index + 0.5);\n#endif\n}\n#if CC_USE_SKINNING\nin vec4 a_weights;\nin vec4 a_joints;\nuniform CCSkinningTexture {\n highp vec4 cc_jointsTextureInfo;\n};\nuniform CCSkinningAnimation {\n highp vec4 cc_jointsAnimInfo;\n};\nuniform sampler2D cc_jointsTexture;\n#if CC_USE_SKINNING == 1\n highp float decode32(highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - step(128.0, rgba[3]) * 2.0;\n highp float Exponent = 2.0 * mod(rgba[3], 128.0) + step(128.0, rgba[2]) - 127.0;\n highp float Mantissa = mod(rgba[2], 128.0) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n#endif\n#if CC_USE_SKINNING == 1\n void getJointDQ(float i, out vec4 Qr, out vec4 Qt, out vec3 S) {\n highp float j = 12.0 * (cc_jointsAnimInfo.x * i + cc_jointsAnimInfo.y) + cc_jointsTextureInfo.z;\n highp float invSize = cc_jointsTextureInfo.y;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointsTextureInfo.x;\n y = (y + 0.5) * invSize;\n Qr = vec4(\n decode32(texture(cc_jointsTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 3.5) * invSize, y)))\n );\n Qt = vec4(\n decode32(texture(cc_jointsTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 7.5) * invSize, y)))\n );\n S = vec3(\n decode32(texture(cc_jointsTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointsTexture, vec2((x + 10.5) * invSize, y)))\n );\n }\n#elif CC_USE_SKINNING == 2\n void getJointDQ(float i, out vec4 Qr, out vec4 Qt, out vec3 S) {\n highp float j = 3.0 * (cc_jointsAnimInfo.x * i + cc_jointsAnimInfo.y) + cc_jointsTextureInfo.z;\n highp float invSize = cc_jointsTextureInfo.y;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointsTextureInfo.x;\n y = (y + 0.5) * invSize;\n Qr = texture(cc_jointsTexture, vec2((x + 0.5) * invSize, y));\n Qt = texture(cc_jointsTexture, vec2((x + 1.5) * invSize, y));\n S = texture(cc_jointsTexture, vec2((x + 2.5) * invSize, y)).xyz;\n }\n#endif\nvoid skinRTS(out vec4 R, out vec3 T, out vec3 S) {\n vec4 r, t, Qt = vec4(0.0); vec3 s;\n R = vec4(0.0); S = vec3(0.0);\n for (int i = 0; i < 4; i++) {\n float w = a_weights[i];\n getJointDQ(a_joints[i], r, t, s);\n S += s * w; R += r * w; Qt += t * w;\n }\n float invNorm = 1.0 / length(R); R *= invNorm; Qt *= invNorm;\n T = 2.0 * (R.w * Qt.xyz - Qt.w * R.xyz + cross(R.xyz, Qt.xyz));\n}\nvec3 VectorTransformQuat(vec3 v, vec4 Q) {\n return v + 2.0 * cross(Q.xyz, cross(Q.xyz, v) + Q.w * v);\n}\nvoid CCSkin(inout vec4 position) {\n vec4 R; vec3 T, S;\n skinRTS(R, T, S);\n position.xyz = VectorTransformQuat(position.xyz * S, R) + T;\n}\nvoid CCSkin(inout StandardAttributes attr) {\n vec4 R; vec3 T, S;\n skinRTS(R, T, S);\n attr.position.xyz = VectorTransformQuat(attr.position.xyz * S, R) + T;\n attr.normal = VectorTransformQuat(attr.normal, R);\n attr.tangent.xyz = VectorTransformQuat(attr.tangent.xyz, R);\n}\n#endif\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n int index;\n};\nvoid CCAttrToInput (in StandardAttributes attr, out StandardVertInput In) {\n In.position = attr.position;\n In.normal = attr.normal;\n In.tangent = attr.tangent;\n In.index = attr.index;\n}\nvoid CCVertInput (out StandardVertInput In) {\n StandardAttributes attr;\n CCDecode(attr);\n #if CC_USE_SKINNING\n CCSkin(attr);\n #endif\n CCAttrToInput(attr, In);\n}\nuniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScale;\n vec4 pbrParams;\n vec4 pbrScale;\n vec4 emissive;\n vec4 emissiveScale;\n};\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nout vec3 v_position;\nout vec3 v_normal;\n#if USE_NORMAL_MAP\n out vec3 v_tangent;\n out vec3 v_bitangent;\n#endif\n#if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n in vec2 a_texCoord;\n out vec2 v_uv;\n#endif\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n #if USE_BATCHING\n mat4 matWorld = cc_matWorlds[In.index];\n mat4 matWorldIT = transposeMat4(matWorld);\n #else\n mat4 matWorld = cc_matWorld;\n mat4 matWorldIT = cc_matWorldIT;\n #endif\n vec4 pos = matWorld * In.position;\n v_position = pos.xyz;\n v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n #if USE_NORMAL_MAP\n v_tangent = normalize((matWorldIT * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n #if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #endif\n return cc_matViewProj * pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\n#endif\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nuniform CCForwardLight {\n highp vec4 cc_sphereLitPos[2];\n vec4 cc_sphereLitSizeRange[2];\n vec4 cc_sphereLitColor[2];\n highp vec4 cc_spotLitPos[2];\n vec4 cc_spotLitSizeRangeAngle[2];\n vec4 cc_spotLitDir[2];\n vec4 cc_spotLitColor[2];\n};\nfloat SmoothDistAtt2(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float factor2 = factor * factor;\n float factor3 = factor2 * factor2;\n float smoothFactor = clamp(1.0 - factor3 * factor3, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat SmoothDistAtt(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt(float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt(vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GGXMobile(float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular(float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox(vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nvec3 CalcDynamicLighting(vec3 worldPos, vec3 N, vec3 V, vec3 diffuse, vec3 specular, float roughness) {\n vec3 lighting = vec3(0.0);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n for (int i = 0; i < 2; i++) {\n vec3 PLU = cc_sphereLitPos[i].xyz - worldPos;\n vec3 PL = normalize(PLU);\n vec3 PH = normalize(PL + V);\n float PNL = max(dot(N, PL), 0.001);\n float PNH = max(dot(N, PH), 0.0);\n float distSqr = dot(PLU, PLU);\n float litRadius = cc_sphereLitSizeRange[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_sphereLitSizeRange[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(roughness, PNH, PH, N);\n lighting += PNL * cc_sphereLitColor[i].rgb * cc_sphereLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n for (int i = 0; i < 2; i++) {\n vec3 SLU = cc_spotLitPos[i].xyz - worldPos;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_spotLitSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_spotLitSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float cosInner = max(dot(-cc_spotLitDir[i].xyz, SL), 0.01);\n float cosOuter = cc_spotLitSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n att *= GetAngleAtt(SL, -cc_spotLitDir[i].xyz, litAngleScale, litAngleOffset);\n vec3 lspec = specular * CalcSpecular(roughness, SNH, SH, N);\n lighting += SNL * cc_spotLitColor[i].rgb * cc_spotLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n return lighting;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n float roughness;\n float metallic;\n float occlusion;\n};\nvec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NV = max(abs(dot(N, V)), 0.001);\n float NL = max(dot(N, L), 0.001);\n float NH = max(dot(N, H), 0.0);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w * (diffuseContrib + specularContrib);\n finalColor += CalcDynamicLighting(s.position, N, V, diffuse, specular, s.roughness);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = textureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb) * cc_ambientSky.w;\n #endif\n finalColor += env * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n return vec4(finalColor, s.albedo.a);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nuniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScale;\n vec4 pbrParams;\n vec4 pbrScale;\n vec4 emissive;\n vec4 emissiveScale;\n};\nin vec3 v_position;\n#if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n in vec2 v_uv;\n#endif\nin vec3 v_normal;\n#if USE_NORMAL_MAP\n in vec3 v_tangent;\n in vec3 v_bitangent;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n vec4 texColor = texture(albedoMap, v_uv);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScale.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScale.w) discard;\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture(normalMap, v_uv).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrScale.w) * normalize(v_tangent) +\n (nmmp.y * pbrScale.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n pbr = texture(pbrMap, v_uv);\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture(metallicRoughnessMap, v_uv);\n pbr.METALLIC_CHANNEL = metallicRoughness.METALLIC_CHANNEL;\n pbr.ROUGHNESS_CHANNEL = metallicRoughness.ROUGHNESS_CHANNEL;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.OCCLUSION_CHANNEL = texture(occlusionMap, v_uv).OCCLUSION_CHANNEL;\n #endif\n pbr *= pbrScale;\n s.roughness = clamp(pbr.ROUGHNESS_CHANNEL, 0.04, 1.0);\n s.metallic = clamp(pbr.METALLIC_CHANNEL, 0.0, 0.96);\n s.occlusion = pbr.OCCLUSION_CHANNEL;\n s.emissive = emissive.rgb * emissiveScale.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture(emissiveMap, v_uv).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n return CCFragOutput(color);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` + "frag": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\n#endif\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nuniform CCForwardLight {\n highp vec4 cc_sphereLitPos[2];\n vec4 cc_sphereLitSizeRange[2];\n vec4 cc_sphereLitColor[2];\n highp vec4 cc_spotLitPos[2];\n vec4 cc_spotLitSizeRangeAngle[2];\n vec4 cc_spotLitDir[2];\n vec4 cc_spotLitColor[2];\n};\nfloat SmoothDistAtt2(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float factor2 = factor * factor;\n float factor3 = factor2 * factor2;\n float smoothFactor = clamp(1.0 - factor3 * factor3, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat SmoothDistAtt(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt(float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt(vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GGXMobile(float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular(float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox(vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nvec3 CalcDynamicLighting(vec3 worldPos, vec3 N, vec3 V, vec3 diffuse, vec3 specular, float roughness) {\n vec3 lighting = vec3(0.0);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n for (int i = 0; i < 2; i++) {\n vec3 PLU = cc_sphereLitPos[i].xyz - worldPos;\n vec3 PL = normalize(PLU);\n vec3 PH = normalize(PL + V);\n float PNL = max(dot(N, PL), 0.001);\n float PNH = max(dot(N, PH), 0.0);\n float distSqr = dot(PLU, PLU);\n float litRadius = cc_sphereLitSizeRange[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_sphereLitSizeRange[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(roughness, PNH, PH, N);\n lighting += PNL * cc_sphereLitColor[i].rgb * cc_sphereLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n for (int i = 0; i < 2; i++) {\n vec3 SLU = cc_spotLitPos[i].xyz - worldPos;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_spotLitSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_spotLitSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float cosInner = max(dot(-cc_spotLitDir[i].xyz, SL), 0.01);\n float cosOuter = cc_spotLitSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n att *= GetAngleAtt(SL, -cc_spotLitDir[i].xyz, litAngleScale, litAngleOffset);\n vec3 lspec = specular * CalcSpecular(roughness, SNH, SH, N);\n lighting += SNL * cc_spotLitColor[i].rgb * cc_spotLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n return lighting;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n float roughness;\n float metallic;\n float occlusion;\n};\nvec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NV = max(abs(dot(N, V)), 0.001);\n float NL = max(dot(N, L), 0.001);\n float NH = max(dot(N, H), 0.0);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w * (diffuseContrib + specularContrib);\n finalColor += CalcDynamicLighting(s.position, N, V, diffuse, specular, s.roughness);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = textureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb) * cc_ambientSky.w;\n #endif\n finalColor += env * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n return vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = ACESToneMap(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nuniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScale;\n vec4 pbrParams;\n vec4 pbrScale;\n vec4 emissive;\n vec4 emissiveScale;\n};\nin vec3 v_position;\n#if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n in vec2 v_uv;\n#endif\nin vec3 v_normal;\n#if USE_NORMAL_MAP\n in vec3 v_tangent;\n in vec3 v_bitangent;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n vec4 texColor = texture(albedoMap, v_uv);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScale.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScale.w) discard;\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture(normalMap, v_uv).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrScale.w) * normalize(v_tangent) +\n (nmmp.y * pbrScale.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n pbr = texture(pbrMap, v_uv);\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture(metallicRoughnessMap, v_uv);\n pbr.METALLIC_CHANNEL = metallicRoughness.METALLIC_CHANNEL;\n pbr.ROUGHNESS_CHANNEL = metallicRoughness.ROUGHNESS_CHANNEL;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.OCCLUSION_CHANNEL = texture(occlusionMap, v_uv).OCCLUSION_CHANNEL;\n #endif\n pbr *= pbrScale;\n s.roughness = clamp(pbr.ROUGHNESS_CHANNEL, 0.04, 1.0);\n s.metallic = clamp(pbr.METALLIC_CHANNEL, 0.0, 0.96);\n s.occlusion = pbr.OCCLUSION_CHANNEL;\n s.emissive = emissive.rgb * emissiveScale.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture(emissiveMap, v_uv).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n return CCFragOutput(color);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` }, "glsl1": { "vert": `\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\nuniform highp mat4 cc_matWorlds[10];\nstruct StandardAttributes {\n vec4 position;\n vec3 normal;\n vec4 tangent;\n int index;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec4 a_tangent;\n#if USE_BATCHING\nattribute float a_index;\n#endif\nvoid CCDecode (out StandardAttributes attr) {\n attr.position = vec4(a_position, 1.0);\n attr.normal = a_normal;\n attr.tangent = a_tangent;\n#if USE_BATCHING\n attr.index = int(a_index + 0.5);\n#endif\n}\n#if CC_USE_SKINNING\nattribute vec4 a_weights;\nattribute vec4 a_joints;\nuniform highp vec4 cc_jointsTextureInfo;\nuniform highp vec4 cc_jointsAnimInfo;\nuniform sampler2D cc_jointsTexture;\n#if CC_USE_SKINNING == 1\n highp float decode32(highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - step(128.0, rgba[3]) * 2.0;\n highp float Exponent = 2.0 * mod(rgba[3], 128.0) + step(128.0, rgba[2]) - 127.0;\n highp float Mantissa = mod(rgba[2], 128.0) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n#endif\n#if CC_USE_SKINNING == 1\n void getJointDQ(float i, out vec4 Qr, out vec4 Qt, out vec3 S) {\n highp float j = 12.0 * (cc_jointsAnimInfo.x * i + cc_jointsAnimInfo.y) + cc_jointsTextureInfo.z;\n highp float invSize = cc_jointsTextureInfo.y;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointsTextureInfo.x;\n y = (y + 0.5) * invSize;\n Qr = vec4(\n decode32(texture2D(cc_jointsTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 3.5) * invSize, y)))\n );\n Qt = vec4(\n decode32(texture2D(cc_jointsTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 7.5) * invSize, y)))\n );\n S = vec3(\n decode32(texture2D(cc_jointsTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointsTexture, vec2((x + 10.5) * invSize, y)))\n );\n }\n#elif CC_USE_SKINNING == 2\n void getJointDQ(float i, out vec4 Qr, out vec4 Qt, out vec3 S) {\n highp float j = 3.0 * (cc_jointsAnimInfo.x * i + cc_jointsAnimInfo.y) + cc_jointsTextureInfo.z;\n highp float invSize = cc_jointsTextureInfo.y;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointsTextureInfo.x;\n y = (y + 0.5) * invSize;\n Qr = texture2D(cc_jointsTexture, vec2((x + 0.5) * invSize, y));\n Qt = texture2D(cc_jointsTexture, vec2((x + 1.5) * invSize, y));\n S = texture2D(cc_jointsTexture, vec2((x + 2.5) * invSize, y)).xyz;\n }\n#endif\nvoid skinRTS(out vec4 R, out vec3 T, out vec3 S) {\n vec4 r, t, Qt = vec4(0.0); vec3 s;\n R = vec4(0.0); S = vec3(0.0);\n for (int i = 0; i < 4; i++) {\n float w = a_weights[i];\n getJointDQ(a_joints[i], r, t, s);\n S += s * w; R += r * w; Qt += t * w;\n }\n float invNorm = 1.0 / length(R); R *= invNorm; Qt *= invNorm;\n T = 2.0 * (R.w * Qt.xyz - Qt.w * R.xyz + cross(R.xyz, Qt.xyz));\n}\nvec3 VectorTransformQuat(vec3 v, vec4 Q) {\n return v + 2.0 * cross(Q.xyz, cross(Q.xyz, v) + Q.w * v);\n}\nvoid CCSkin(inout vec4 position) {\n vec4 R; vec3 T, S;\n skinRTS(R, T, S);\n position.xyz = VectorTransformQuat(position.xyz * S, R) + T;\n}\nvoid CCSkin(inout StandardAttributes attr) {\n vec4 R; vec3 T, S;\n skinRTS(R, T, S);\n attr.position.xyz = VectorTransformQuat(attr.position.xyz * S, R) + T;\n attr.normal = VectorTransformQuat(attr.normal, R);\n attr.tangent.xyz = VectorTransformQuat(attr.tangent.xyz, R);\n}\n#endif\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n int index;\n};\nvoid CCAttrToInput (in StandardAttributes attr, out StandardVertInput In) {\n In.position = attr.position;\n In.normal = attr.normal;\n In.tangent = attr.tangent;\n In.index = attr.index;\n}\nvoid CCVertInput (out StandardVertInput In) {\n StandardAttributes attr;\n CCDecode(attr);\n #if CC_USE_SKINNING\n CCSkin(attr);\n #endif\n CCAttrToInput(attr, In);\n}\nuniform vec4 tilingOffset;\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvarying vec3 v_position;\nvarying vec3 v_normal;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\n#if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n attribute vec2 a_texCoord;\n varying vec2 v_uv;\n#endif\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n #if USE_BATCHING\n mat4 matWorld = cc_matWorlds[In.index];\n mat4 matWorldIT = transposeMat4(matWorld);\n #else\n mat4 matWorld = cc_matWorld;\n mat4 matWorldIT = cc_matWorldIT;\n #endif\n vec4 pos = matWorld * In.position;\n v_position = pos.xyz;\n v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n #if USE_NORMAL_MAP\n v_tangent = normalize((matWorldIT * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n #if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #endif\n return cc_matViewProj * pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\n#if CC_USE_IBL\n #ifdef GL_EXT_shader_texture_lod\n #extension GL_EXT_shader_texture_lod : enable\n #endif\n#endif\nprecision highp float;\nuniform vec4 cc_cameraPos;\nuniform vec4 cc_exposure;\nuniform vec4 cc_mainLitDir;\nuniform vec4 cc_mainLitColor;\nuniform vec4 cc_ambientSky;\nuniform vec4 cc_ambientGround;\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\n#endif\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nuniform highp vec4 cc_sphereLitPos[2];\nuniform vec4 cc_sphereLitSizeRange[2];\nuniform vec4 cc_sphereLitColor[2];\nuniform highp vec4 cc_spotLitPos[2];\nuniform vec4 cc_spotLitSizeRangeAngle[2];\nuniform vec4 cc_spotLitDir[2];\nuniform vec4 cc_spotLitColor[2];\nfloat SmoothDistAtt2(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float factor2 = factor * factor;\n float factor3 = factor2 * factor2;\n float smoothFactor = clamp(1.0 - factor3 * factor3, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat SmoothDistAtt(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt(float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt(vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GGXMobile(float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular(float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox(vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nvec3 CalcDynamicLighting(vec3 worldPos, vec3 N, vec3 V, vec3 diffuse, vec3 specular, float roughness) {\n vec3 lighting = vec3(0.0);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n for (int i = 0; i < 2; i++) {\n vec3 PLU = cc_sphereLitPos[i].xyz - worldPos;\n vec3 PL = normalize(PLU);\n vec3 PH = normalize(PL + V);\n float PNL = max(dot(N, PL), 0.001);\n float PNH = max(dot(N, PH), 0.0);\n float distSqr = dot(PLU, PLU);\n float litRadius = cc_sphereLitSizeRange[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_sphereLitSizeRange[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(roughness, PNH, PH, N);\n lighting += PNL * cc_sphereLitColor[i].rgb * cc_sphereLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n for (int i = 0; i < 2; i++) {\n vec3 SLU = cc_spotLitPos[i].xyz - worldPos;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_spotLitSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_spotLitSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float cosInner = max(dot(-cc_spotLitDir[i].xyz, SL), 0.01);\n float cosOuter = cc_spotLitSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n att *= GetAngleAtt(SL, -cc_spotLitDir[i].xyz, litAngleScale, litAngleOffset);\n vec3 lspec = specular * CalcSpecular(roughness, SNH, SH, N);\n lighting += SNL * cc_spotLitColor[i].rgb * cc_spotLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n return lighting;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n float roughness;\n float metallic;\n float occlusion;\n};\nvec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NV = max(abs(dot(N, V)), 0.001);\n float NL = max(dot(N, L), 0.001);\n float NH = max(dot(N, H), 0.0);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w * (diffuseContrib + specularContrib);\n finalColor += CalcDynamicLighting(s.position, N, V, diffuse, specular, s.roughness);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n #ifdef GL_EXT_shader_texture_lod\n vec4 envmap = textureCubeLodEXT(cc_environment, R, s.roughness * cc_ambientGround.w);\n #else\n vec4 envmap = textureCube(cc_environment, R);\n #endif\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb) * cc_ambientSky.w;\n #endif\n finalColor += env * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n return vec4(finalColor, s.albedo.a);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nuniform vec4 albedo;\nuniform vec4 albedoScale;\nuniform vec4 pbrParams;\nuniform vec4 pbrScale;\nuniform vec4 emissive;\nuniform vec4 emissiveScale;\nvarying vec3 v_position;\n#if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n varying vec2 v_uv;\n#endif\nvarying vec3 v_normal;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n vec4 texColor = texture2D(albedoMap, v_uv);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScale.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScale.w) discard;\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, v_uv).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrScale.w) * normalize(v_tangent) +\n (nmmp.y * pbrScale.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n pbr = texture2D(pbrMap, v_uv);\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessMap, v_uv);\n pbr.METALLIC_CHANNEL = metallicRoughness.METALLIC_CHANNEL;\n pbr.ROUGHNESS_CHANNEL = metallicRoughness.ROUGHNESS_CHANNEL;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.OCCLUSION_CHANNEL = texture2D(occlusionMap, v_uv).OCCLUSION_CHANNEL;\n #endif\n pbr *= pbrScale;\n s.roughness = clamp(pbr.ROUGHNESS_CHANNEL, 0.04, 1.0);\n s.metallic = clamp(pbr.METALLIC_CHANNEL, 0.0, 0.96);\n s.occlusion = pbr.OCCLUSION_CHANNEL;\n s.emissive = emissive.rgb * emissiveScale.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture2D(emissiveMap, v_uv).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }\n` + "frag": `\n#if CC_USE_IBL\n #ifdef GL_EXT_shader_texture_lod\n #extension GL_EXT_shader_texture_lod : enable\n #endif\n#endif\nprecision highp float;\nuniform vec4 cc_cameraPos;\nuniform vec4 cc_exposure;\nuniform vec4 cc_mainLitDir;\nuniform vec4 cc_mainLitColor;\nuniform vec4 cc_ambientSky;\nuniform vec4 cc_ambientGround;\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\n#endif\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nuniform highp vec4 cc_sphereLitPos[2];\nuniform vec4 cc_sphereLitSizeRange[2];\nuniform vec4 cc_sphereLitColor[2];\nuniform highp vec4 cc_spotLitPos[2];\nuniform vec4 cc_spotLitSizeRangeAngle[2];\nuniform vec4 cc_spotLitDir[2];\nuniform vec4 cc_spotLitColor[2];\nfloat SmoothDistAtt2(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float factor2 = factor * factor;\n float factor3 = factor2 * factor2;\n float smoothFactor = clamp(1.0 - factor3 * factor3, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat SmoothDistAtt(float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt(float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt(vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GGXMobile(float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular(float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox(vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nvec3 CalcDynamicLighting(vec3 worldPos, vec3 N, vec3 V, vec3 diffuse, vec3 specular, float roughness) {\n vec3 lighting = vec3(0.0);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n for (int i = 0; i < 2; i++) {\n vec3 PLU = cc_sphereLitPos[i].xyz - worldPos;\n vec3 PL = normalize(PLU);\n vec3 PH = normalize(PL + V);\n float PNL = max(dot(N, PL), 0.001);\n float PNH = max(dot(N, PH), 0.0);\n float distSqr = dot(PLU, PLU);\n float litRadius = cc_sphereLitSizeRange[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_sphereLitSizeRange[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(roughness, PNH, PH, N);\n lighting += PNL * cc_sphereLitColor[i].rgb * cc_sphereLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n for (int i = 0; i < 2; i++) {\n vec3 SLU = cc_spotLitPos[i].xyz - worldPos;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_spotLitSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_spotLitSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float cosInner = max(dot(-cc_spotLitDir[i].xyz, SL), 0.01);\n float cosOuter = cc_spotLitSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n att *= GetAngleAtt(SL, -cc_spotLitDir[i].xyz, litAngleScale, litAngleOffset);\n vec3 lspec = specular * CalcSpecular(roughness, SNH, SH, N);\n lighting += SNL * cc_spotLitColor[i].rgb * cc_spotLitColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n return lighting;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n float roughness;\n float metallic;\n float occlusion;\n};\nvec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NV = max(abs(dot(N, V)), 0.001);\n float NL = max(dot(N, L), 0.001);\n float NH = max(dot(N, H), 0.0);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w * (diffuseContrib + specularContrib);\n finalColor += CalcDynamicLighting(s.position, N, V, diffuse, specular, s.roughness);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n #ifdef GL_EXT_shader_texture_lod\n vec4 envmap = textureCubeLodEXT(cc_environment, R, s.roughness * cc_ambientGround.w);\n #else\n vec4 envmap = textureCube(cc_environment, R);\n #endif\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb) * cc_ambientSky.w;\n #endif\n finalColor += env * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n return vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = ACESToneMap(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nuniform vec4 albedo;\nuniform vec4 albedoScale;\nuniform vec4 pbrParams;\nuniform vec4 pbrScale;\nuniform vec4 emissive;\nuniform vec4 emissiveScale;\nvarying vec3 v_position;\n#if USE_ALBEDO_MAP || USE_NORMAL_MAP || USE_PBR_MAP || USE_EMISSIVE_MAP || USE_METALLIC_ROUGHNESS_MAP || USE_OCCLUSION_MAP\n varying vec2 v_uv;\n#endif\nvarying vec3 v_normal;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n vec4 texColor = texture2D(albedoMap, v_uv);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScale.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScale.w) discard;\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, v_uv).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrScale.w) * normalize(v_tangent) +\n (nmmp.y * pbrScale.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n pbr = texture2D(pbrMap, v_uv);\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessMap, v_uv);\n pbr.METALLIC_CHANNEL = metallicRoughness.METALLIC_CHANNEL;\n pbr.ROUGHNESS_CHANNEL = metallicRoughness.ROUGHNESS_CHANNEL;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.OCCLUSION_CHANNEL = texture2D(occlusionMap, v_uv).OCCLUSION_CHANNEL;\n #endif\n pbr *= pbrScale;\n s.roughness = clamp(pbr.ROUGHNESS_CHANNEL, 0.04, 1.0);\n s.metallic = clamp(pbr.METALLIC_CHANNEL, 0.0, 0.96);\n s.occlusion = pbr.OCCLUSION_CHANNEL;\n s.emissive = emissive.rgb * emissiveScale.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture2D(emissiveMap, v_uv).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }\n` }, "builtins": {"globals":{"blocks":[{"name":"CCGlobal", "defines":[]}], "samplers":[{"name":"cc_environment", "defines":["CC_USE_IBL"]}]}, "locals":{"blocks":[{"name":"CCLocal", "defines":[]}, {"name":"CCSkinningTexture", "defines":["CC_USE_SKINNING"]}, {"name":"CCSkinningAnimation", "defines":["CC_USE_SKINNING"]}, {"name":"CCForwardLight", "defines":[]}], "samplers":[{"name":"cc_jointsTexture", "defines":["CC_USE_SKINNING"]}]}}, "defines": [ @@ -365,14 +365,14 @@ export default [ "shaders": [ { "name": "pipeline/skybox|sky-vs:vert|sky-fs:frag", - "hash": 234120969, + "hash": 491422960, "glsl3": { "vert": `\nprecision mediump float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nin vec3 a_position;\nvoid CCDecode (out vec4 position) {\n position = vec4(a_position, 1.0);\n}\nout vec4 viewDir;\nhighp vec4 vert () {\n CCDecode(viewDir);\n mat4 matViewRotOnly = mat4(mat3(cc_matView));\n highp vec4 pos = matViewRotOnly * viewDir;\n highp vec2 f = cc_matProj[3][3] > 0.0 ? vec2(4.8, 2.4) : vec2(cc_matProj[1][1]);\n pos.xy *= vec2(cc_screenSize.y * cc_screenSize.z, 1.0) * f;\n pos.zw = vec2(-0.99999 * pos.z, -pos.z);\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision mediump float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nin vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb) * cc_ambientSky.w;\n #endif\n return CCFragOutput(vec4(c, 1.0));\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` + "frag": `\nprecision mediump float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = ACESToneMap(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nin vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb) * cc_ambientSky.w;\n #endif\n return CCFragOutput(vec4(c, 1.0));\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` }, "glsl1": { "vert": `\nprecision mediump float;\nuniform vec4 cc_screenSize;\nuniform mat4 cc_matView;\nuniform mat4 cc_matProj;\nattribute vec3 a_position;\nvoid CCDecode (out vec4 position) {\n position = vec4(a_position, 1.0);\n}\nvarying vec4 viewDir;\nhighp vec4 vert () {\n CCDecode(viewDir);\n mat4 matViewRotOnly = mat4(mat3(cc_matView));\n highp vec4 pos = matViewRotOnly * viewDir;\n highp vec2 f = cc_matProj[3][3] > 0.0 ? vec2(4.8, 2.4) : vec2(cc_matProj[1][1]);\n pos.xy *= vec2(cc_screenSize.y * cc_screenSize.z, 1.0) * f;\n pos.zw = vec2(-0.99999 * pos.z, -pos.z);\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision mediump float;\nuniform vec4 cc_ambientSky;\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nvarying vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(textureCube(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(textureCube(cc_environment, viewDir.xyz).rgb) * cc_ambientSky.w;\n #endif\n return CCFragOutput(vec4(c, 1.0));\n}\nvoid main() { gl_FragColor = frag(); }\n` + "frag": `\nprecision mediump float;\nuniform vec4 cc_ambientSky;\nuniform samplerCube cc_environment;\nvec3 unpackNormal(vec4 nmap) {\n return nmap.xyz * 2.0 - 1.0;\n}\nvec3 unpackRGBE(vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = ACESToneMap(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n}\nvarying vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(textureCube(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(textureCube(cc_environment, viewDir.xyz).rgb) * cc_ambientSky.w;\n #endif\n return CCFragOutput(vec4(c, 1.0));\n}\nvoid main() { gl_FragColor = frag(); }\n` }, "builtins": {"globals":{"blocks":[{"name":"CCGlobal", "defines":[]}], "samplers":[{"name":"cc_environment", "defines":[]}]}, "locals":{"blocks":[], "samplers":[]}}, "defines": [ @@ -393,7 +393,7 @@ export default [ "shaders": [ { "name": "pipeline/smaa|smaa-edge-vs:vert|smaa-edge-fs:frag", - "hash": 2142686600, + "hash": 2008336459, "glsl3": { "vert": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nout vec4 v_offsets[3];\nvec4 vert () {\n vec4 pos = vec4(a_position, 0.0, 1.0);\n v_uv = a_texCoord * cc_screenScale.xy;\n v_offsets[0] = v_uv.xyxy + cc_nativeSize.zwzw * vec4(-1.0, 0.0, 0.0, 1.0);\n v_offsets[1] = v_uv.xyxy + cc_nativeSize.zwzw * vec4( 1.0, 0.0, 0.0, -1.0);\n v_offsets[2] = v_uv.xyxy + cc_nativeSize.zwzw * vec4(-2.0, 0.0, 0.0, 2.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, "frag": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nin vec2 v_uv;\nin vec4 v_offsets[3];\nuniform sampler2D u_texSampler;\nvec3 ToLDR(vec3 color) {\n#if CC_USE_HDR\n color *= cc_exposure.x * 1024.0;\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#endif\n return color;\n}\nvec4 frag () {\n vec2 threshold = vec2(0.1, 0.1);\n vec4 delta;\n vec3 C = ToLDR(texture(u_texSampler, v_uv).rgb);\n vec3 Cleft = ToLDR(texture(u_texSampler, v_offsets[0].xy).rgb);\n vec3 t = abs(C - Cleft);\n delta.x = max(max(t.r, t.g), t.b);\n vec3 Ctop = ToLDR(texture(u_texSampler, v_offsets[0].zw).rgb);\n t = abs(C - Ctop);\n delta.y = max(max(t.r, t.g), t.b);\n vec2 edges = step(threshold, delta.xy);\n if (dot(edges, vec2(1.0, 1.0)) == 0.0)\n discard;\n vec3 Cright = ToLDR(texture(u_texSampler, v_offsets[1].xy).rgb);\n t = abs(C - Cright);\n delta.z = max(max(t.r, t.g), t.b);\n vec3 Cbottom = ToLDR(texture(u_texSampler, v_offsets[1].zw).rgb);\n t = abs(C - Cbottom);\n delta.w = max(max(t.r, t.g), t.b);\n float maxDelta = max(max(max(delta.x, delta.y), delta.z), delta.w);\n vec3 Cleftleft = ToLDR(texture(u_texSampler, v_offsets[2].xy).rgb);\n t = abs(C - Cleftleft);\n delta.z = max(max(t.r, t.g), t.b);\n vec3 Ctoptop = ToLDR(texture(u_texSampler, v_offsets[2].zw).rgb);\n t = abs(C - Ctoptop);\n delta.w = max(max(t.r, t.g), t.b);\n maxDelta = max(max(maxDelta, delta.z), delta.w);\n edges.xy *= step(0.5 * maxDelta, delta.xy);\n vec4 o = vec4(edges, 0.0, 0.0);\n return o;\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` @@ -441,7 +441,7 @@ export default [ "shaders": [ { "name": "pipeline/tonemap|tonemap-vs:vert|tonemap-fs:frag", - "hash": 1769238053, + "hash": 2708165168, "glsl3": { "vert": `\nprecision highp float;\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nout vec4 v_offset;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord * cc_screenScale.xy;\n v_offset = v_uv.xyxy + cc_nativeSize.zwzw * vec4(1.0, 0.0, 0.0, -1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, "frag": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n vec4 cc_screenSize;\n vec4 cc_screenScale;\n vec4 cc_nativeSize;\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_exposure;\n vec4 cc_mainLitDir;\n vec4 cc_mainLitColor;\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\n#define saturate(a) clamp( a, 0.0, 1.0 )\nhighp mat4 transposeMat4(in highp mat4 mat) {\n highp vec4 i0 = mat[0];\n highp vec4 i1 = mat[1];\n highp vec4 i2 = mat[2];\n highp vec4 i3 = mat[3];\n return mat4(vec4(i0.x, i1.x, i2.x, i3.x),\n vec4(i0.y, i1.y, i2.y, i3.y),\n vec4(i0.z, i1.z, i2.z, i3.z),\n vec4(i0.w, i1.w, i2.w, i3.w));\n}\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nin vec2 v_uv;\nin vec4 v_offset;\nuniform sampler2D u_texSampler;\nuniform sampler2D u_blendTexSampler;\nvec3 ToLDR(vec3 color) {\n #if CC_USE_HDR\n color *= cc_exposure.x * 1024.0;\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n #endif\n return color;\n}\nvec4 frag () {\n #if CC_USE_SMAA\n vec4 a;\n a.rb = texture(u_blendTexSampler, v_uv).rb;\n a.g = texture(u_blendTexSampler, v_offset.zw).g;\n a.a = texture(u_blendTexSampler, v_offset.xy).a;\n if (dot(a, vec4(1.0)) < 1e-5) {\n vec4 o = texture(u_texSampler, v_uv);\n o.rgb = ToLDR(o.rgb);\n return o;\n } else {\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b;\n offset.y = a.g > a.r ? -a.g : a.r;\n if (abs(offset.x) > abs(offset.y)) {\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n vec4 C = texture(u_texSampler, v_uv);\n C.rgb = ToLDR(C.rgb);\n vec2 uv = v_uv + sign(offset) * cc_nativeSize.zw;\n vec4 Cop = texture(u_texSampler, uv);\n Cop.rgb = ToLDR(Cop.rgb);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n C.rgb = pow(C.rgb, vec3(2.2));\n Cop.rgb = pow(Cop.rgb, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.rgb = pow(mixed.rgb, vec3(1.0 / 2.2));\n return mixed;\n }\n #else\n vec4 o = texture(u_texSampler, v_uv);\n o.rgb = ToLDR(o.rgb);\n return o;\n #endif\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` @@ -466,7 +466,7 @@ export default [ { "name": "util/profiler", "techniques": [ - {"passes":[{"blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "program":"util/profiler|profiler-vs:vert|profiler-fs:frag", "depthStencilState":{"depthTest":true, "depthWrite":false}, "properties":{"mainTexture":{"value":"grey", "type":28}, "offset":{"type":16}}}]} + {"passes":[{"blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "rasterizerState":{"cullMode":0}, "program":"util/profiler|profiler-vs:vert|profiler-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"mainTexture":{"value":"grey", "type":28}, "offset":{"type":16}}}]} ], "shaders": [ { diff --git a/cocos/core/pipeline/forward/forward-pipeline.ts b/cocos/core/pipeline/forward/forward-pipeline.ts index f1f2cb4b34..74ccdf2687 100644 --- a/cocos/core/pipeline/forward/forward-pipeline.ts +++ b/cocos/core/pipeline/forward/forward-pipeline.ts @@ -228,7 +228,6 @@ export class ForwardPipeline extends RenderPipeline { _vec4Array[1] *= tempRGB.y; _vec4Array[2] *= tempRGB.z; } - _vec4Array[3] = sphereLit.luminance * this._lightMeterScale; if (this._isHDR) { _vec4Array[3] = sphereLit.luminance * this._fpScale * this._lightMeterScale; } else { diff --git a/cocos/core/pipeline/forward/forward-stage.ts b/cocos/core/pipeline/forward/forward-stage.ts index af34fed9fa..9b53170cf0 100644 --- a/cocos/core/pipeline/forward/forward-stage.ts +++ b/cocos/core/pipeline/forward/forward-stage.ts @@ -11,6 +11,7 @@ import { RenderFlow } from '../render-flow'; import { opaqueCompareFn, RenderQueue, transparentCompareFn } from '../render-queue'; import { IRenderStageInfo, RenderStage } from '../render-stage'; import { RenderView } from '../render-view'; +import { Layers } from '../../scene-graph'; const colors: IGFXColor[] = []; const bufs: GFXCommandBuffer[] = []; @@ -211,7 +212,9 @@ export class ForwardStage extends RenderStage { this._opaqueBatchedQueue.recordCommandBuffer(cmdBuff); - cmdBuff.execute(planarShadow.cmdBuffs.array, planarShadow.cmdBuffCount); + if (camera.visibility & Layers.BitMask.DEFAULT) { + cmdBuff.execute(planarShadow.cmdBuffs.array, planarShadow.cmdBuffCount); + } cmdBuff.execute(this._transparentQueue.cmdBuffs.array, this._transparentQueue.cmdBuffCount); cmdBuff.endRenderPass(); diff --git a/cocos/core/pipeline/render-pipeline.ts b/cocos/core/pipeline/render-pipeline.ts index f5687cc035..1677d84c59 100644 --- a/cocos/core/pipeline/render-pipeline.ts +++ b/cocos/core/pipeline/render-pipeline.ts @@ -4,18 +4,8 @@ import { intersect } from '../geom-utils'; import { GFXBuffer } from '../gfx/buffer'; -import { - GFXBindingType, - GFXBufferUsageBit, - GFXFormat, - GFXFormatInfos, - GFXLoadOp, - GFXMemoryUsageBit, - GFXStoreOp, - GFXTextureLayout, - GFXTextureType, - GFXTextureUsageBit, - GFXTextureViewType} from '../gfx/define'; +import { GFXBindingType, GFXBufferUsageBit, GFXFormat, GFXFormatInfos, GFXLoadOp, GFXMemoryUsageBit, + GFXStoreOp, GFXTextureLayout, GFXTextureType, GFXTextureUsageBit, GFXTextureViewType } from '../gfx/define'; import { GFXDevice, GFXFeature } from '../gfx/device'; import { GFXFramebuffer } from '../gfx/framebuffer'; import { GFXInputAssembler, IGFXAttribute } from '../gfx/input-assembler'; @@ -35,7 +25,6 @@ import { IRenderFlowInfo, RenderFlow } from './render-flow'; import { RenderView } from './render-view'; const _vec4Array = new Float32Array(4); -const _outMat = new Mat4(); const _v3tmp = new Vec3(); const _v4Zero = new Vec4(0.0, 0.0, 0.0, 0.0); diff --git a/cocos/core/renderer/scene/camera.ts b/cocos/core/renderer/scene/camera.ts index 41015f7f64..efedaceaea 100644 --- a/cocos/core/renderer/scene/camera.ts +++ b/cocos/core/renderer/scene/camera.ts @@ -2,10 +2,10 @@ import { frustum, ray } from '../../geom-utils'; import { GFXClearFlag, IGFXColor } from '../../gfx/define'; import { GFXWindow } from '../../gfx/window'; import { lerp, Mat4, Rect, toRadian, Vec3 } from '../../math'; +import { CameraDefaultMask } from '../../pipeline/define'; import { RenderView } from '../../pipeline/render-view'; import { INode } from '../../utils/interfaces'; import { RenderScene } from './render-scene'; -import { CameraDefaultMask } from '../../pipeline/define'; export enum CameraProjection { ORTHO, @@ -62,7 +62,7 @@ export enum CameraShutter { } 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 SHUTERS: 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, +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]; @@ -134,7 +134,7 @@ export class Camera { this._priority = info.priority || 0; this._apertureValue = FSTOPS[this._aperture]; - this._shutterValue = SHUTERS[this._shutter]; + this._shutterValue = SHUTTERS[this._shutter]; this._isoValue = ISOS[this._iso]; this.updateExposure(); @@ -441,7 +441,7 @@ export class Camera { set shutter (val: CameraShutter) { this._shutter = val; - this._shutterValue = SHUTERS[this._shutter]; + this._shutterValue = SHUTTERS[this._shutter]; this.updateExposure(); } diff --git a/cocos/core/renderer/scene/planar-shadows.ts b/cocos/core/renderer/scene/planar-shadows.ts index 7fdaa57e05..4e0a7715a2 100644 --- a/cocos/core/renderer/scene/planar-shadows.ts +++ b/cocos/core/renderer/scene/planar-shadows.ts @@ -1,7 +1,7 @@ import { EffectAsset } from '../../assets/effect-asset'; import { GFXCommandBuffer } from '../../gfx/command-buffer'; -import { GFXCommandBufferType } from '../../gfx/define'; +import { GFXCommandBufferType, GFXStatus } from '../../gfx/define'; import { GFXInputAssembler } from '../../gfx/input-assembler'; import { GFXPipelineState } from '../../gfx/pipeline-state'; import { Color, Mat4, Quat, Vec3 } from '../../math'; @@ -155,15 +155,15 @@ export class PlanarShadows { if (!this._scene.mainLight.enabled) { return; } for (const model of this._scene.models) { if (!model.enabled || !model.node || !model.castShadow) { continue; } - let pso = this._psoRecord.get(model); - if (!pso) { pso = this._createPSO(model); this._psoRecord.set(model, pso); } + let pso = this._psoRecord.get(model); let newOne = false; + if (!pso) { pso = this._createPSO(model); this._psoRecord.set(model, pso); newOne = true; } if (!model.UBOUpdated) { model.updateUBOs(); } // for those outside the frustum for (let i = 0; i < model.subModelNum; i++) { const ia = model.getSubModel(i).inputAssembler; if (!ia) { continue; } let cb = this._cbRecord.get(ia); - if (!cb) { - cb = this._createCommandBuffer(); + if (newOne || !cb) { + cb = this._createOrReuseCommandBuffer(cb); cb.begin(); cb.bindPipelineState(pso); cb.bindBindingLayout(pso.pipelineLayout.layouts[0]); @@ -177,6 +177,17 @@ export class PlanarShadows { } } + public destroyShadowModel (model: Model) { + const pso = this._psoRecord.get(model); + if (pso) { this._destroyPSO(model, pso); this._psoRecord.delete(model); } + for (let i = 0; i < model.subModelNum; i++) { + const ia = model.getSubModel(i).inputAssembler; + const cb = this._cbRecord.get(ia!); + if (!ia || !cb) { continue; } + cb.destroy(); this._cbRecord.delete(ia); + } + } + public onPipelineChange () { const cbs = this._cbRecord.values(); let cbRes = cbs.next(); @@ -188,8 +199,7 @@ export class PlanarShadows { const models = this._psoRecord.keys(); let modelRes = models.next(); while (!modelRes.done) { - const pass = modelRes.value instanceof SkinningModel ? this._passSkinning : this._passNormal; - pass.destroyPipelineState(this._psoRecord.get(modelRes.value)!); + this._destroyPSO(modelRes.value, this._psoRecord.get(modelRes.value)!); modelRes = models.next(); } this._psoRecord.clear(); @@ -209,11 +219,23 @@ export class PlanarShadows { return pso; } - protected _createCommandBuffer () { + protected _destroyPSO (model: Model, pso: GFXPipelineState) { + const pass = model instanceof SkinningModel ? this._passSkinning : this._passNormal; + return pass.destroyPipelineState(pso); + } + + protected _createOrReuseCommandBuffer (cb?: GFXCommandBuffer) { const device = this._scene.root.device; - return device.createCommandBuffer({ + const info = { allocator: device.commandAllocator, type: GFXCommandBufferType.SECONDARY, - }); + }; + if (cb) { + if (cb.status === GFXStatus.SUCCESS) { cb.destroy(); } + cb.initialize(info); + } else { + cb = device.createCommandBuffer(info); + } + return cb; } } diff --git a/cocos/core/renderer/scene/render-scene.ts b/cocos/core/renderer/scene/render-scene.ts index 46594a3f87..faf3188f81 100644 --- a/cocos/core/renderer/scene/render-scene.ts +++ b/cocos/core/renderer/scene/render-scene.ts @@ -100,7 +100,7 @@ export class RenderScene { /** * @zh - * 获取 raycastAll 后的检测结果 + * 获取 raycastAll 后的检测结果 */ get rayResultAll () { return resultAll; @@ -230,6 +230,7 @@ export class RenderScene { public destroyModel (model: Model) { for (let i = 0; i < this._models.length; ++i) { if (this._models[i] === model) { + this._planarShadows.destroyShadowModel(model); this._models.splice(i, 1)[0].destroy(); return; } @@ -238,6 +239,7 @@ export class RenderScene { public destroyModels () { for (const m of this._models) { + this._planarShadows.destroyShadowModel(m); m.destroy(); } this._models = []; @@ -260,7 +262,7 @@ export class RenderScene { * Cast a ray into the scene, record all the intersected models and ui2d nodes in the result array * @param worldRay the testing ray * @param mask the layer mask to filter the models - * @param distance the max distance , Infinity by default + * @param distance the max distance , Infinity by default * @returns boolean , ray is hit or not * @note getter of this.rayResultAll can get recently result * @zh @@ -285,7 +287,7 @@ export class RenderScene { /** * @en - * Cast a ray into the scene, record all the intersected models in the result array + * Cast a ray into the scene, record all the intersected models in the result array * @param worldRay the testing ray * @param mask the layer mask to filter the models * @param distance the max distance , Infinity by default @@ -347,7 +349,7 @@ export class RenderScene { */ public raycastSingleModel (worldRay: ray, model: Model, mask = Layers.Enum.DEFAULT, distance = Infinity): boolean { if (CC_PREVIEW) { - if (model == null) console.error(" 检测前请保证 model 不为 null "); + if (model == null) { console.error(' 检测前请保证 model 不为 null '); } } pool.reset(); const m = model; @@ -410,7 +412,7 @@ export class RenderScene { private _raycastUI2DNode (worldRay: ray, ui2dNode: INode, mask = Layers.Enum.UI_2D, distance = Infinity) { if (CC_PREVIEW) { - if (ui2dNode == null) console.error(" 检测前请保证 uiNode 不为 null "); + if (ui2dNode == null) { console.error('make sure UINode is not null'); } } const uiTransfrom = ui2dNode.uiTransfromComp; if (uiTransfrom == null || ui2dNode.layer & Layers.Enum.IGNORE_RAYCAST || !(ui2dNode.layer & mask)) { return; } diff --git a/cocos/core/utils/profiler/profiler.ts b/cocos/core/utils/profiler/profiler.ts index 051ffc53f2..9c447d494d 100644 --- a/cocos/core/utils/profiler/profiler.ts +++ b/cocos/core/utils/profiler/profiler.ts @@ -225,8 +225,8 @@ export class Profiler { camera.far = 0; camera.orthoHeight = this._device!.height; camera.visibility = Layers.BitMask.PROFILER; - camera.clearFlags = GFXClearFlag.DEPTH | GFXClearFlag.STENCIL; - camera.priority = 1073741928; + camera.clearFlags = GFXClearFlag.NONE; + camera.priority = 0xffffffff; // after everything else const managerNode = new Node('Profiler_Root'); managerNode.parent = this._rootNode; diff --git a/cocos/ui/components/ui-model-component.ts b/cocos/ui/components/ui-model-component.ts index a031887649..77fb9f59aa 100644 --- a/cocos/ui/components/ui-model-component.ts +++ b/cocos/ui/components/ui-model-component.ts @@ -28,13 +28,13 @@ * @category ui */ +import { RenderableComponent } from '../../core/3d/framework/renderable-component'; +import { Material } from '../../core/assets'; +import { UIComponent } from '../../core/components/ui-base/ui-component'; import { ccclass, executionOrder, menu } from '../../core/data/class-decorator'; +import { director } from '../../core/director'; import { RenderPriority } from '../../core/pipeline/define'; import { UI } from '../../core/renderer/ui/ui'; -import { Material } from '../../core/assets'; -import { RenderableComponent } from '../../core/3d/framework/renderable-component'; -import { UIComponent } from '../../core/components/ui-base/ui-component'; -import { director } from '../../core/director'; /** * @zh @@ -54,8 +54,8 @@ export class UIModelComponent extends UIComponent { public onLoad () { this._modelComponent = this.getComponent('cc.RenderableComponent') as RenderableComponent; - if (!this._modelComponent){ - console.warn(`Use this component on a node(${this.node && this.node.name}) that has a model component`); + if (!this._modelComponent) { + console.warn(`node '${this.node && this.node.name}' doesn't have any renderable component`); return; } @@ -65,7 +65,7 @@ export class UIModelComponent extends UIComponent { public onDestroy () { this._modelComponent = this.getComponent('cc.RenderableComponent') as RenderableComponent; - if (!this._modelComponent){ + if (!this._modelComponent) { return; } From e5a9a3a187d2330f934744ca03794d2524cdb6ba Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 21 Oct 2019 11:10:23 +0800 Subject: [PATCH 15/33] More strict check during parent changing (#5569) --- cocos/core/scene-graph/base-node.ts | 40 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/cocos/core/scene-graph/base-node.ts b/cocos/core/scene-graph/base-node.ts index 08d94d8508..f13c7a759b 100644 --- a/cocos/core/scene-graph/base-node.ts +++ b/cocos/core/scene-graph/base-node.ts @@ -37,6 +37,7 @@ import { IBaseNode } from '../utils/interfaces'; import * as js from '../utils/js'; import { baseNodePolyfill } from './base-node-dev'; import { Scene } from './scene'; +import { errorID, warnID } from '../platform/debug'; /** * @@ -49,6 +50,9 @@ const Destroying = CCObject.Flags.Destroying; const DontDestroy = CCObject.Flags.DontDestroy; // @ts-ignore const Deactivating = CCObject.Flags.Deactivating; +// @ts-ignore +const Activating = CCObject.Flags.Activating; +const ChangingState = Activating | Deactivating; // const CHILD_ADDED = 'child-added'; // const CHILD_REMOVED = 'child-removed'; @@ -59,7 +63,7 @@ const NullScene = null as unknown as Scene; function getConstructor (typeOrClassName: string | Function): Function | null { if (!typeOrClassName) { - cc.errorID(3804); + errorID(3804); return null; } if (typeof typeOrClassName === 'string') { @@ -135,7 +139,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { } set name (value) { if (CC_DEV && value.indexOf('/') !== -1) { - cc.errorID(1632); + errorID(1632); return; } this._name = value; @@ -415,8 +419,10 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { return; } const oldParent = this._parent; - if (CC_DEBUG && oldParent && (oldParent._objFlags & Deactivating)) { - cc.errorID(3821); + if (CC_DEBUG && oldParent && + // Change parent when old parent desactivating or activating + (oldParent._objFlags & ChangingState)) { + errorID(3821); } this._parent = value; @@ -431,7 +437,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { if (value) { if (CC_DEBUG && (value._objFlags & Deactivating)) { - cc.errorID(3821); + errorID(3821); } value._children.push(this); this._siblingIndex = value._children.length - 1; @@ -443,7 +449,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { if (!(oldParent._objFlags & Destroying)) { const removeAt = oldParent._children.indexOf(this); if (CC_DEV && removeAt < 0) { - return cc.errorID(1633); + return errorID(1633); } oldParent._children.splice(removeAt, 1); oldParent._updateSiblingIndex(); @@ -560,7 +566,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { public addChild (child: this): void { if (CC_DEV && !(child instanceof cc._BaseNode)) { - return cc.errorID(1634, cc.js.getClassName(child)); + return errorID(1634, cc.js.getClassName(child)); } cc.assertID(child, 1606); cc.assertID(child._parent === null, 1605); @@ -616,7 +622,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { return; } if (this._parent._objFlags & Deactivating) { - cc.errorID(3821); + errorID(3821); return; } const siblings = this._parent._children; @@ -982,15 +988,15 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { if (typeof typeOrClassName === 'string') { constructor = js.getClassByName(typeOrClassName); if (!constructor) { - cc.errorID(3807, typeOrClassName); + errorID(3807, typeOrClassName); if (cc._RF.peek()) { - cc.errorID(3808, typeOrClassName); + errorID(3808, typeOrClassName); } return null; } } else { if (!typeOrClassName) { - cc.errorID(3804); + errorID(3804); return null; } constructor = typeOrClassName; @@ -999,11 +1005,11 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { // check component if (typeof constructor !== 'function') { - cc.errorID(3809); + errorID(3809); return null; } if (!js.isChildClassOf(constructor, cc.Component)) { - cc.errorID(3810); + errorID(3810); return null; } @@ -1082,7 +1088,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { public removeComponent (component: any) { if (!component) { - cc.errorID(3813); + errorID(3813); return; } let componentInstance: Component | null = null; @@ -1133,7 +1139,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { // Do remove component, only used internally. public _removeComponent (component: Component) { if (!component) { - cc.errorID(3814); + errorID(3814); return; } @@ -1147,7 +1153,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { } // @ts-ignore else if (component.node !== this) { - cc.errorID(3815); + errorID(3815); } } } @@ -1221,7 +1227,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { if (this._persistNode && !(newParent instanceof cc.Scene)) { cc.game.removePersistRootNode(this); if (CC_EDITOR) { - cc.warnID(1623); + warnID(1623); } } From f3b1010a73f8adcba96277fa049c02b7b636c343 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Mon, 21 Oct 2019 11:13:41 +0800 Subject: [PATCH 16/33] skeletal sockets: don't change node transform unless necessary (#5570) --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- cocos/core/animation/skeletal-animation-component.ts | 2 +- cocos/core/math/mat4.ts | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0f7b215960..35e6c25f9f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -Re: cocos-creator/fireball# +Re: cocos-creator/3d-tasks# Changelog: * @@ -13,4 +13,4 @@ Changelog: - [ ] Document new code with comments in source code based on [API Docs](https://github.com/cocos-creator/fireball#api-docs) - [ ] Make sure any runtime log information in `cc.log` , `cc.error` or `new Error('')` has been moved into `DebugInfos.js` with an ID, and use `cc.logID(id)` or `new Error(cc._getErrorID(id))` instead. ---> \ No newline at end of file +--> diff --git a/cocos/core/animation/skeletal-animation-component.ts b/cocos/core/animation/skeletal-animation-component.ts index 833e381cf3..19281abcb7 100644 --- a/cocos/core/animation/skeletal-animation-component.ts +++ b/cocos/core/animation/skeletal-animation-component.ts @@ -138,7 +138,7 @@ export class SkeletalAnimationComponent extends AnimationComponent { target.name = `${socket.path.substring(socket.path.lastIndexOf('/') + 1)} Socket`; target.parent = this.node; getWorldTransformUntilRoot(joint, this.node, m4_1); - target.matrix = m4_1; + if (!Mat4.equals(target.matrix, m4_1)) { target.matrix = m4_1; } } } for (const stateName of Object.keys(this._nameToState)) { diff --git a/cocos/core/math/mat4.ts b/cocos/core/math/mat4.ts index f0a06f54bf..79091d03a9 100644 --- a/cocos/core/math/mat4.ts +++ b/cocos/core/math/mat4.ts @@ -1314,7 +1314,8 @@ export class Mat4 extends ValueType { * @zh 排除浮点数误差的矩阵近似等价判断 */ public static equals (a: Out, b: Out, epsilon = EPSILON) { - + // TAOCP vol.2, 3rd ed., s.4.2.4, p.213-225 + // defines a 'close enough' relationship between u and v that scales for magnitude return ( Math.abs(a.m00 - b.m00) <= epsilon * Math.max(1.0, Math.abs(a.m00), Math.abs(b.m00)) && Math.abs(a.m01 - b.m01) <= epsilon * Math.max(1.0, Math.abs(a.m01), Math.abs(b.m01)) && From 1a6c27654cb31451f0a48b7139609d99051c1485 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Mon, 21 Oct 2019 11:46:21 +0800 Subject: [PATCH 17/33] fix sockets cond (#5571) --- cocos/core/animation/skeletal-animation-component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/core/animation/skeletal-animation-component.ts b/cocos/core/animation/skeletal-animation-component.ts index 19281abcb7..5f5f3ef89e 100644 --- a/cocos/core/animation/skeletal-animation-component.ts +++ b/cocos/core/animation/skeletal-animation-component.ts @@ -51,6 +51,7 @@ export class Socket { } const m4_1 = new Mat4(); +const m4_2 = new Mat4(); function collectRecursively (node: INode, prefix = '', out: string[] = []) { for (let i = 0; i < node.children.length; i++) { @@ -138,7 +139,8 @@ export class SkeletalAnimationComponent extends AnimationComponent { target.name = `${socket.path.substring(socket.path.lastIndexOf('/') + 1)} Socket`; target.parent = this.node; getWorldTransformUntilRoot(joint, this.node, m4_1); - if (!Mat4.equals(target.matrix, m4_1)) { target.matrix = m4_1; } + Mat4.fromRTS(m4_2, target.rotation, target.position, target.scale); + if (!Mat4.equals(m4_2, m4_1)) { target.matrix = m4_1; } } } for (const stateName of Object.keys(this._nameToState)) { From 3e28aeb310b7fbed349e6b9578efa8b63a808744 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Mon, 21 Oct 2019 12:00:45 +0800 Subject: [PATCH 18/33] - update cannon version to cc1.0.2 (#5545) - emit events after transform sync in cannon physics --- cocos/physics/cannon/cannon-world.ts | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos/physics/cannon/cannon-world.ts b/cocos/physics/cannon/cannon-world.ts index 9e70079afd..1c94e8188d 100644 --- a/cocos/physics/cannon/cannon-world.ts +++ b/cocos/physics/cannon/cannon-world.ts @@ -62,6 +62,8 @@ export class CannonWorld implements PhysicsWorldBase { this._callCustomBeforeSteps(); this._world.step(deltaTime, time, maxSubStep); this._callCustomAfterSteps(); + this._world.emitTriggeredEvents(); + this._world.emitCollisionEvents(); } public addBeforeStep (cb: BeforeStepCallback) { diff --git a/package-lock.json b/package-lock.json index 92d2ab0ae7..901121e172 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3117,8 +3117,8 @@ "dev": true }, "cannon": { - "version": "github:cocos-creator/cannon.js#b4461faffe280150a9990f66a0a592c2b06adff4", - "from": "github:cocos-creator/cannon.js#cc1.0.1", + "version": "github:cocos-creator/cannon.js#dc9fe79b300839ee20c1f5ee4c608a81630f82e4", + "from": "github:cocos-creator/cannon.js#cc1.0.2", "dev": true }, "capture-exit": { diff --git a/package.json b/package.json index 298df73099..27a1918689 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "babel-preset-env": "^1.2.2", "babelify": "7.3.0", "browserify": "^16.2.3", - "cannon": "github:cocos-creator/cannon.js#cc1.0.1", + "cannon": "github:cocos-creator/cannon.js#cc1.0.2", "chalk": "1.1.0", "commander": "^2.20.0", "dat.gui": "^0.7.5", From 300609e748644be4d7fa285de3e0f28eab649757 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Mon, 21 Oct 2019 15:25:46 +0800 Subject: [PATCH 19/33] impl physics raycast (#5403) * impl physics raycast * - remove raycastAny - rename raycastAll to raycast - rename raycastAllResults to raycastResults --- cocos/core/geom-utils/ray.ts | 8 ++- cocos/physics/api.ts | 21 +++--- cocos/physics/cannon/cannon-util.ts | 43 +++-------- cocos/physics/cannon/cannon-world.ts | 45 +++++++----- cocos/physics/cocos/builtin-body.ts | 30 ++++---- cocos/physics/cocos/builtin-world.ts | 79 ++++++++++++++++----- cocos/physics/cocos/shapes/builtin-shape.ts | 11 +-- cocos/physics/components/physics-system.ts | 67 +++++++++++++++-- cocos/physics/instance.ts | 6 +- cocos/physics/physics-ray-result.ts | 64 +++++++++++++++++ cocos/physics/raycast-result.ts | 38 ---------- exports/physics-framework.ts | 7 +- 12 files changed, 271 insertions(+), 148 deletions(-) create mode 100644 cocos/physics/physics-ray-result.ts delete mode 100644 cocos/physics/raycast-result.ts diff --git a/cocos/core/geom-utils/ray.ts b/cocos/core/geom-utils/ray.ts index 133d67bf71..06ee594091 100644 --- a/cocos/core/geom-utils/ray.ts +++ b/cocos/core/geom-utils/ray.ts @@ -4,6 +4,7 @@ import { Vec3 } from '../math'; import enums from './enums'; +import { IVec3Like } from '../math/type-define'; /** * @zh @@ -125,9 +126,14 @@ export default class ray { * @param {number} dz 方向的 z 部分。 */ constructor (ox: number = 0, oy: number = 0, oz: number = 0, - dx: number = 0, dy: number = 0, dz: number = -1) { + dx: number = 0, dy: number = 0, dz: number = -1) { this._type = enums.SHAPE_RAY; this.o = new Vec3(ox, oy, oz); this.d = new Vec3(dx, dy, dz); } + + public computeHit (out: IVec3Like, distance: number) { + Vec3.normalize(out, this.d) + Vec3.scaleAndAdd(out, this.o, out, distance); + } } diff --git a/cocos/physics/api.ts b/cocos/physics/api.ts index 8777f81b83..9343d367cb 100644 --- a/cocos/physics/api.ts +++ b/cocos/physics/api.ts @@ -4,15 +4,18 @@ import { Mat4, Quat, Vec3 } from '../core/math'; import { ERigidBodyType } from './physic-enum'; -import { RaycastResult } from './raycast-result'; +import { PhysicsRayResult } from './physics-ray-result'; +import { ray } from '../core/geom-utils'; +import { RecyclePool } from '../core'; // tslint:disable:interface-name // tslint:disable:no-empty-interface export interface IRaycastOptions { - collisionFilterMask?: number; - collisionFilterGroup?: number; - queryTriggerInteraction?: boolean; + mask: number; + group: number; + queryTrigger: boolean; + maxDistance: number; } export interface ICreateBodyOptions { @@ -64,19 +67,13 @@ export interface BuiltInWorldBase { * Ray cast, and return information of the closest hit. * @return True if any body was hit. */ - raycastClosest (from: Vec3, to: Vec3, options: IRaycastOptions, result: RaycastResult): boolean; - - /** - * Ray cast, and stop at the first result. Note that the order is random - but the method is fast. - * @return True if any body was hit. - */ - raycastAny (from: Vec3, to: Vec3, options: IRaycastOptions, result: RaycastResult): boolean; + raycastClosest (worldRay: ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; /** * Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. * @return True if any body was hit. */ - raycastAll (from: Vec3, to: Vec3, options: IRaycastOptions, callback: (result: RaycastResult) => void): boolean; + raycast (worldRay: ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean } export interface PhysicsWorldBase extends BuiltInWorldBase { diff --git a/cocos/physics/cannon/cannon-util.ts b/cocos/physics/cannon/cannon-util.ts index f31776f7a5..db7382b74c 100644 --- a/cocos/physics/cannon/cannon-util.ts +++ b/cocos/physics/cannon/cannon-util.ts @@ -1,42 +1,21 @@ import CANNON from 'cannon'; -import { IRaycastOptions, RigidBodyBase, ShapeBase } from '../api'; -import { RaycastResult } from '../raycast-result'; +import { IRaycastOptions, ShapeBase } from '../api'; +import { PhysicsRayResult } from '../physics-ray-result'; import { getWrap } from '../util'; +import { Vec3 } from '../../core'; -interface ICANNONRaycastOptions { - collisionFilterMask?: number; - collisionFilterGroup?: number; - checkCollisionResponse?: boolean; - skipBackfaces?: boolean; +export function toCannonRaycastOptions (out: CANNON.IRaycastOptions, options: IRaycastOptions) { + out.checkCollisionResponse = !options.queryTrigger; + // out.collisionFilterGroup = options.group; + // out.collisionFilterMask = options.mask; + out.skipBackFaces = false; } -export function toCannonRaycastOptions (options: IRaycastOptions): ICANNONRaycastOptions { - return toCannonOptions(options, { - queryTriggerInteraction: 'checkCollisionResponse', - }); -} - -export function toCannonOptions (options: any, optionsRename?: { [x: string]: string }) { - const result = {}; - for (const key of Object.keys(options)) { - let destKey = key; - if (optionsRename) { - const rename = optionsRename[key]; - if (rename) { - destKey = rename; - } - } - result[destKey] = options[key]; - } - return result as T; -} - -export function fillRaycastResult (result: RaycastResult, cannonResult: CANNON.RaycastResult) { +export function fillRaycastResult (result: PhysicsRayResult, cannonResult: CANNON.RaycastResult) { result._assign( - cannonResult.hitPointWorld, + Vec3.copy(new Vec3(), cannonResult.hitPointWorld), cannonResult.distance, - getWrap(cannonResult.shape), - getWrap(cannonResult.body), + getWrap(cannonResult.shape) ); } diff --git a/cocos/physics/cannon/cannon-world.ts b/cocos/physics/cannon/cannon-world.ts index 1c94e8188d..aa7ea49b1b 100644 --- a/cocos/physics/cannon/cannon-world.ts +++ b/cocos/physics/cannon/cannon-world.ts @@ -1,12 +1,14 @@ import CANNON from 'cannon'; import { Vec3 } from '../../core/math'; -import { RaycastResult } from '../raycast-result'; +import { PhysicsRayResult } from '../physics-ray-result'; import { setWrap } from '../util'; import { AfterStepCallback, BeforeStepCallback, IRaycastOptions, PhysicsWorldBase } from './../api'; import { fillRaycastResult, toCannonRaycastOptions } from './cannon-util'; import { CannonConstraint } from './constraint/cannon-constraint'; import { CannonShape } from './shapes/cannon-shape'; import { PhysicMaterial } from '../assets/physic-material'; +import { ray } from '../../core/geom-utils'; +import { RecyclePool } from '../../core'; export class CannonWorld implements PhysicsWorldBase { @@ -90,28 +92,25 @@ export class CannonWorld implements PhysicsWorldBase { this._customAfterStepListener.splice(i, 1); } - public raycastClosest (from: Vec3, to: Vec3, options: IRaycastOptions, result: RaycastResult): boolean { - const hit = (this._world as any).raycastClosest(from, to, toCannonRaycastOptions(options), this._raycastResult); + public raycastClosest (worldRay: ray, options: IRaycastOptions, result: PhysicsRayResult): boolean { + setupFromAndTo(worldRay, options.maxDistance); + toCannonRaycastOptions(raycastOpt, options); + const hit = this._world.raycastClosest(from, to, raycastOpt, this._raycastResult); if (hit) { fillRaycastResult(result, this._raycastResult); } return hit; } - public raycastAny (from: Vec3, to: Vec3, options: IRaycastOptions, result: RaycastResult): boolean { - const hit = (this._world as any).raycastAny(from, to, toCannonRaycastOptions(options), this._raycastResult); - if (hit) { - fillRaycastResult(result, this._raycastResult); - } - return hit; - } - - public raycastAll (from: Vec3, to: Vec3, options: IRaycastOptions, callback: (result: RaycastResult) => void): boolean { - return (this._world as any).raycastAll(from, to, toCannonRaycastOptions(options), (cannonResult: CANNON.RaycastResult) => { - const result = new RaycastResult(); - fillRaycastResult(result, cannonResult); - callback(result); + public raycast (worldRay: ray, options: IRaycastOptions, pool: RecyclePool, results: PhysicsRayResult[]): boolean { + setupFromAndTo(worldRay, options.maxDistance); + toCannonRaycastOptions(raycastOpt, options); + const hit = this._world.raycastAll(from, to, raycastOpt, (result: CANNON.RaycastResult): any => { + const r = pool.add(); + fillRaycastResult(r, result); + results.push(r); }); + return hit } // public addContactMaterial (contactMaterial: ContactMaterial) { @@ -134,3 +133,17 @@ export class CannonWorld implements PhysicsWorldBase { this._customAfterStepListener.forEach((fx) => fx()); } } + +const from = new CANNON.Vec3(); +const to = new CANNON.Vec3(); +function setupFromAndTo (worldRay: ray, distance: number) { + Vec3.copy(from, worldRay.o); + worldRay.computeHit(to, distance); +} + +const raycastOpt: CANNON.IRaycastOptions = { + 'checkCollisionResponse': false, + 'collisionFilterGroup': -1, + 'collisionFilterMask': -1, + 'skipBackFaces': false +} \ No newline at end of file diff --git a/cocos/physics/cocos/builtin-body.ts b/cocos/physics/cocos/builtin-body.ts index 777a16fcb4..918cf45225 100644 --- a/cocos/physics/cocos/builtin-body.ts +++ b/cocos/physics/cocos/builtin-body.ts @@ -28,7 +28,7 @@ export class BuiltInBody extends BuiltinObject implements BuiltInRigidBodyBase { private _world!: BuiltInWorld; - private _shapes: BuiltinShape[] = []; + public readonly shapes: BuiltinShape[] = []; private userData: any; @@ -38,11 +38,11 @@ export class BuiltInBody extends BuiltinObject implements BuiltInRigidBodyBase { } public intersects (body: BuiltInBody) { - for (let i = 0; i < this._shapes.length; i++) { - const shapeA = this._shapes[i]; + for (let i = 0; i < this.shapes.length; i++) { + const shapeA = this.shapes[i]; - for (let j = 0; j < body._shapes.length; j++) { - const shapeB = body._shapes[j]; + for (let j = 0; j < body.shapes.length; j++) { + const shapeB = body.shapes[j]; // first, Check collision filter masks if ((shapeA.collisionFilterGroup & shapeB.collisionFilterMask) === 0 || @@ -59,14 +59,14 @@ export class BuiltInBody extends BuiltinObject implements BuiltInRigidBodyBase { } public addShape (shape: BuiltinShape): void { - this._shapes.push(shape); + this.shapes.push(shape); shape.body = this; } public removeShape (shape: BuiltinShape): void { - const i = this._shapes.indexOf(shape); + const i = this.shapes.indexOf(shape); if (i >= 0) { - this._shapes.splice(i, 1); + this.shapes.splice(i, 1); } } @@ -90,7 +90,7 @@ export class BuiltInBody extends BuiltinObject implements BuiltInRigidBodyBase { public setPosition (pos: Vec3): void { /** 更新所有形状的位置 */ - for (const shape of this._shapes) { + for (const shape of this.shapes) { shape.setPosition(pos); } } @@ -101,13 +101,13 @@ export class BuiltInBody extends BuiltinObject implements BuiltInRigidBodyBase { public setRotation (rot: Quat): void { /** 更新所有形状的方向 */ - for (const shape of this._shapes) { + for (const shape of this.shapes) { shape.setRotation(rot); } } public scaleAllShapes (scale: Vec3): void { - for (const shape of this._shapes) { + for (const shape of this.shapes) { shape.setScale(scale); } } @@ -121,14 +121,14 @@ export class BuiltInBody extends BuiltinObject implements BuiltInRigidBodyBase { } public transform (m: Mat4, pos: Vec3, rot: Quat, scale: Vec3) { - for (let i = this._shapes.length; i--;) { - this._shapes[i].transform(m, pos, rot, scale); + for (let i = this.shapes.length; i--;) { + this.shapes[i].transform(m, pos, rot, scale); } } public translateAndRotate (m: Mat4, rot: Quat): void { - for (let i = this._shapes.length; i--;) { - this._shapes[i].translateAndRotate(m, rot); + for (let i = this.shapes.length; i--;) { + this.shapes[i].translateAndRotate(m, rot); } } } diff --git a/cocos/physics/cocos/builtin-world.ts b/cocos/physics/cocos/builtin-world.ts index 03679a9101..e216f74aa2 100644 --- a/cocos/physics/cocos/builtin-world.ts +++ b/cocos/physics/cocos/builtin-world.ts @@ -3,13 +3,16 @@ */ import { Vec3 } from '../../core/math'; -import { AfterStepCallback, BeforeStepCallback, BuiltInRigidBodyBase, BuiltInWorldBase, - IRaycastOptions, ITriggerEventType, ShapeBase } from '../api'; -import { RaycastResult } from '../raycast-result'; -import { getWrap } from '../util'; +import { + AfterStepCallback, BeforeStepCallback, BuiltInRigidBodyBase, BuiltInWorldBase, + IRaycastOptions, ITriggerEventType +} from '../api'; +import { PhysicsRayResult } from '../physics-ray-result'; import { BuiltInBody } from './builtin-body'; import { BuiltinShape } from './shapes/builtin-shape'; import { ArrayCollisionMatrix } from './utils/array-collision-matrix'; +import { ray, intersect } from '../../core/geom-utils'; +import { RecyclePool } from '../../core'; /** * Built-in collision system, intended for use as a @@ -83,10 +86,10 @@ export class BuiltInWorld implements BuiltInWorldBase { if (this._collisionMatrixPrev.get(shapeA.id, shapeB.id)) { // emit stay - TriggerEventObject.type = 'onTriggerStay'; + TriggerEventObject.type = 'onTriggerStay'; } else { // first trigger, emit enter - TriggerEventObject.type = 'onTriggerEnter'; + TriggerEventObject.type = 'onTriggerEnter'; } shapeA.onTrigger(TriggerEventObject); @@ -167,24 +170,66 @@ export class BuiltInWorld implements BuiltInWorldBase { this._customAfterStepListener.splice(i, 1); } - public raycastClosest (from: Vec3, to: Vec3, options: IRaycastOptions, result: RaycastResult): boolean { - return false; + public raycastClosest (worldRay: ray, options: IRaycastOptions, out: PhysicsRayResult): boolean { + let tmp_d = Infinity; + const max_d = options.maxDistance!; + const mask = options.mask!; + for (let i = 0; i < this._bodies.length; i++) { + const body = this._bodies[i] as BuiltInBody; + for (let i = 0; i < body.shapes.length; i++) { + const shape = body.shapes[i]; + // const collider = shape.getUserData(); + // if (!(collider!.node.layer & mask)) { + // continue; + // } + const distance = intersect.resolve(worldRay, shape.worldShape); + if (distance == 0 || distance > max_d) { + continue; + } + if (tmp_d > distance) { + tmp_d = distance; + Vec3.normalize(hitPoint, worldRay.d) + Vec3.scaleAndAdd(hitPoint, worldRay.o, hitPoint, distance); + out._assign(hitPoint, distance, shape); + } + } + } + + return !(tmp_d == Infinity); } - public raycastAny (from: Vec3, to: Vec3, options: IRaycastOptions, result: RaycastResult): boolean { - return false; + public raycast (worldRay: ray, options: IRaycastOptions, pool: RecyclePool, results: PhysicsRayResult[]): boolean { + const max_d = options.maxDistance!; + const mask = options.mask!; + for (let i = 0; i < this._bodies.length; i++) { + const body = this._bodies[i] as BuiltInBody; + for (let i = 0; i < body.shapes.length; i++) { + const shape = body.shapes[i]; + // const collider = shape.getUserData(); + // if (!(collider!.node.layer & mask)) { + // continue; + // } + const distance = intersect.resolve(worldRay, shape.worldShape); + if (distance == 0 || distance > max_d) { + continue; + } else { + const r = pool.add(); + worldRay.computeHit(hitPoint, distance); + r._assign(hitPoint, distance, shape); + results.push(r); + } + } + } + return results.length > 0; } - - public raycastAll (from: Vec3, to: Vec3, options: IRaycastOptions, callback: (result: RaycastResult) => void): boolean { - return false; - } - } const TriggerEventObject = { type: '' as unknown as ITriggerEventType, - selfCollider: null, - otherCollider: null, + selfCollider: null as any, + otherCollider: null as any, // selfRigidBody: null, // otherRigidBody: null, }; + +const hitPoint = new Vec3(); diff --git a/cocos/physics/cocos/shapes/builtin-shape.ts b/cocos/physics/cocos/shapes/builtin-shape.ts index 033eca6b9f..b435815d1e 100644 --- a/cocos/physics/cocos/shapes/builtin-shape.ts +++ b/cocos/physics/cocos/shapes/builtin-shape.ts @@ -3,6 +3,7 @@ import { ITriggerCallback, ITriggerEvent, ShapeBase } from '../../api'; import { BuiltInBody } from '../builtin-body'; import { IBuiltinShape } from '../builtin-interface'; import { BuiltinObject } from '../object/builtin-object'; +import { ColliderComponent } from '../../../../exports/physics-framework'; export class BuiltinShape extends BuiltinObject implements ShapeBase { @@ -28,7 +29,7 @@ export class BuiltinShape extends BuiltinObject implements ShapeBase { private readonly _id: number; - private userData: any; + private userData!: ColliderComponent | null; private _triggeredCB: ITriggerCallback[] = []; @@ -58,8 +59,8 @@ export class BuiltinShape extends BuiltinObject implements ShapeBase { Vec3.copy(this._localShape.center, center); } - public getUserData () { - return this.userData; + public getUserData (): ColliderComponent { + return this.userData!; } public setUserData (data: any): void { @@ -74,7 +75,7 @@ export class BuiltinShape extends BuiltinObject implements ShapeBase { } - public setPosition (position: Vec3){ + public setPosition (position: Vec3) { } @@ -86,7 +87,7 @@ export class BuiltinShape extends BuiltinObject implements ShapeBase { this._localShape.transform(m, pos, rot, scale, this._worldShape); } - public translateAndRotate (m: Mat4, rot: Quat){ + public translateAndRotate (m: Mat4, rot: Quat) { this._localShape.translateAndRotate(m, rot, this._worldShape); } diff --git a/cocos/physics/components/physics-system.ts b/cocos/physics/components/physics-system.ts index 6cf3f14a11..6b0988da4c 100644 --- a/cocos/physics/components/physics-system.ts +++ b/cocos/physics/components/physics-system.ts @@ -3,11 +3,14 @@ */ import { Vec3 } from '../../core/math'; -import { PhysicsWorldBase } from '../api'; +import { PhysicsWorldBase, IRaycastOptions } from '../api'; import { createPhysicsWorld } from '../instance'; import { director, Director } from '../../core/director'; import { System } from '../../core/components'; import { PhysicMaterial } from '../assets/physic-material'; +import { Layers, RecyclePool } from '../../core'; +import { ray } from '../../core/geom-utils'; +import { PhysicsRayResult } from '../physics-ray-result'; /** * @zh @@ -125,8 +128,8 @@ export class PhysicsSystem extends System { // this._deltaTime = 1 / this._frameRate; // } - public static instance: PhysicsSystem; - public static ID: 'physics'; + public static readonly instance: PhysicsSystem; + public static readonly ID: 'physics'; public _world: PhysicsWorldBase; @@ -139,7 +142,21 @@ export class PhysicsSystem extends System { private readonly _gravity = new Vec3(0, -10, 0); private readonly _material: PhysicMaterial | null = null; - constructor () { + public readonly raycastClosestResult = new PhysicsRayResult(); + public readonly raycastResults: PhysicsRayResult[] = []; + + private readonly raycastOptions: IRaycastOptions = { + 'group': -1, + 'mask': -1, + 'queryTrigger': true, + 'maxDistance': Infinity + } + + private readonly raycastResultPool = new RecyclePool(() => { + return new PhysicsRayResult(); + }, 1); + + private constructor () { super(); this._world = createPhysicsWorld(); if (!CC_PHYSICS_BUILTIN) { @@ -176,6 +193,42 @@ export class PhysicsSystem extends System { director.emit(Director.EVENT_AFTER_PHYSICS); } + /** + * @zh + * 检测所有的碰撞盒,并记录所有被检测到的结果,通过 PhysicsSystem.instance.raycastResults 访问结果 + * @param worldRay 世界空间下的一条射线 + * @param mask 掩码 + * @param maxDistance 最大检测距离 + * @param queryTrigger 是否检测触发器 + * @return boolean 表示是否有检测到碰撞盒 + * @note 由于目前 Layer 还未完善,mask 暂时失效,请留意更新公告 + */ + public raycast (worldRay: ray, mask: number = Layers.Enum.DEFAULT, maxDistance = Infinity, queryTrigger = true): boolean { + this.raycastResultPool.reset(); + this.raycastResults.length = 0; + this.raycastOptions.mask = mask; + this.raycastOptions.maxDistance = maxDistance; + this.raycastOptions.queryTrigger = queryTrigger; + return this._world.raycast(worldRay, this.raycastOptions, this.raycastResultPool, this.raycastResults); + } + + /** + * @zh + * 检测所有的碰撞盒,并记录与射线距离最短的检测结果,通过 PhysicsSystem.instance.raycastClosestResult 访问结果 + * @param worldRay 世界空间下的一条射线 + * @param mask 掩码 + * @param maxDistance 最大检测距离 + * @param queryTrigger 是否检测触发器 + * @return boolean 表示是否有检测到碰撞盒 + * @note 由于目前 Layer 还未完善,mask 暂时失效,请留意更新公告 + */ + public raycastClosest (worldRay: ray, mask: number = Layers.Enum.DEFAULT, maxDistance = Infinity, queryTrigger = true): boolean { + this.raycastOptions.mask = mask; + this.raycastOptions.maxDistance = maxDistance; + this.raycastOptions.queryTrigger = queryTrigger; + return this._world.raycastClosest(worldRay, this.raycastOptions, this.raycastClosestResult); + } + private _updateMaterial () { if (!CC_PHYSICS_BUILTIN) { this._world.defaultMaterial = this._material; @@ -185,7 +238,7 @@ export class PhysicsSystem extends System { cc.PhysicsSystem = PhysicsSystem; director.on(Director.EVENT_INIT, function () { - let sys = new PhysicsSystem(); - PhysicsSystem.instance = sys; + const sys = new cc.PhysicsSystem(); + cc.PhysicsSystem.instance = sys; director.registerSystem(PhysicsSystem.ID, sys, 0); -}); \ No newline at end of file +}); diff --git a/cocos/physics/instance.ts b/cocos/physics/instance.ts index 135981b905..939d1ac72f 100644 --- a/cocos/physics/instance.ts +++ b/cocos/physics/instance.ts @@ -5,7 +5,7 @@ import { Vec3 } from '../core/math'; import { BoxShapeBase, ICreateBodyOptions, PhysicsWorldBase, RigidBodyBase, SphereShapeBase } from './api'; import { BoxShape, PhysicsWorld, RigidBody, SphereShape } from './impl-selector'; -import { RaycastResult } from './raycast-result'; +import { PhysicsRayResult } from './physics-ray-result'; export function createPhysicsWorld (): PhysicsWorldBase { return new PhysicsWorld() as PhysicsWorldBase; @@ -23,8 +23,8 @@ export function createSphereShape (radius: number): SphereShapeBase { return new SphereShape(radius); } -export function createRaycastResult (): RaycastResult { - return new RaycastResult(); +export function createRaycastResult (): PhysicsRayResult { + return new PhysicsRayResult(); } cc.createRaycastResult = createRaycastResult; diff --git a/cocos/physics/physics-ray-result.ts b/cocos/physics/physics-ray-result.ts new file mode 100644 index 0000000000..929bcf00ed --- /dev/null +++ b/cocos/physics/physics-ray-result.ts @@ -0,0 +1,64 @@ +/** + * @category physics + */ + +import { Vec3 } from '../core/math'; +import { ShapeBase } from './api'; +import { ColliderComponent } from '../../exports/physics-framework'; + +/** + * @zh + * 用于保存物理射线检测结果 + */ +export class PhysicsRayResult { + + /** + * @zh + * 击中点 + */ + get hitPoint (): Vec3 { + return this._hitPoint; + } + + /** + * @zh + * 距离 + */ + get distance (): number { + return this._distance; + } + + /** + * @zh + * 击中的碰撞盒 + */ + get collider (): ColliderComponent { + return this._collidier!; + } + + private _hitPoint: Vec3 = new Vec3(); + private _distance: number = 0; + private _collidier: ColliderComponent | null = null; + + /** + * @zh + * 设置射线,此方法由引擎内部使用,请勿在外部脚本调用 + */ + public _assign (hitPoint: Vec3, distance: number, shape: ShapeBase) { + Vec3.copy(this._hitPoint, hitPoint); + this._distance = distance; + this._collidier = shape.getUserData() as ColliderComponent; + } + + /** + * @zh + * 克隆 + */ + public clone () { + const c = new PhysicsRayResult(); + Vec3.copy(c._hitPoint, this._hitPoint); + c._distance = this._distance; + c._collidier = this._collidier; + return c; + } +} diff --git a/cocos/physics/raycast-result.ts b/cocos/physics/raycast-result.ts deleted file mode 100644 index e174467b1c..0000000000 --- a/cocos/physics/raycast-result.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @hidden - */ - -import { Component } from '../core/components/component'; -import { Vec3 } from '../core/math'; -import { RigidBodyBase, ShapeBase } from './api'; -import { INode } from '../core/utils/interfaces'; - -export class RaycastResult { - get hitPoint (): Vec3 { - return this._hitPoint; - } - - get distance (): number { - return this._distance; - } - - get collider (): Component { - return this._collidier!; - } - - get node (): INode { - return this._node!; - } - - private _hitPoint: Vec3 = new Vec3(); - private _distance: number = 0; - private _collidier: Component | null = null; - private _node: INode | null = null; - - public _assign (hitPoint: any, distance: number, shape: ShapeBase, body: RigidBodyBase) { - Vec3.copy(this._hitPoint, hitPoint); - this._distance = distance; - this._node = body.getUserData(); - this._collidier = shape.getUserData() as Component; - } -} diff --git a/exports/physics-framework.ts b/exports/physics-framework.ts index fbbeba4e6a..e8d88a07de 100644 --- a/exports/physics-framework.ts +++ b/exports/physics-framework.ts @@ -3,6 +3,7 @@ */ import { PhysicMaterial } from '../cocos/physics/assets/physic-material'; +import { PhysicsRayResult } from '../cocos/physics/physics-ray-result'; import { BoxColliderComponent } from '../cocos/physics/components/collider/box-collider-component'; import { ColliderComponent } from '../cocos/physics/components/collider/collider-component'; import { SphereColliderComponent } from '../cocos/physics/components/collider/sphere-collider-component'; @@ -14,11 +15,13 @@ export { BoxColliderComponent, SphereColliderComponent, RigidBodyComponent, - PhysicMaterial + PhysicMaterial, + PhysicsRayResult }; cc.ColliderComponent = ColliderComponent; cc.BoxColliderComponent = BoxColliderComponent; cc.SphereColliderComponent = SphereColliderComponent; cc.RigidBodyComponent = RigidBodyComponent; -cc.PhysicMaterial = PhysicMaterial; \ No newline at end of file +cc.PhysicMaterial = PhysicMaterial; +cc.PhysicsRayResult = PhysicsRayResult; \ No newline at end of file From 441435e474eb718dd46ae2167bfbef571a6c7011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelie=20Leight=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Mon, 21 Oct 2019 15:35:20 +0800 Subject: [PATCH 20/33] optimize size of serialized animation clip (#5559) --- cocos/core/animation/animation-clip.ts | 44 ++++ cocos/core/data/index.ts | 1 + .../data/utils/compact-value-type-array.ts | 209 ++++++++++++++++++ tests/core/compact-value-type-array.test.ts | 13 ++ 4 files changed, 267 insertions(+) create mode 100644 cocos/core/data/utils/compact-value-type-array.ts create mode 100644 tests/core/compact-value-type-array.test.ts diff --git a/cocos/core/animation/animation-clip.ts b/cocos/core/animation/animation-clip.ts index b3976c6a8e..3d8faba307 100644 --- a/cocos/core/animation/animation-clip.ts +++ b/cocos/core/animation/animation-clip.ts @@ -12,6 +12,7 @@ import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; import { AnimCurve, CurveValueAdapter, IPropertyCurveData, RatioSampler } from './animation-curve'; import { ComponentModifier, HierachyModifier, TargetModifier } from './target-modifier'; import { WrapMode as AnimationWrapMode } from './types'; +import { CompactValueTypeArray } from '../data/utils/compact-value-type-array'; export interface IObjectCurveData { [propertyName: string]: IPropertyCurveData; @@ -75,6 +76,16 @@ export declare namespace AnimationClip { func: string; params: string[]; } + + export namespace _impl { + type MaybeCompactCurve = Omit & { + data: Omit & { + values: any[] | CompactValueTypeArray; + }; + }; + + type MaybeCompactKeys = Array; + } } /** @@ -82,6 +93,7 @@ export declare namespace AnimationClip { */ @ccclass('cc.AnimationClip') export class AnimationClip extends Asset { + public static preventDeferredLoadDependents = true; public static WrapMode = AnimationWrapMode; @@ -177,6 +189,8 @@ export class AnimationClip extends Asset { eventGroups: IAnimationEventGroup[]; }; + private _data: Uint8Array | null = null; + /** * @zh 动画的周期。 */ @@ -238,9 +252,17 @@ export class AnimationClip extends Asset { delete this._runtimeCurves; } + /** + * 此动画的数据。 + */ + get data () { + return this._data; + } + public onLoaded () { this.frameRate = this.sample; this._migrateCurveDatas(); + this._decodeCVTAs(); } public getPropertyCurves (): ReadonlyArray { @@ -383,6 +405,28 @@ export class AnimationClip extends Asset { } delete this.curveDatas; } + + private _decodeCVTAs () { + const binaryBuffer: ArrayBuffer = this._nativeAsset; + if (!binaryBuffer) { + return; + } + + const maybeCompressedKeys = this._keys as AnimationClip._impl.MaybeCompactKeys; + for (let iKey = 0; iKey < maybeCompressedKeys.length; ++iKey) { + const keys = maybeCompressedKeys[iKey]; + if (keys instanceof CompactValueTypeArray) { + maybeCompressedKeys[iKey] = keys.decompress(binaryBuffer); + } + } + + for (let iCurve = 0; iCurve < this._curves.length; ++iCurve) { + const curve = this._curves[iCurve] as AnimationClip._impl.MaybeCompactCurve; + if (curve.data.values instanceof CompactValueTypeArray) { + curve.data.values = curve.data.values.decompress(binaryBuffer); + } + } + } } cc.AnimationClip = AnimationClip; diff --git a/cocos/core/data/index.ts b/cocos/core/data/index.ts index a2b8b61d68..b4e405a3b7 100644 --- a/cocos/core/data/index.ts +++ b/cocos/core/data/index.ts @@ -35,3 +35,4 @@ export { CCObject, isValid } from './object'; export { default as deserialize } from './deserialize'; export { default as instantiate } from './instantiate'; export { CCInteger, CCFloat, CCBoolean, CCString} from './utils/attribute'; +export { CompactValueTypeArray } from './utils/compact-value-type-array'; diff --git a/cocos/core/data/utils/compact-value-type-array.ts b/cocos/core/data/utils/compact-value-type-array.ts new file mode 100644 index 0000000000..b6d4de46d4 --- /dev/null +++ b/cocos/core/data/utils/compact-value-type-array.ts @@ -0,0 +1,209 @@ +import { ccclass, property } from '../class-decorator'; +import { Vec3, Quat, Vec4, Vec2 } from '../../math'; + +export enum StorageUnit { + Uint8, Uint16, Uint32, + Int8, Int16, Int32, + Float32, Float64, +} + +export enum ElementType { + Scalar, + Vec2, + Vec3, + Vec4, + Quat, +} + +const elementTypeBits = 3; + +export type StorageUnitElementType = number; + +export function combineStorageUnitElementType (unit: StorageUnit, elementType: ElementType) { + return (elementType << elementTypeBits) + unit; +} + +export function extractStorageUnitElementType (combined: StorageUnitElementType) { + return { + storageUnit: ~(-1 << elementTypeBits) & combined, + elementType: combined >> elementTypeBits, + }; +} + +@ccclass('cc.CompactValueTypeArray') +export class CompactValueTypeArray { + public static StorageUnit = StorageUnit; + + public static ElementType = ElementType; + + /** + * Offset into buffer, in bytes. + */ + @property + private _byteOffset = 0; + + /** + * Unit count this CVTA occupies. + */ + @property + private _unitCount = 0; + + /** + * Element type this CVTA holds. + */ + @property + private _unitElement = combineStorageUnitElementType(StorageUnit.Uint8, ElementType.Scalar); + + /** + * Element count this CVTA holds. + */ + @property + private _length = 0; + + /** + * Returns the length in bytes that a buffer needs to encode the specified value array in form of CVTA. + * @param values The value array. + * @param unit Target element type. + */ + public static lengthFor (values: any[], elementType: ElementType, unit: StorageUnit): number { + const elementTraits = getElementTraits(elementType); + return elementTraits.requiredUnits * values.length * getStorageConstructor(unit).BYTES_PER_ELEMENT; + } + + /** + * Compresses the specified value array in form of CVTA into target buffer. + * @param values The value array. + * @param unit Target element type. + * @param arrayBuffer Target buffer. + * @param byteOffset Offset into target buffer. + */ + public static compress (values: any[], elementType: ElementType, unit: StorageUnit, arrayBuffer: ArrayBuffer, byteOffset: number, presumedByteOffset: number): CompactValueTypeArray { + const elementTraits = getElementTraits(elementType); + const storageConstructor = getStorageConstructor(unit); + const unitCount = elementTraits.requiredUnits * values.length; + const storage = new storageConstructor(arrayBuffer, byteOffset, unitCount); + for (let i = 0; i < values.length; ++i) { + elementTraits.compress(storage, i, values[i]); + } + + const result = new CompactValueTypeArray(); + result._unitElement = combineStorageUnitElementType(unit, elementType); + result._byteOffset = presumedByteOffset; + result._unitCount = unitCount; + result._length = values.length; + return result; + } + + /** + * Decompresses this CVTA. + * @param arrayBuffer The buffer this CVTA stored in. + */ + public decompress (arrayBuffer: ArrayBuffer): T[] { + const { storageUnit, elementType } = extractStorageUnitElementType(this._unitElement); + const elementTraits = getElementTraits(elementType); + const storageConstructor = getStorageConstructor(storageUnit); + const storage = new storageConstructor(arrayBuffer, this._byteOffset, this._unitCount); + const result = new Array(this._length); + for (let i = 0; i < this._length; ++i) { + result[i] = elementTraits.decompress(storage, i); + } + return result; + } +} + +function getElementTraits (elementType: ElementType) { + return BuiltinElementTypeTraits[elementType]; +} + +function getStorageConstructor (unit: StorageUnit) { + switch (unit) { + case StorageUnit.Uint8: + return Uint8Array; + case StorageUnit.Uint16: + return Uint16Array; + case StorageUnit.Uint32: + return Uint32Array; + case StorageUnit.Int8: + return Int8Array; + case StorageUnit.Int16: + return Int16Array; + case StorageUnit.Int32: + return Int32Array; + case StorageUnit.Float32: + return Float32Array; + case StorageUnit.Float64: + return Float64Array; + } +} + +interface CompactTraits { + requiredUnits: number; + compress (storage: CompactValueTypeArrayStorage, index: number, value: any): void; + decompress (storage: CompactValueTypeArrayStorage, index: number): any; +} + +const BuiltinElementTypeTraits: Record = { + [ElementType.Scalar]: { + requiredUnits: 1, + compress (storage: CompactValueTypeArrayStorage, index: number, value: number) { + storage[index] = value; + }, + decompress (storage: CompactValueTypeArrayStorage, index: number) { + return storage[index]; + } + }, + [ElementType.Vec2]: { + requiredUnits: 2, + compress (storage: CompactValueTypeArrayStorage, index: number, value: Vec2) { + storage[index * 2] = value.x; + storage[index * 2 + 1] = value.y; + }, + decompress (storage: CompactValueTypeArrayStorage, index: number) { + return new Vec3(storage[index * 2], storage[index * 2 + 1]); + } + }, + [ElementType.Vec3]: { + requiredUnits: 3, + compress (storage: CompactValueTypeArrayStorage, index: number, value: Vec3) { + storage[index * 3] = value.x; + storage[index * 3 + 1] = value.y; + storage[index * 3 + 2] = value.z; + }, + decompress (storage: CompactValueTypeArrayStorage, index: number) { + return new Vec3(storage[index * 3], storage[index * 3 + 1], storage[index * 3 + 2]); + } + }, + [ElementType.Vec4]: { + requiredUnits: 4, + compress (storage: CompactValueTypeArrayStorage, index: number, value: Vec4) { + storage[index * 4] = value.x; + storage[index * 4 + 1] = value.y; + storage[index * 4 + 2] = value.z; + storage[index * 4 + 3] = value.w; + }, + decompress (storage: CompactValueTypeArrayStorage, index: number) { + return new Vec4(storage[index * 4], storage[index * 4 + 1], storage[index * 4 + 2], storage[index * 4 + 3]); + } + }, + [ElementType.Quat]: { + requiredUnits: 4, + compress (storage: CompactValueTypeArrayStorage, index: number, value: Quat) { + storage[index * 4] = value.x; + storage[index * 4 + 1] = value.y; + storage[index * 4 + 2] = value.z; + storage[index * 4 + 3] = value.w; + }, + decompress (storage: CompactValueTypeArrayStorage, index: number) { + return new Quat(storage[index * 4], storage[index * 4 + 1], storage[index * 4 + 2], storage[index * 4 + 3]); + } + }, +}; + +interface CompactValueTypeArrayStorage { + readonly length: number; + [n: number]: number; +} + +export function isCompactValueTypeArray (value: any): value is CompactValueTypeArray { + return value instanceof CompactValueTypeArray; +} diff --git a/tests/core/compact-value-type-array.test.ts b/tests/core/compact-value-type-array.test.ts new file mode 100644 index 0000000000..aa350e56b5 --- /dev/null +++ b/tests/core/compact-value-type-array.test.ts @@ -0,0 +1,13 @@ +import { StorageUnit, ElementType, combineStorageUnitElementType, extractStorageUnitElementType } from '../../cocos/core/data/utils/compact-value-type-array'; + +test('Combine storage unit & element type', () => { + const storageUnits = Object.values(StorageUnit).filter((e) => typeof e === 'number') as StorageUnit[]; + const elementTypes = Object.values(ElementType).filter((e) => typeof e === 'number') as ElementType[]; + for (const storageUnit of storageUnits) { + for (const elementType of elementTypes) { + const combined = combineStorageUnitElementType(storageUnit, elementType); + const extracted = extractStorageUnitElementType(combined); + expect(extracted.storageUnit === storageUnit && extracted.elementType === elementType).toBe(true); + } + } +}); \ No newline at end of file From 44e6915279adafced02bea94f4223b592eb1ea62 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Mon, 21 Oct 2019 16:37:00 +0800 Subject: [PATCH 21/33] update cannon.js source to @cocos/cannon (#5573) --- cocos/physics/cannon/cannon-body.ts | 2 +- cocos/physics/cannon/cannon-util.ts | 2 +- cocos/physics/cannon/cannon-world.ts | 2 +- cocos/physics/cannon/constraint/cannon-constraint.ts | 2 +- .../cannon/constraint/cannon-distance-constraint.ts | 2 +- .../cannon/constraint/cannon-lock-constraint.ts | 2 +- .../constraint/cannon-point-to-point-constraint.ts | 2 +- cocos/physics/cannon/shapes/cannon-box-shape.ts | 2 +- cocos/physics/cannon/shapes/cannon-shape.ts | 2 +- cocos/physics/cannon/shapes/cannon-sphere-shape.ts | 2 +- package-lock.json | 10 +++++----- package.json | 4 +++- rollup/src/build-engine.ts | 4 ++-- tsconfig.json | 1 + 14 files changed, 21 insertions(+), 18 deletions(-) diff --git a/cocos/physics/cannon/cannon-body.ts b/cocos/physics/cannon/cannon-body.ts index 2b2342d346..b8daaf26a1 100644 --- a/cocos/physics/cannon/cannon-body.ts +++ b/cocos/physics/cannon/cannon-body.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { Mat4, Quat, Vec3 } from '../../core/math'; import { ICollisionCallback, ICollisionEventType, ICreateBodyOptions, PhysicsWorldBase, RigidBodyBase, ShapeBase } from '../api'; import { ERigidBodyType } from '../physic-enum'; diff --git a/cocos/physics/cannon/cannon-util.ts b/cocos/physics/cannon/cannon-util.ts index db7382b74c..56e4c7ee85 100644 --- a/cocos/physics/cannon/cannon-util.ts +++ b/cocos/physics/cannon/cannon-util.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { IRaycastOptions, ShapeBase } from '../api'; import { PhysicsRayResult } from '../physics-ray-result'; import { getWrap } from '../util'; diff --git a/cocos/physics/cannon/cannon-world.ts b/cocos/physics/cannon/cannon-world.ts index aa7ea49b1b..1050d0530c 100644 --- a/cocos/physics/cannon/cannon-world.ts +++ b/cocos/physics/cannon/cannon-world.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { Vec3 } from '../../core/math'; import { PhysicsRayResult } from '../physics-ray-result'; import { setWrap } from '../util'; diff --git a/cocos/physics/cannon/constraint/cannon-constraint.ts b/cocos/physics/cannon/constraint/cannon-constraint.ts index 6372f3e69c..8dcea72186 100644 --- a/cocos/physics/cannon/constraint/cannon-constraint.ts +++ b/cocos/physics/cannon/constraint/cannon-constraint.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { ConstraintBase } from '../../api'; import { getWrap, setWrap } from '../../util'; import { CannonRigidBody } from '../cannon-body'; diff --git a/cocos/physics/cannon/constraint/cannon-distance-constraint.ts b/cocos/physics/cannon/constraint/cannon-distance-constraint.ts index 521a46d24d..550fa65f31 100644 --- a/cocos/physics/cannon/constraint/cannon-distance-constraint.ts +++ b/cocos/physics/cannon/constraint/cannon-distance-constraint.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { DistanceConstraintBase, IDistanceConstraintOptions } from '../../api'; import { CannonRigidBody } from '../cannon-body'; import { CannonConstraint } from './cannon-constraint'; diff --git a/cocos/physics/cannon/constraint/cannon-lock-constraint.ts b/cocos/physics/cannon/constraint/cannon-lock-constraint.ts index 521a46d24d..550fa65f31 100644 --- a/cocos/physics/cannon/constraint/cannon-lock-constraint.ts +++ b/cocos/physics/cannon/constraint/cannon-lock-constraint.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { DistanceConstraintBase, IDistanceConstraintOptions } from '../../api'; import { CannonRigidBody } from '../cannon-body'; import { CannonConstraint } from './cannon-constraint'; diff --git a/cocos/physics/cannon/constraint/cannon-point-to-point-constraint.ts b/cocos/physics/cannon/constraint/cannon-point-to-point-constraint.ts index 3c2e369741..6f9df9f0ea 100644 --- a/cocos/physics/cannon/constraint/cannon-point-to-point-constraint.ts +++ b/cocos/physics/cannon/constraint/cannon-point-to-point-constraint.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { Vec3 } from '../../../core/math'; import { IPointToPointConstraintOptions, PointToPointConstraintBase } from '../../api'; import { CannonRigidBody } from '../cannon-body'; diff --git a/cocos/physics/cannon/shapes/cannon-box-shape.ts b/cocos/physics/cannon/shapes/cannon-box-shape.ts index 06c47a4202..bedd5356b2 100644 --- a/cocos/physics/cannon/shapes/cannon-box-shape.ts +++ b/cocos/physics/cannon/shapes/cannon-box-shape.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { Vec3 } from '../../../core/math'; import { BoxShapeBase, ShapeBase } from '../../api'; import { getWrap, setWrap, stringfyVec3 } from '../../util'; diff --git a/cocos/physics/cannon/shapes/cannon-shape.ts b/cocos/physics/cannon/shapes/cannon-shape.ts index 4b5b513a9d..ff32a9ff62 100644 --- a/cocos/physics/cannon/shapes/cannon-shape.ts +++ b/cocos/physics/cannon/shapes/cannon-shape.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { Quat, Vec3 } from '../../../core/math'; import { ITriggerCallback, ITriggerEventType, ShapeBase } from '../../api'; import { getWrap, stringfyVec3 } from '../../util'; diff --git a/cocos/physics/cannon/shapes/cannon-sphere-shape.ts b/cocos/physics/cannon/shapes/cannon-sphere-shape.ts index e9b6881d7f..103b073413 100644 --- a/cocos/physics/cannon/shapes/cannon-sphere-shape.ts +++ b/cocos/physics/cannon/shapes/cannon-sphere-shape.ts @@ -1,4 +1,4 @@ -import CANNON from 'cannon'; +import CANNON from '@cocos/cannon'; import { Vec3 } from '../../../core/math'; import { ShapeBase, SphereShapeBase } from '../../api'; import { maxComponent, setWrap } from '../../util'; diff --git a/package-lock.json b/package-lock.json index 901121e172..210fc96aba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -877,6 +877,11 @@ "minimist": "^1.2.0" } }, + "@cocos/cannon": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@cocos/cannon/-/cannon-1.0.1.tgz", + "integrity": "sha512-D/LQSfW7YM5xV6Si7r5ari1+0nb5HP5aXqBmQmMGBGOq0HPDQgeq8pEQ05DKPIfdCncHz7BHDxP6LJIA9P/cGg==" + }, "@jest/console": { "version": "24.9.0", "resolved": "https://registry.npm.taobao.org/@jest/console/download/@jest/console-24.9.0.tgz", @@ -3116,11 +3121,6 @@ "integrity": "sha1-uRk+KTzPfkQmxSRRNLjypWwKxLk=", "dev": true }, - "cannon": { - "version": "github:cocos-creator/cannon.js#dc9fe79b300839ee20c1f5ee4c608a81630f82e4", - "from": "github:cocos-creator/cannon.js#cc1.0.2", - "dev": true - }, "capture-exit": { "version": "2.0.0", "resolved": "https://registry.npm.taobao.org/capture-exit/download/capture-exit-2.0.0.tgz", diff --git a/package.json b/package.json index 27a1918689..2f615412ab 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "babel-preset-env": "^1.2.2", "babelify": "7.3.0", "browserify": "^16.2.3", - "cannon": "github:cocos-creator/cannon.js#cc1.0.2", "chalk": "1.1.0", "commander": "^2.20.0", "dat.gui": "^0.7.5", @@ -98,5 +97,8 @@ "vinyl-source-stream": "1.0.0", "watchify": "^3.7.0", "yargs": "^12.0.5" + }, + "dependencies": { + "@cocos/cannon": "^1.0.1" } } diff --git a/rollup/src/build-engine.ts b/rollup/src/build-engine.ts index 48541a0e4f..310d076e25 100644 --- a/rollup/src/build-engine.ts +++ b/rollup/src/build-engine.ts @@ -174,7 +174,7 @@ async function _internalBuild (options: IAdvancedOptions) { extensions: ['.js', '.ts'], highlightCode: true, ignore: [ - 'node_modules/cannon/**', + 'node_modules/@cocos/cannon/**', 'node_modules/tween.js/**', ], plugins: [ @@ -196,7 +196,7 @@ async function _internalBuild (options: IAdvancedOptions) { commonjs({ namedExports: { - 'cannon': ['CANNON', 'Shape'], + '@cocos/cannon': ['CANNON'], 'tween.js': ['TWEEN'], }, }), diff --git a/tsconfig.json b/tsconfig.json index 556d7bd801..30d6799e15 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,6 +19,7 @@ "./@types/webGL.extras", "./@types/webGL2.extras", "./node_modules/tween.js/TWEEN", + "./node_modules/@cocos/cannon/CANNON", "./node_modules/@types/jest/index" ] }, From 3cf4c225d2a9905ab3c1e350c0dcba47e35eb739 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Wed, 23 Oct 2019 13:42:40 +0800 Subject: [PATCH 22/33] allow up to 2^32 shader macro combinations (#5579) * allow up to 2^32 shader macro combinations * stricter layer check for rendering --- cocos/core/pipeline/render-pipeline.ts | 4 +-- cocos/core/renderer/core/program-lib.ts | 42 +++++++++++++------------ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/cocos/core/pipeline/render-pipeline.ts b/cocos/core/pipeline/render-pipeline.ts index 1677d84c59..19f35c3c2c 100644 --- a/cocos/core/pipeline/render-pipeline.ts +++ b/cocos/core/pipeline/render-pipeline.ts @@ -1233,8 +1233,8 @@ export abstract class RenderPipeline { model.updateUBOs(); this.addVisibleModel(model, camera); } - }else{ - if ((model.node && (view.visibility & model.node.layer)) || + } else { + if (model.node && ((view.visibility & model.node.layer) === model.node.layer) || (view.visibility & model.visFlags)) { model.updateTransform(); diff --git a/cocos/core/renderer/core/program-lib.ts b/cocos/core/renderer/core/program-lib.ts index 59c5b229b0..079e5c657e 100644 --- a/cocos/core/renderer/core/program-lib.ts +++ b/cocos/core/renderer/core/program-lib.ts @@ -46,9 +46,9 @@ interface IProgramInfo extends IShaderInfo { globalsInited: boolean; localsInited: boolean; } -export interface IDefineValue { +export interface IMacroInfo { name: string; - result: string | boolean; + value: string; } const getBitCount = (cnt: number) => Math.ceil(Math.log2(Math.max(cnt, 2))); @@ -64,17 +64,17 @@ const mapDefine = (info: IDefineInfo, def: number | string | boolean) => { }; const prepareDefines = (defs: IDefineMap, tDefs: IDefineInfo[]) => { - const defines: IDefineValue[] = []; + const macros: IMacroInfo[] = []; for (const tmpl of tDefs) { const name = tmpl.name; - const result = mapDefine(tmpl, defs[name]); - defines.push({ name, result }); + const value = mapDefine(tmpl, defs[name]); + macros.push({ name, value }); } - return defines; + return macros; }; -const getShaderInstanceName = (name: string, defs: IDefineValue[]) => { - return name + defs.reduce((acc, cur) => cur.result !== '0' ? `${acc}|${cur.name}${cur.result}` : acc, ''); +const getShaderInstanceName = (name: string, macros: IMacroInfo[]) => { + return name + macros.reduce((acc, cur) => cur.value !== '0' ? `${acc}|${cur.name}${cur.value}` : acc, ''); }; const insertBuiltinBindings = (tmpl: IProgramInfo, source: Map, type: string) => { @@ -143,12 +143,12 @@ class ProgramLib { if (def.type === 'number') { const range = def.range!; cnt = getBitCount(range[1] - range[0] + 1); // inclusive on both ends - def._map = (value: number) => (value - range[0]) << def._offset; + def._map = (value: number) => value - range[0]; } else if (def.type === 'string') { cnt = getBitCount(def.options!.length); - def._map = (value: any) => Math.max(0, def.options!.findIndex((s) => s === value)) << def._offset; + def._map = (value: any) => Math.max(0, def.options!.findIndex((s) => s === value)); } else if (def.type === 'boolean') { - def._map = (value: any) => value ? (1 << def._offset) : 0; + def._map = (value: any) => value ? 1 : 0; } def._offset = offset; offset += cnt; @@ -186,9 +186,11 @@ class ProgramLib { if (value === undefined || !tmplDef._map) { continue; } - key |= tmplDef._map(value); + const mapped = tmplDef._map(value); + const offset = tmplDef._offset; + key |= mapped << offset; } - return key << 8 | (tmpl.id & 0xff); + return `${key.toString(16)}|${tmpl.id}`; } /** @@ -197,9 +199,9 @@ class ProgramLib { * @param defines 用于筛选的预处理宏列表 */ public destroyShaderByDefines (defines: IDefineMap) { - const defs = Object.keys(defines); if (!defs.length) { return; } - const regexes = defs.map((cur) => { - let val = defs[cur]; + const names = Object.keys(defines); if (!names.length) { return; } + const regexes = names.map((cur) => { + let val = defines[cur]; if (typeof val === 'boolean') { val = val ? '1' : '0'; } return new RegExp(cur + val); }); @@ -231,9 +233,9 @@ class ProgramLib { const tmpl = this._templates[name]; if (!tmpl.globalsInited) { insertBuiltinBindings(tmpl, pipeline.globalBindings, 'globals'); tmpl.globalsInited = true; } - const defs = prepareDefines(defines, tmpl.defines); - const customDef = defs.reduce((acc, cur) => { - return `${acc}#define ${cur.name} ${cur.result}\n`; + const macroArray = prepareDefines(defines, tmpl.defines); + const customDef = macroArray.reduce((acc, cur) => { + return `${acc}#define ${cur.name} ${cur.value}\n`; }, ''); let vert: string = ''; @@ -247,7 +249,7 @@ class ProgramLib { } program = device.createShader({ - name: getShaderInstanceName(name, defs), + name: getShaderInstanceName(name, macroArray), blocks: tmpl.blocks, samplers: tmpl.samplers, stages: [ From edbbea92dd8126f99e11a3c7c44bf24f99d94ced Mon Sep 17 00:00:00 2001 From: JoneLau <32630749+JoneLau@users.noreply.github.com> Date: Wed, 23 Oct 2019 13:52:00 +0800 Subject: [PATCH 23/33] add wx subcontextview (#5583) --- .../ui-base/ui-transfrom-component.ts | 2 +- cocos/core/platform/SubContextView.ts | 224 ++++++++++++++++++ cocos/core/platform/index.ts | 1 + 3 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 cocos/core/platform/SubContextView.ts diff --git a/cocos/core/components/ui-base/ui-transfrom-component.ts b/cocos/core/components/ui-base/ui-transfrom-component.ts index bac6f5638b..bb3153eb3c 100644 --- a/cocos/core/components/ui-base/ui-transfrom-component.ts +++ b/cocos/core/components/ui-base/ui-transfrom-component.ts @@ -351,7 +351,7 @@ export class UITransformComponent extends Component { /** * @zh * 将一个 UI 节点世界坐标系下点转换到另一个 UI 节点 (局部) 空间坐标系,这个坐标系以锚点为原点。 - * 非 UI 节点转换到 UI 节点(局部) 空间坐标系,请走 `cc.pipelineUtils.ConvertWorldToUISpaceAR`。 + * 非 UI 节点转换到 UI 节点(局部) 空间坐标系,请走 `cc.pipelineUtils.WorldNode3DToLocalNodeUI`。 * * @param worldPoint - 世界坐标点。 * @param out - 转换后坐标。 diff --git a/cocos/core/platform/SubContextView.ts b/cocos/core/platform/SubContextView.ts new file mode 100644 index 0000000000..0af0599a30 --- /dev/null +++ b/cocos/core/platform/SubContextView.ts @@ -0,0 +1,224 @@ + +import { Component } from '../components/component'; +import { property, ccclass, menu, executionOrder } from '../data/class-decorator'; +import { view } from './view'; +import { SpriteComponent } from '../../ui/components/sprite-component'; +import { Node } from '../scene-graph'; +import { UITransformComponent } from '../components/ui-base/ui-transfrom-component'; +import { SpriteFrame, ImageAsset } from '../assets'; +import { Rect } from '../math'; + +/** + * @en SubContextView is a view component which controls open data context viewport in WeChat game platform.
+ * The component's node size decide the viewport of the sub context content in main context, + * the entire sub context texture will be scaled to the node's bounding box area.
+ * This component provides multiple important features:
+ * 1. Sub context could use its own resolution size and policy.
+ * 2. Sub context could be minized to smallest size it needed.
+ * 3. Resolution of sub context content could be increased.
+ * 4. User touch input is transformed to the correct viewport.
+ * 5. Texture update is handled by this component. User don't need to worry.
+ * One important thing to be noted, whenever the node's bounding box change, + * you need to manually reset the viewport of sub context using updateSubContextViewport. + * @zh SubContextView 可以用来控制微信小游戏平台开放数据域在主域中的视窗的位置。
+ * 这个组件的节点尺寸决定了开放数据域内容在主域中的尺寸,整个开放数据域会被缩放到节点的包围盒范围内。
+ * 在这个组件的控制下,用户可以更自由得控制开放数据域:
+ * 1. 子域中可以使用独立的设计分辨率和适配模式
+ * 2. 子域区域尺寸可以缩小到只容纳内容即可
+ * 3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
+ * 4. 用户输入坐标会被自动转换到正确的子域视窗中
+ * 5. 子域内容贴图的更新由组件负责,用户不需要处理
+ * 唯一需要注意的是,当子域节点的包围盒发生改变时,开发者需要使用 `updateSubContextViewport` 来手动更新子域视窗。 + */ +@ccclass('cc.SubContextView') +@executionOrder(110) +@menu('Components/SubContextView') +export class SubContextView extends Component { + @property + get fps (){ + return this._fps; + } + set fps (value) { + if (this._fps === value) { + return; + } + this._fps = value; + this._updateInterval = 1 / value; + this._updateSubContextFrameRate(); + } + + @property({ type: Number }) + private _fps = 60; + private _sprite: SpriteComponent | null; + private _imageAsset: ImageAsset; + private _context: any;; + private _updatedTime = 0; + private _updateInterval = 0; + + constructor () { + super(); + this._sprite = null; + this._imageAsset = new ImageAsset(); + this._context = null; + this._updatedTime = performance.now(); + } + + public onLoad () { + // Setup subcontext canvas size + if (wx.getOpenDataContext) { + this._updateInterval = 1000 / this._fps; + this._context = wx.getOpenDataContext(); + // reset sharedCanvas width and height + this.reset(); + + const image = this._imageAsset; + const sharedCanvas = this._context.canvas; + image.reset(sharedCanvas); + image._texture.create(sharedCanvas.width, sharedCanvas.height); + + this._sprite = this.node.getComponent(SpriteComponent); + if (!this._sprite) { + this._sprite = this.node.addComponent(SpriteComponent); + } + + if (this._sprite!.spriteFrame) { + this._sprite!.spriteFrame.texture = this._imageAsset._texture; + } else { + const sp = new SpriteFrame(); + sp.texture = this._imageAsset._texture; + this._sprite!.spriteFrame = sp; + } + } else { + this.enabled = false; + } + } + + public onEnable () { + this._runSubContextMainLoop(); + this._registerNodeEvent(); + this._updateSubContextFrameRate(); + this.updateSubContextViewport(); + } + + public onDisable () { + this._unregisterNodeEvent(); + this._stopSubContextMainLoop(); + } + + public update (dt: number) { + let calledUpdateMannually = (dt === undefined); + if (calledUpdateMannually) { + this._context && this._context.postMessage({ + fromEngine: true, + event: 'step', + }); + this._updateSubContextTexture(); + return; + } + let now = performance.now(); + let deltaTime = (now - this._updatedTime); + if (deltaTime >= this._updateInterval) { + this._updatedTime += this._updateInterval; + this._updateSubContextTexture(); + } + } + + /** + * @en Reset open data context size and viewport + * @zh 重置开放数据域的尺寸和视窗 + * @method reset + */ + public reset () { + if (this._context) { + this.updateSubContextViewport(); + let sharedCanvas = this._context.canvas; + if (sharedCanvas) { + sharedCanvas.width = this.node.getComponent(UITransformComponent).width; + sharedCanvas.height = this.node.getComponent(UITransformComponent).height; + } + } + } + + /** + * @en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + * @zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。 + */ + public updateSubContextViewport () { + if (this._context) { + let box = this.node.getComponent(UITransformComponent).getBoundingBoxToWorld() as Rect; + let sx = view.getScaleX(); + let sy = view.getScaleY(); + const rect = view.getViewportRect(); + this._context.postMessage({ + fromEngine: true, + event: 'viewport', + x: box.x * sx + rect.x, + y: box.y * sy + rect.y, + width: box.width * sx, + height: box.height * sy + }); + } + } + + private _updateSubContextTexture () { + const img = this._imageAsset; + if (!img || !this._context) { + return; + } + + if (img.width <= 0 || img.height <= 0) { + return; + } + + const canvas = this._context.canvas; + img.reset(canvas); + if (canvas.width > img.width || canvas.height > img.height ){ + this._imageAsset._texture.create(canvas.width, canvas.height); + } + + this._imageAsset._texture.uploadData(canvas); + } + + private _registerNodeEvent () { + this.node.on(Node.EventType.TRANSFORM_CHANGED, this.updateSubContextViewport, this); + this.node.on(Node.EventType.SCALE_PART, this.updateSubContextViewport, this); + this.node.on(Node.EventType.SIZE_CHANGED, this.updateSubContextViewport, this); + } + + private _unregisterNodeEvent () { + this.node.off(Node.EventType.TRANSFORM_CHANGED, this.updateSubContextViewport, this); + this.node.off(Node.EventType.SCALE_PART, this.updateSubContextViewport, this); + this.node.off(Node.EventType.SIZE_CHANGED, this.updateSubContextViewport, this); + } + + private _runSubContextMainLoop () { + if (this._context) { + this._context.postMessage({ + fromEngine: true, + event: 'mainLoop', + value: true, + }); + } + } + + private _stopSubContextMainLoop () { + if (this._context) { + this._context.postMessage({ + fromEngine: true, + event: 'mainLoop', + value: false, + }); + } + } + + private _updateSubContextFrameRate () { + if (this._context) { + this._context.postMessage({ + fromEngine: true, + event: 'frameRate', + value: this._fps, + }); + } + } +} +cc.SubContextView = SubContextView; diff --git a/cocos/core/platform/index.ts b/cocos/core/platform/index.ts index 0a8edbd4e5..5ffe72a3ec 100644 --- a/cocos/core/platform/index.ts +++ b/cocos/core/platform/index.ts @@ -43,3 +43,4 @@ export { } from './debug'; export { screen } from './screen'; +export { SubContextView } from './SubContextView'; From 89c1ca97cf8fbd142996fd4d5e9fd33b7c37f5fc Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Wed, 23 Oct 2019 14:17:25 +0800 Subject: [PATCH 24/33] fix rigidbody initialize (#5590) --- cocos/physics/components/rigid-body-component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/physics/components/rigid-body-component.ts b/cocos/physics/components/rigid-body-component.ts index 5e7df8d011..d79e068498 100644 --- a/cocos/physics/components/rigid-body-component.ts +++ b/cocos/physics/components/rigid-body-component.ts @@ -396,7 +396,8 @@ export class RigidBodyComponent extends PhysicsBasedComponent { /// COMPONENT LIFECYCLE /// - protected onLoad () { + protected onEnable () { + super.onEnable(); if (!CC_PHYSICS_BUILTIN) { /** * 此处设置刚体属性是因为__preload不受executionOrder的顺序影响, From 4d0ce3d94c35e8dedb872330b4e6b91b14fee322 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Wed, 23 Oct 2019 17:08:59 +0800 Subject: [PATCH 25/33] fix physics sync with kinematic (#5589) * fix physics sync with kinematic * tweaks --- .../detail/physics-based-component.ts | 24 ++++++++----------- .../components/rigid-body-component.ts | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/cocos/physics/components/detail/physics-based-component.ts b/cocos/physics/components/detail/physics-based-component.ts index acecc3d9c8..fc043f3ea5 100644 --- a/cocos/physics/components/detail/physics-based-component.ts +++ b/cocos/physics/components/detail/physics-based-component.ts @@ -207,21 +207,11 @@ export class PhysicsBasedComponent extends Component { } class SharedRigidBody { - public get isShapeOnly (): boolean { return this._isShapeOnly; } public get body () { return this._body; } - /** the source to manage body transfrom */ - public set transfromSource (v: ETransformSource) { - if (v === ETransformSource.SCENE) { - this._isShapeOnly = true; - } else { - this._isShapeOnly = false; - } - } - public get rigidBody () { return this._rigidBody; } @@ -250,9 +240,15 @@ class SharedRigidBody { private _afterStepCallback!: AfterStepCallback; - /** 是否只有Collider组件 */ private _isShapeOnly: boolean = true; + public get isShapeOnly (): boolean { + return this._isShapeOnly; + } + + public set isShapeOnly (v: boolean) { + this._isShapeOnly = v; + } constructor (node: INode, rigidBody: object | null, world: PhysicsWorldBase) { this._body = createRigidBody({ @@ -394,11 +390,11 @@ class SharedRigidBody { private _afterStep () { if (!CC_PHYSICS_BUILTIN) { - // 物理计算之后,除了只有形状组件的节点,其它有刚体组件的节点,并且刚体类型为DYNAMIC的,需要将计算结果同步到Scene中 - if (!this._isShapeOnly && this._body.getType() === ERigidBodyType.DYNAMIC) { + // sync, if body is not static + if (this._body.getType() !== ERigidBodyType.STATIC) { this._syncSceneWithPhys(); } else { - // 对于只有形状组件的节点,需要将Scene中节点的Transform同步到Phyisc。 + // 对于只有形状组件的节点,需要将Scene中节点的Transform同步到Physics。 // 这是因为物理计算后可能会改变一些节点,这会导致这些子节点的Transform也发生改变。 if (this._node.hasChangedFlags) { this._syncPhysWithScene(this._node); diff --git a/cocos/physics/components/rigid-body-component.ts b/cocos/physics/components/rigid-body-component.ts index d79e068498..5fa53dbe45 100644 --- a/cocos/physics/components/rigid-body-component.ts +++ b/cocos/physics/components/rigid-body-component.ts @@ -413,6 +413,7 @@ export class RigidBodyComponent extends PhysicsBasedComponent { this.fixedRotation = this._fixedRotation; this.linearFactor = this._linearFactor; this.angularFactor = this._angularFactor; + this.sharedBody.isShapeOnly = false; } } } From 91ef4f0d8a2e8d7adf82746d60ee7e171572a6de Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Wed, 23 Oct 2019 19:11:14 +0800 Subject: [PATCH 26/33] fix skybox mesh init (#5599) --- cocos/core/renderer/scene/render-scene.ts | 1 + cocos/core/renderer/scene/skybox.ts | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos/core/renderer/scene/render-scene.ts b/cocos/core/renderer/scene/render-scene.ts index faf3188f81..ade0a104dc 100644 --- a/cocos/core/renderer/scene/render-scene.ts +++ b/cocos/core/renderer/scene/render-scene.ts @@ -156,6 +156,7 @@ export class RenderScene { this.destroyPointLights(); this.destroySpotLights(); this.destroyModels(); + this._skybox.destroy(); this._planarShadows.destroy(); this._texturePool.destroy(); } diff --git a/cocos/core/renderer/scene/skybox.ts b/cocos/core/renderer/scene/skybox.ts index 3c1caa00e9..e181361523 100644 --- a/cocos/core/renderer/scene/skybox.ts +++ b/cocos/core/renderer/scene/skybox.ts @@ -1,6 +1,7 @@ import { builtinResMgr } from '../../3d/builtin'; import { createMesh } from '../../3d/misc/utils'; import { Material } from '../../assets/material'; +import { Mesh } from '../../assets/mesh'; import { TextureCube } from '../../assets/texture-cube'; import { IInternalBindingInst, UNIFORM_ENVIRONMENT } from '../../pipeline/define'; import { box } from '../../primitive'; @@ -8,6 +9,8 @@ import { samplerLib } from '../core/sampler-lib'; import { Model } from './model'; import { RenderScene } from './render-scene'; +let skybox_mesh: Mesh | null = null; + export class Skybox extends Model { set useIBL (val) { @@ -52,10 +55,8 @@ export class Skybox extends Model { this._scene = scene; this._material.initialize({ effectName: 'pipeline/skybox', defines: { USE_RGBE_CUBEMAP: this._isRGBE } }); this._globalBinding = this._scene.root.pipeline.globalBindings.get(UNIFORM_ENVIRONMENT.name)!; - - const mesh = createMesh(box({ width: 2, height: 2, length: 2 })); - const subMeshData = mesh.renderingMesh.getSubmesh(0)!; - this.initSubModel(0, subMeshData, this._material); + if (!skybox_mesh) { skybox_mesh = createMesh(box({ width: 2, height: 2, length: 2 })); } + this.initSubModel(0, skybox_mesh.renderingMesh.getSubmesh(0), this._material); } protected _updatePipeline () { From 9ae90d2235db6db6f28ce4d2eb9e2a42b1e72834 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 23 Oct 2019 19:11:32 +0800 Subject: [PATCH 27/33] Fix Asset._native property definition (#5595) * Fix Asset._native property definition * Fix ci --- cocos/core/assets/asset.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/core/assets/asset.ts b/cocos/core/assets/asset.ts index 8711e0f2f1..da17998894 100644 --- a/cocos/core/assets/asset.ts +++ b/cocos/core/assets/asset.ts @@ -106,8 +106,8 @@ export class Asset extends RawAsset implements IEventTarget { * 用于本机资产的可序列化URL。供内部使用。 * @default "" */ - @property - public _native: string | undefined = ''; + @property(cc.String) + public _native: string = ''; private _file: any = null; @@ -247,7 +247,7 @@ export class Asset extends RawAsset implements IEventTarget { */ public _setRawAsset (filename: string, inLibrary: boolean = true) { if (inLibrary !== false) { - this._native = filename || undefined; + this._native = filename || ''; } else { this._native = '/' + filename; // simply use '/' to tag location where is not in the library From 473726a7eb7dd9f0c7825cd90993c11ece39d6cb Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Thu, 24 Oct 2019 10:02:36 +0800 Subject: [PATCH 28/33] physic material override & hide some property (#5582) * - override & hide some property - default value -1 to 0.1 * remove override --- cocos/physics/assets/physic-material.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/physics/assets/physic-material.ts b/cocos/physics/assets/physic-material.ts index 3cfbf33200..753c112bb7 100644 --- a/cocos/physics/assets/physic-material.ts +++ b/cocos/physics/assets/physic-material.ts @@ -17,16 +17,17 @@ export class PhysicMaterial extends Asset { private static _idCounter: number = 0; @property - private _friction = -1; + private _friction = 0.1; @property - private _restitution = -1; + private _restitution = 0.1; /** * Friction for this material. * If non-negative, it will be used instead of the friction given by ContactMaterials. * If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used. */ + @property get friction () { return this._friction; } @@ -43,6 +44,7 @@ export class PhysicMaterial extends Asset { * If non-negative, it will be used instead of the restitution given by ContactMaterials. * If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used */ + @property get restitution () { return this._restitution; } From 48283dda5033b3acfeb90db797bf437ee9ba0194 Mon Sep 17 00:00:00 2001 From: zxg0622 <247274249@qq.com> Date: Thu, 24 Oct 2019 10:22:07 +0800 Subject: [PATCH 29/33] fix hdr renderpipeline gizmo render error (#5603) --- cocos/core/3d/framework/camera-component.ts | 6 ++++++ cocos/core/pipeline/render-view.ts | 18 ++++++++++++------ cocos/core/pipeline/ui/ui-stage.ts | 7 +++++-- cocos/core/renderer/scene/camera.ts | 6 ++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cocos/core/3d/framework/camera-component.ts b/cocos/core/3d/framework/camera-component.ts index 15f5688a37..847be01954 100644 --- a/cocos/core/3d/framework/camera-component.ts +++ b/cocos/core/3d/framework/camera-component.ts @@ -346,6 +346,12 @@ export class CameraComponent extends Component { } } + set flows (val) { + if (this._camera) { + this._camera.flows = val; + } + } + public onLoad () { cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH, this.onSceneChanged, this); } diff --git a/cocos/core/pipeline/render-view.ts b/cocos/core/pipeline/render-view.ts index b3cb6c10d4..f80c646be3 100644 --- a/cocos/core/pipeline/render-view.ts +++ b/cocos/core/pipeline/render-view.ts @@ -7,6 +7,7 @@ import { GFXWindow } from '../gfx/window'; import { Camera } from '../renderer/scene/camera'; import { RenderFlow } from './render-flow'; import { CameraDefaultMask } from './define'; +import { indexOf } from '../utils/array'; /** * @zh @@ -183,12 +184,7 @@ export class RenderView { if (!info.flows) { info.flows = ['ForwardFlow', 'ToneMapFlow', 'SMAAFlow']; } - const pipelineFlows = cc.director.root.pipeline.flows; - for (const f of pipelineFlows) { - if (info.flows.indexOf(f.name) !== -1) { - this.flows.push(f); - } - } + this.setExecuteFlows(info.flows); return true; } @@ -209,4 +205,14 @@ export class RenderView { public enable (isEnable: boolean) { this._isEnable = isEnable; } + + public setExecuteFlows (flows: string[]) { + this.flows.length = 0; + const pipelineFlows = cc.director.root.pipeline.flows; + for (const f of pipelineFlows) { + if (flows.indexOf(f.name) !== -1) { + this.flows.push(f); + } + } + } } diff --git a/cocos/core/pipeline/ui/ui-stage.ts b/cocos/core/pipeline/ui/ui-stage.ts index fe2cdc79c9..dd6a52fd58 100644 --- a/cocos/core/pipeline/ui/ui-stage.ts +++ b/cocos/core/pipeline/ui/ui-stage.ts @@ -82,8 +82,11 @@ export class UIStage extends RenderStage { const camera = view.camera!; - this._renderArea.width = this.flow.pipeline.root.device.width; - this._renderArea.height = this.flow.pipeline.root.device.height; + const vp = camera.viewport; + this._renderArea.x = vp.x * camera.width; + this._renderArea.y = vp.y * camera.height; + this._renderArea.width = vp.width * camera.width; + this._renderArea.height = vp.height * camera.height; cmdBuff.begin(); cmdBuff.beginRenderPass(framebuffer, this._renderArea, diff --git a/cocos/core/renderer/scene/camera.ts b/cocos/core/renderer/scene/camera.ts index efedaceaea..fe1c05ba2d 100644 --- a/cocos/core/renderer/scene/camera.ts +++ b/cocos/core/renderer/scene/camera.ts @@ -479,6 +479,12 @@ export class Camera { return this._exposure; } + set flows (val: string[]) { + if (this._view) { + this._view.setExecuteFlows(val); + } + } + public changeTargetWindow (window: GFXWindow | null = null) { const scene = this._scene; const win = window || scene.root.mainWindow; From 819fc122fb671827fa7ef3522c23610e53588fba Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Thu, 24 Oct 2019 17:11:05 +0800 Subject: [PATCH 30/33] physics sync after events (#5610) --- cocos/physics/cannon/cannon-world.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos/physics/cannon/cannon-world.ts b/cocos/physics/cannon/cannon-world.ts index 1050d0530c..ce3a79c89a 100644 --- a/cocos/physics/cannon/cannon-world.ts +++ b/cocos/physics/cannon/cannon-world.ts @@ -66,6 +66,9 @@ export class CannonWorld implements PhysicsWorldBase { this._callCustomAfterSteps(); this._world.emitTriggeredEvents(); this._world.emitCollisionEvents(); + + // hack, node transform may be dirty + this._callCustomBeforeSteps(); } public addBeforeStep (cb: BeforeStepCallback) { From f30a4b7b2de5da75ad768d69046fe0983e7b0908 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Fri, 25 Oct 2019 16:27:13 +0800 Subject: [PATCH 31/33] update @cocos/cannon to 1.0.2 (#5621) - fix trigger exit overlap tick may not execute --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 210fc96aba..42577bbaca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -878,9 +878,9 @@ } }, "@cocos/cannon": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@cocos/cannon/-/cannon-1.0.1.tgz", - "integrity": "sha512-D/LQSfW7YM5xV6Si7r5ari1+0nb5HP5aXqBmQmMGBGOq0HPDQgeq8pEQ05DKPIfdCncHz7BHDxP6LJIA9P/cGg==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@cocos/cannon/-/cannon-1.0.2.tgz", + "integrity": "sha512-BMr1vEB+eKC1ZGxX0642uj3C4v6tul/T15ZfBAN9gH4Hp/JcNtFooQjcPcxACKoDcErw4zPnX777cZFec4lZbA==" }, "@jest/console": { "version": "24.9.0", diff --git a/package.json b/package.json index 2f615412ab..1fd0331566 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,6 @@ "yargs": "^12.0.5" }, "dependencies": { - "@cocos/cannon": "^1.0.1" + "@cocos/cannon": "^1.0.2" } } From 61331869a7dac97bb7cdf0fcb652ead19d10054d Mon Sep 17 00:00:00 2001 From: JoneLau <32630749+JoneLau@users.noreply.github.com> Date: Fri, 25 Oct 2019 16:48:01 +0800 Subject: [PATCH 32/33] fix ui sort err in wx (#5620) --- cocos/core/components/ui-base/ui-component.ts | 8 +++++++- cocos/core/scene-graph/base-node.ts | 4 ++-- cocos/core/utils/interfaces.ts | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cocos/core/components/ui-base/ui-component.ts b/cocos/core/components/ui-base/ui-component.ts index 8644a53f53..d5b9ec619c 100644 --- a/cocos/core/components/ui-base/ui-component.ts +++ b/cocos/core/components/ui-base/ui-component.ts @@ -139,8 +139,14 @@ export class UIComponent extends Component { const bComp = b._uiComp; const ca = aComp ? aComp.priority : 0; const cb = bComp ? bComp.priority : 0; - return ca - cb; + const diff = ca - cb; + if(diff === 0){ + return a.getSiblingIndex() - b.getSiblingIndex(); + } + return diff; }); + + this.node.parent!._updateSiblingIndex(); } } diff --git a/cocos/core/scene-graph/base-node.ts b/cocos/core/scene-graph/base-node.ts index f13c7a759b..ade09ecf04 100644 --- a/cocos/core/scene-graph/base-node.ts +++ b/cocos/core/scene-graph/base-node.ts @@ -419,7 +419,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { return; } const oldParent = this._parent; - if (CC_DEBUG && oldParent && + if (CC_DEBUG && oldParent && // Change parent when old parent desactivating or activating (oldParent._objFlags & ChangingState)) { errorID(3821); @@ -1158,7 +1158,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable { } } - protected _updateSiblingIndex () { + public _updateSiblingIndex () { for (let i = 0; i < this._children.length; ++i) { this._children[i]._siblingIndex = i; } diff --git a/cocos/core/utils/interfaces.ts b/cocos/core/utils/interfaces.ts index 387807989c..99188ec1e4 100644 --- a/cocos/core/utils/interfaces.ts +++ b/cocos/core/utils/interfaces.ts @@ -736,4 +736,5 @@ export interface INode extends IBaseNode { targetOff (target: string | Object): void; pauseSystemEvents (recursive: boolean): void; resumeSystemEvents (recursive: boolean): void; + _updateSiblingIndex(): void; } From fb901af937e1cb73bdcc1143acb33805e4064f11 Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Fri, 25 Oct 2019 16:49:02 +0800 Subject: [PATCH 33/33] tslint forin rule change (#5616) --- tslint.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tslint.json b/tslint.json index 3a8e5adc83..2b4146413f 100644 --- a/tslint.json +++ b/tslint.json @@ -24,6 +24,7 @@ "no-empty": false, "radix": false, "prefer-for-of": false, + "forin":false, "max-line-length": [ true,