diff options
Diffstat (limited to 'o3d/samples/o3djs/material.js')
-rw-r--r-- | o3d/samples/o3djs/material.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/o3d/samples/o3djs/material.js b/o3d/samples/o3djs/material.js index db1449d..8ef180c 100644 --- a/o3d/samples/o3djs/material.js +++ b/o3d/samples/o3djs/material.js @@ -337,6 +337,47 @@ o3djs.material.createBasicMaterial = function(pack, }; /** + * This function creates 2 color procedureal texture material. + * + * @see o3djs.material.createBasicMaterial + * + * @param {!o3d.Pack} pack Pack to manage created objects. + * @param {!o3djs.rendergraph.ViewInfo} viewInfo as returned from + * o3djs.rendergraph.createBasicView. + * @param {!o3djs.math.Vector4} opt_color1 a color in the format [r, g, b, a]. + * Defaults to a medium blue-green. + * @param {!o3djs.math.Vector4} opt_color2 a color in the format [r, g, b, a]. + * Defaults to a light blue-green. + * @param {boolean} opt_transparent Whether or not the material is transparent. + * Defaults to false. + * @param {number} opt_checkSize Defaults to 10 units. + * @return {!o3d.Material} The created material. + */ +o3djs.material.createCheckerMaterial = function(pack, + viewInfo, + opt_color1, + opt_color2, + opt_transparent, + opt_checkSize) { + opt_color1 = opt_color1 || [0.4, 0.5, 0.5, 1]; + opt_color2 = opt_color2 || [0.4, 0.8, 0.8, 1]; + opt_checkSize = opt_checkSize || 10; + + var effect = o3djs.effect.createCheckerEffect(pack); + var material = pack.createObject('Material'); + material.effect = effect; + material.drawList = opt_transparent ? viewInfo.zOrderedDrawList : + viewInfo.performanceDrawList; + o3djs.effect.createUniformParameters(pack, effect, material); + + material.getParam('color1').value = opt_color1; + material.getParam('color2').value = opt_color2; + material.getParam('checkSize').value = opt_checkSize; + + return material; +}; + +/** * Creates a material for an effect loaded from a file. * If the effect has already been loaded in the pack it will be reused. * @param {!o3d.Pack} pack Pack to create effect in. |