首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >X3dom :旋转气缸

X3dom :旋转气缸
EN

Stack Overflow用户
提问于 2017-09-26 10:07:08
回答 1查看 909关注 0票数 0

如何在x3dom中旋转气缸?

但是,在API文档中:API接口中,只有如何创建垂直柱面。如何创建水平圆柱?

这是代码:

代码语言:javascript
复制
myCanvas.addCylinder({ 
  id: item.coil_no,
  x:row,  y: tier , z:(Math.abs(column)),
  radius: 0.5, 
  height:1,
  color:warna,
  onclick:'ClickHandler(this)', 'data-description' : item.coil_no, 'data-lokasi' : item.lokasi_terakhir
}); 

最新情况:

这是我的js:

代码语言:javascript
复制
$.fn.addCylinder = function( oArg) {
    this.find('scene').append( $( drawCylinder( oArg ) ) );
};

drawCylinder是:

代码语言:javascript
复制
function drawCylinder ( oArg) {
    var oAttr = {
        x:0, y:0, z:0, radius:.1, height:1, color:NODE_COLOR,
        label:'', labeloffset: 0.1,
        fontFamily:FONT_FAMILY, fontColor:FONT_COLOR, fontSize:FONT_SIZE
    };
    $.extend(true, oAttr, oArg);
    var label = (oAttr.label.length > 0) ? setLabel ( oAttr ) : '';
    var gObj = $('\
        <transform translation="' + oAttr.x + ' ' + oAttr.y + ' ' + oAttr.z + '">\
        <shape><appearance><material diffuseColor="'+hex2rgb(oAttr.color)+'"></material></appearance>\
        <Cylinder radius="'+oAttr.radius+' "height="'+oAttr.height+'"></Cylinder></shape>\
        </transform>'+label);
    if (oAttr.id) { $(gObj).find('shape').attr("id", oAttr.id); } 
    if (oAttr.onclick) { $(gObj).find('shape').attr("onclick", oAttr.onclick); } 
    $.each( oAttr, function( key, value ) {
        if (key.match("^data-")) { $(gObj).find('shape').attr(key, value); }
    });
    return gObj;
}

在xml中,生成的结果如下所示:

代码语言:javascript
复制
<transform translation="1 1 1" render="true" bboxcenter="0,0,0" bboxsize="-1,-1,-1" center="0,0,0" rotation="0,0,0,0"
       scale="1,1,1" scaleorientation="0,0,0,0">
<shape id="DNA07X1A518081734A" onclick="ClickHandler(this)" data-description="DNA07X1A518081734A" data-lokasi="111"
       render="true" bboxcenter="0,0,0" bboxsize="-1,-1,-1" ispickable="true">
    <appearance sorttype="auto" alphaclipthreshold="0.1">
        <material diffusecolor="1,0,1" ambientintensity="0.2" emissivecolor="0,0,0" shininess="0.2"
                  specularcolor="0,0,0"></material>
    </appearance>
    <cylinder radius="0.5 " height="1" solid="true" ccw="true" usegeocache="true" lit="true" bottom="true"
              top="true" subdivision="32" side="true"></cylinder>
</shape>

请给我建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-27 07:49:34

您可以使用转换节点并将其旋转90度。由于我不知道您的外部函数addCylinder和XML是什么样子,所以我只添加了XML:

代码语言:javascript
复制
<x3d id="x3dElement" style="width:100%; height:100%; border:0" width="1355px" height="826px">
    <scene>
        <transform rotation="1 0 0 -1.57">
            <transform rotation="0 0 1 1.57">
                <shape>
                    <appearance>
                        <material diffusecolor="0 1 1" ambientintensity="0.2" emissivecolor="0,0,0" shininess="0.2" specularcolor="0,0,0"></material>
                    </appearance>
                    <cylinder radius="1" height="2"></cylinder>
                </shape>
            </transform>
        </transform>
    </scene>
</x3d>

我把汽缸旋转了两次。首先是围绕X轴的90度(PI/2),然后是围绕Z轴的90度的第二次旋转(PI/2)。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46423513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档