mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 15:42:39 +08:00
committed by
Weiliang Wang
parent
57068a5c8a
commit
7dc0bbef30
@@ -207,7 +207,8 @@ export class Material extends Asset {
|
||||
|
||||
protected _update (keepProps: boolean = true) {
|
||||
const asset = this._effectAsset;
|
||||
if (!asset) { this._passes = builtinResMgr.get<Material>('default-material')._passes.slice(); return; }
|
||||
// ugly yellow indicating missing effect
|
||||
if (!asset) { this._passes = builtinResMgr.get<Material>('missing-effect-material')._passes.slice(); return; }
|
||||
// create passes
|
||||
this._passes = Effect.parseEffect(asset, {
|
||||
techIdx: this._techIdx,
|
||||
|
||||
@@ -125,7 +125,7 @@ class BuiltinResMgr {
|
||||
effect.onLoaded();
|
||||
});
|
||||
|
||||
// tonemap material
|
||||
// smaa material
|
||||
const smaaMtl = new cc.Material();
|
||||
smaaMtl._uuid = 'smaa-material';
|
||||
smaaMtl.initialize({
|
||||
@@ -149,15 +149,25 @@ class BuiltinResMgr {
|
||||
});
|
||||
resources[standardMtl._uuid] = standardMtl;
|
||||
|
||||
// default material
|
||||
const defaultMtl = new cc.Material();
|
||||
defaultMtl._uuid = 'default-material';
|
||||
defaultMtl.initialize({
|
||||
// material indicating missing material (purple)
|
||||
const missingMtl = new cc.Material();
|
||||
missingMtl._uuid = 'missing-material';
|
||||
missingMtl.initialize({
|
||||
effectName: 'builtin-unlit',
|
||||
defines: { USE_COLOR: true },
|
||||
});
|
||||
defaultMtl.setProperty('color', cc.color('#ff00ff'));
|
||||
resources[defaultMtl._uuid] = defaultMtl;
|
||||
missingMtl.setProperty('color', cc.color('#ff00ff'));
|
||||
resources[missingMtl._uuid] = missingMtl;
|
||||
|
||||
// material indicating missing effect (yellow)
|
||||
const missingEfxMtl = new cc.Material();
|
||||
missingEfxMtl._uuid = 'missing-effect-material';
|
||||
missingEfxMtl.initialize({
|
||||
effectName: 'builtin-unlit',
|
||||
defines: { USE_COLOR: true },
|
||||
});
|
||||
missingEfxMtl.setProperty('color', cc.color('#ffff00'));
|
||||
resources[missingEfxMtl._uuid] = missingEfxMtl;
|
||||
|
||||
// sprite material
|
||||
const spriteMtl = new cc.Material();
|
||||
|
||||
@@ -284,6 +284,6 @@ export class ModelComponent extends RenderableComponent {
|
||||
|
||||
private _getBuiltinMaterial () {
|
||||
// classic ugly pink indicating missing material
|
||||
return builtinResMgr.get<Material>('default-material');
|
||||
return builtinResMgr.get<Material>('missing-material');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export default class ray {
|
||||
* @param {number} dz dir Z component
|
||||
* @return {ray}
|
||||
*/
|
||||
public static create (ox, oy, oz, dx, dy, dz) {
|
||||
public static create (ox = 0, oy = 0, oz = 0, dx = 0, dy = 0, dz = 1) {
|
||||
return new ray(ox, oy, oz, dx, dy, dz);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class triangle {
|
||||
* @param {number} cz
|
||||
* @return {triangle}
|
||||
*/
|
||||
public static create (ax, ay, az, bx, by, bz, cx, cy, cz) {
|
||||
public static create (ax = 1, ay = 0, az = 0, bx = 0, by = 0, bz = 0, cx = 0, cy = 0, cz = 1) {
|
||||
return new triangle(ax, ay, az, bx, by, bz, cx, cy, cz);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ export class Model {
|
||||
protected _node: Node | null;
|
||||
protected _id: number;
|
||||
protected _enabled: boolean = false;
|
||||
protected _viewID: number = -1;
|
||||
protected _viewID: number = 1;
|
||||
protected _cameraID: number = -1;
|
||||
protected _userKey: number = -1;
|
||||
protected _worldBounds: aabb | null = null;
|
||||
|
||||
@@ -247,8 +247,8 @@ const v3 = new Vec3();
|
||||
const m4 = new Mat4();
|
||||
let distance = Infinity;
|
||||
const tri = triangle.create();
|
||||
const pool = new RecyclePool(() => {
|
||||
return { node: null, distance: Infinity };
|
||||
const pool = new RecyclePool<IRaycastResult>(() => {
|
||||
return { node: null!, distance: Infinity };
|
||||
}, 8);
|
||||
const results: IRaycastResult[] = [];
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
// const spNode = new cc.Node('test');
|
||||
// spNode.parent = rt;
|
||||
// const spCom = spNode.addComponent('cc.ModelComponent');
|
||||
// spCom.material = cc.builtinResMgr.get('default-material');
|
||||
// spCom.material = cc.builtinResMgr.get('missing-material');
|
||||
// spCom.mesh = cc.utils.createMesh(sp);
|
||||
|
||||
cc.director.runSceneImmediate(scene);
|
||||
|
||||
Reference in New Issue
Block a user