2017-09-26 2 views
0

x3dom에서 원통을 회전하는 방법은 무엇입니까?X3dom : 원통을 회전하십시오.

그러나 API 문서에서 : API에는 세로 형 원통을 만드는 방법이 있습니다. 가로형 원통형을 만드는 방법은 무엇입니까?

코드입니다 :

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 
}); 

업데이트 : drawCylinder입니다

$.fn.addCylinder = function(oArg) { 
    this.find('scene').append($(drawCylinder(oArg))); 
}; 

은 다음과 같습니다 : 이것은 내 JS입니다

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에 그 생성 된 모습 이케이 :

<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> 

알려 주시기 바랍니다.

+0

scene3d는 코어 함수 만 포함하는 일반적인 jquery X3DOM 래퍼입니다. 다른 API와 마찬가지로 회전 기능을 비롯하여 필요한 기능을 사용하여 확장해야합니다. –

답변

3

변형 노드를 사용하여 90도 회전 할 수 있습니다. 내가 두 번 실린더를 회전 한

<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> 

: 나는 당신의 외부 기능 addCylinder과 XML이 어떻게 생겼는지 알 수 없기 때문에, 난 그냥 XML을 추가합니다. X 축을 기준으로 처음 90도 (PI/2), Z 축을 중심으로 90도 (PI/2)의 두 번째 회전.

+0

내 업데이트 –

+0

을 참조하십시오 그 밖의 무엇이 필요합니까? 내 대답은 당신이 어떻게하는지 분명히 밝히고 있습니다. 변환 노드에서 회전을 사용하십시오. 먼저 x 축을 중심으로 회전 한 다음 z 축을 회전시킵니다. 둘 다 90도 (PI/2). – mistapink

+0

오키, 고마워, 마침. –

관련 문제