簡體   English   中英

如何在three.js中導入VRML文件?

[英]How to import VRML Files in three.js?

我正在嘗試在Three.js中導入VRML文件,但是它不起作用。 這是VRML文件:

#VRML V2.0 utf8

#Created by CINEMA 4D

DEF B1 Transform {
 translation 600 0 0.333333
 children [ 
 DEF _60_ Transform {
  translation -600 0 0
  children [ 
  ]
}
DEF Button Transform {
  translation 679.734143 0 0
  children [ 
    Shape {
      appearance DEF MAT_Metal_010 Appearance {
        material Material {
          ambientIntensity 0.2
          diffuseColor 0.815686 0 0.223529
          specularColor 0 0 0
          emissiveColor 0 0 0
          shininess 0.1
          transparency 0
        }
      }
      geometry DEF FACESET_Button IndexedFaceSet {
        ccw FALSE
        creaseAngle 1.396263
        coord Coordinate {
          point [ -100 -100 -100,-100 100 -100,-100 -100 100,-100 100 100,100 -100 100,
            100 100 100,100 -100 -100,100 100 -100
          ]
        }
        texCoord TextureCoordinate {
          point [ 0 1,1 0,
            0 0,0 0,1 1,0 1,1 1,
            0 0,1 0,1 0,0 1,1 1,
            1 0,0 0,1 1,0 1,0 0,
            1 0,0 1,1 1
          ]
        }
        coordIndex [ 0,1,3,2,-1,2,3,5,4,-1,4,5,7,6,-1,
          6,7,1,0,-1,1,7,5,3,-1,6,0,2,4,-1
        ]
        texCoordIndex [ 2,5,11,8,-1,7,10,14,12,-1,13,15,19,17,-1,
          16,18,4,1,-1,3,18,14,9,-1,16,0,6,12,-1
        ]
      }
    }
  ]
 }
]
}
DEF Timer TimeSensor {
startTime 0
stopTime 0
cycleInterval 14.4
loop TRUE
}

這是我用於導入的JavaScript代碼:

var loader = new THREE.VRMLLoader();
loader.addEventListener( 'load', function ( event ) {
    scene.add(event.content);
    } );
loader.load( "models/MyVRML.wrl" );

瀏覽器中的錯誤消息是:

TypeError:a是未定義的three.js:1636。

我使用實際的three.js(未縮小)

謝謝你的幫助!

現在,您的觀點應該各有千秋。 我願意解決此問題,但目前面臨緊迫的期限。 現在的解決方法是像這樣設置坐標:

coord  Coordinate { #default NULL
    point [
        0.14    0   -0.14,
        5.54    0   -0.14,
        5.54    0   -8.86,
        0.14    0   -8.86,
    ]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM