在三个js立方体的所有面上打印时钟

时间:2017-02-17 12:11:04

标签: javascript three.js

如何使用moment.js以特定格式在three.js(r84)多维数据集的所有面上打印当前日期和时间。日期和时间的格式将是这样的

moment().format('dddd') + " " + moment().format('h:mm:ss a') + " " + moment().format('LL');

小时,分钟,秒和日期应该像数字时钟一样增加。功能如下:

    this.createScene1 = function(scene, data, update) {
    update = update || 0;
    var dynamicTextures = [];
    dynamicTextures.push(_this.dynamicTextureForFaceTextAndImage(data['text1_margin_line_height'][0],data['text1_margin_line_height'][1],data['text1_bold'],data['text1_italic'],data['text1_align'],data['text1_font'],data['text1_font_size'],data['text1_font_color'],data['text1'],data['image1'],data['cube_color']));
    dynamicTextures.push(_this.dynamicTextureForFaceTextAndImage(data['text2_margin_line_height'][0],data['text2_margin_line_height'][1],data['text2_bold'],data['text2_italic'],data['text2_align'],data['text2_font'],data['text2_font_size'],data['text2_font_color'],data['text2'],data['image2'],data['cube_color']));
    dynamicTextures.push(_this.dynamicTextureForFaceTextAndImage(data['text3_margin_line_height'][0],data['text3_margin_line_height'][1],data['text3_bold'],data['text3_italic'],data['text3_align'],data['text3_font'],data['text3_font_size'],data['text3_font_color'],data['text3'],data['image3'],data['cube_color']));
    dynamicTextures.push(_this.dynamicTextureForFaceTextAndImage(data['text4_margin_line_height'][0],data['text4_margin_line_height'][1],data['text4_bold'],data['text4_italic'],data['text4_align'],data['text4_font'],data['text4_font_size'],data['text4_font_color'],data['text4'],data['image4'],data['cube_color']));
    dynamicTextures.push(_this.dynamicTextureForFaceTextAndImage(data['text5_margin_line_height'][0],data['text5_margin_line_height'][1],data['text5_bold'],data['text5_italic'],data['text5_align'],data['text5_font'],data['text5_font_size'],data['text5_font_color'],data['text5'],data['image5'],data['cube_color']));
    dynamicTextures.push(_this.dynamicTextureForFaceTextAndImage(data['text6_margin_line_height'][0],data['text6_margin_line_height'][1],data['text6_bold'],data['text6_italic'],data['text6_align'],data['text6_font'],data['text6_font_size'],data['text6_font_color'],data['text6'],data['image6'],data['cube_color']));
    var text = [];
    for (var i = 0; i < dynamicTextures.length; i++) {
        text.push(new THREE.MeshLambertMaterial({
            ambient: 0xffffff,
            map: dynamicTextures[i].texture
        }))
    }


    if (update == 1) {
        scene.remove(_this.cube);
    }


    var geo = new THREE.BoxGeometry(data['cube_width'],data['cube_height'],data['cube_depth']); // w, h, d
    _this.cube = new THREE.Mesh(geo, new THREE.MeshFaceMaterial(text));
    //var cube    = new THREE.Mesh( geo, materialText );
    _this.cube.name = "scene-1-lambert-cube";
    scene.add(_this.cube);

}

时钟值/变量将被data ['text1']参数替换。

0 个答案:

没有答案