mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge branch '3d' of https://github.com/cocos-creator/engine into 3d
This commit is contained in:
@@ -7,7 +7,7 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('cc.RenderableComponent')
|
||||
export class RenderableComponent extends Component {
|
||||
@property({ type: [Material] })
|
||||
private _materials: Array<Material | null> = [];
|
||||
protected _materials: Array<Material | null> = [];
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
import { ccclass, executeInEditMode, executionOrder, menu, property } from '../../core/data/class-decorator';
|
||||
import { mat4 } from '../../core/vmath';
|
||||
import { GFXDevice, GFXFeature } from '../../gfx/device';
|
||||
import { SkinningModel, __FORCE_USE_UNIFORM_STORAGE__ } from '../../renderer/models/skinning-model';
|
||||
import { __FORCE_USE_UNIFORM_STORAGE__, SkinningModel } from '../../renderer/models/skinning-model';
|
||||
import { Node } from '../../scene-graph/node';
|
||||
import { Material } from '../assets/material';
|
||||
import Skeleton from '../assets/skeleton';
|
||||
@@ -86,6 +86,11 @@ export default class SkinningModelComponent extends ModelComponent {
|
||||
|
||||
public onLoad () {
|
||||
super.onLoad();
|
||||
this._materials.forEach((material, index) => {
|
||||
if (material) {
|
||||
this._onMaterialModified(index, material);
|
||||
}
|
||||
});
|
||||
this._resetSkinningTarget();
|
||||
}
|
||||
|
||||
@@ -126,16 +131,16 @@ export default class SkinningModelComponent extends ModelComponent {
|
||||
skinningModel.commitJointMatrices();
|
||||
}
|
||||
|
||||
protected _getModelConstructor () {
|
||||
return SkinningModel;
|
||||
}
|
||||
|
||||
public _updateModelParams () {
|
||||
// Should bind skeleton before super create pso
|
||||
this._bindSkeleton();
|
||||
super._updateModelParams();
|
||||
}
|
||||
|
||||
protected _getModelConstructor () {
|
||||
return SkinningModel;
|
||||
}
|
||||
|
||||
protected _onMaterialModified (index: number, material: Material) {
|
||||
super._onMaterialModified(index, material);
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
const MAX_BINDING = 24;
|
||||
|
||||
export enum UBOBinding {
|
||||
CC_SKINNING = MAX_BINDING - 6,
|
||||
CC_JOINTS_TEXTURE = MAX_BINDING - 7,
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { GFXType } from '../../gfx/define';
|
||||
import { GFXUniformBlock, GFXUniformSampler } from '../../gfx/shader';
|
||||
import { UBOBinding as UBOBindings } from '../../pipeline/cc-binding';
|
||||
|
||||
export class SkinningUBO {
|
||||
public static MAT_JOINT_OFFSET: number = 0;
|
||||
@@ -8,13 +9,13 @@ export class SkinningUBO {
|
||||
public static SIZE: number = SkinningUBO.COUNT * 4;
|
||||
|
||||
public static BLOCK: GFXUniformBlock = {
|
||||
binding: 28, name: 'CCSkinning', members: [
|
||||
binding: UBOBindings.CC_SKINNING, name: 'CCSkinning', members: [
|
||||
{ name: 'cc_matJoint', type: GFXType.MAT4, count: 128 },
|
||||
{ name: 'cc_jointsTextureSize', type: GFXType.FLOAT4, count: 1 },
|
||||
],
|
||||
};
|
||||
|
||||
public static JOINT_TEXTURE: GFXUniformSampler = {
|
||||
binding: 27, name: 'cc_jointsTexture', type: GFXType.SAMPLER2D, count: 1,
|
||||
binding: UBOBindings.CC_JOINTS_TEXTURE, name: 'cc_jointsTexture', type: GFXType.SAMPLER2D, count: 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import Skeleton from '../../3d/assets/skeleton';
|
||||
import { Texture2D } from '../../assets/texture-2d';
|
||||
import { Filter, PixelFormat, WrapMode } from '../../assets/texture-base';
|
||||
import { mat4 } from '../../core/vmath';
|
||||
import { GFXBuffer } from '../../gfx/buffer';
|
||||
import { GFXBufferUsageBit, GFXMemoryUsageBit } from '../../gfx/define';
|
||||
@@ -11,7 +12,6 @@ import { Node } from '../../scene-graph/node';
|
||||
import { Model } from '../scene/model';
|
||||
import { RenderScene } from '../scene/render-scene';
|
||||
import { SkinningUBO } from './model-uniforms';
|
||||
import { PixelFormat, Filter, WrapMode } from '../../assets/texture-base';
|
||||
|
||||
const textureSizeBuffer = new Float32Array(4);
|
||||
|
||||
@@ -159,4 +159,4 @@ function _createJointsTexture (skinning: { joints: any[]; }) {
|
||||
texture.setFilters(Filter.NEAREST, Filter.NEAREST);
|
||||
texture.setWrapMode(WrapMode.CLAMP_TO_EDGE, WrapMode.CLAMP_TO_EDGE);
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user