diff --git a/cocos/3d/assets/material.ts b/cocos/3d/assets/material.ts index 718caf9e55..fd9e739fab 100644 --- a/cocos/3d/assets/material.ts +++ b/cocos/3d/assets/material.ts @@ -207,7 +207,8 @@ export class Material extends Asset { protected _update (keepProps: boolean = true) { const asset = this._effectAsset; - if (!asset) { this._passes = builtinResMgr.get('default-material')._passes.slice(); return; } + // ugly yellow indicating missing effect + if (!asset) { this._passes = builtinResMgr.get('missing-effect-material')._passes.slice(); return; } // create passes this._passes = Effect.parseEffect(asset, { techIdx: this._techIdx, diff --git a/cocos/3d/builtin/init.ts b/cocos/3d/builtin/init.ts index 59bc2d6131..fd121e6650 100644 --- a/cocos/3d/builtin/init.ts +++ b/cocos/3d/builtin/init.ts @@ -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(); diff --git a/cocos/3d/framework/model-component.ts b/cocos/3d/framework/model-component.ts index c27ef4da4b..1a7dbd93c9 100644 --- a/cocos/3d/framework/model-component.ts +++ b/cocos/3d/framework/model-component.ts @@ -284,6 +284,6 @@ export class ModelComponent extends RenderableComponent { private _getBuiltinMaterial () { // classic ugly pink indicating missing material - return builtinResMgr.get('default-material'); + return builtinResMgr.get('missing-material'); } } diff --git a/cocos/3d/geom-utils/ray.ts b/cocos/3d/geom-utils/ray.ts index 421bc40790..08e0db4f3b 100644 --- a/cocos/3d/geom-utils/ray.ts +++ b/cocos/3d/geom-utils/ray.ts @@ -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); } diff --git a/cocos/3d/geom-utils/triangle.ts b/cocos/3d/geom-utils/triangle.ts index f221ac30f6..2db49b5c88 100644 --- a/cocos/3d/geom-utils/triangle.ts +++ b/cocos/3d/geom-utils/triangle.ts @@ -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); } diff --git a/cocos/renderer/scene/model.ts b/cocos/renderer/scene/model.ts index 054df30e0d..eaf18cfb5c 100644 --- a/cocos/renderer/scene/model.ts +++ b/cocos/renderer/scene/model.ts @@ -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; diff --git a/cocos/renderer/scene/render-scene.ts b/cocos/renderer/scene/render-scene.ts index 4c599d0d41..46d885b65e 100644 --- a/cocos/renderer/scene/render-scene.ts +++ b/cocos/renderer/scene/render-scene.ts @@ -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(() => { + return { node: null!, distance: Infinity }; }, 8); const results: IRaycastResult[] = []; diff --git a/playground/planarShadow.html b/playground/planarShadow.html index 8a73ee44cf..2cc9ab0495 100644 --- a/playground/planarShadow.html +++ b/playground/planarShadow.html @@ -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);