0

我对 Three.js 和 Thingiview.js(来自 Three.js)有疑问。我与这两个库/脚本有冲突。(我认为是three.js 和three.min.js 文件)。在这里,我只能拥有 50% 的脚本:s

我想要做的是用thingiview 显示我的场景并用three.js 计算边界框。

我希望你知道解决这种冲突的方法。我已经度过了一整天:(

这是我调用的代码:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script src="thingview/javascripts/Three.js"></script>
<script src="thingview/javascripts/thingiview.js"></script>
<script>
  var modele = document.getElementById('modele3d').value; 

    window.onload = function() {
      // You may want to place these lines inside an onload handler
      CFInstall.check({
        mode: "inline", // the default
        node: "prompt"
      });

      thingiurlbase = "";
      thingiview = new Thingiview("viewer");
      thingiview.setObjectColor('#e4e5e6');
      thingiview.initScene();
      thingiview.loadSTL('../../images/'+modele);
      log(thingiview.objectColor);
    }

</script>
<div id="viewer" style="width:400px;height:300px;margin:auto;position:relative;border:5px solid white;border-radius:5px;"></div>




<script src="scripts/three.min.js"></script>
<script src="three/js/loaders/STLLoader.js"></script>
<script src="three/js/Detector.js"></script>
<script>
   var loader = new THREE.STLLoader();
        loader.addEventListener( 'load', function ( event ) {
          var geometry = event.content;
          var material = new THREE.MeshLambertMaterial( { color: 0xd0d1d2, shininess: 5 } );
          var mesh = new THREE.Mesh(geometry, material );   
          // Recherche et envoi des tailles //
          geometry.computeBoundingBox();
          var largeur = (mesh.geometry.boundingBox.max.x)- (mesh.geometry.boundingBox.min.x);
          var hauteur = (mesh.geometry.boundingBox.max.y)-(mesh.geometry.boundingBox.min.y);
          var profondeur = (mesh.geometry.boundingBox.max.z)-(mesh.geometry.boundingBox.min.z);

          var tailles = largeur + " " + hauteur + " " + profondeur;

          var prix  = document.getElementById('prototype_prix').value;
          if(prix==0){
          document.getElementById('prototype_taille1').value = (Math.round(largeur*100))/100;
          document.getElementById('prototype_taille2').value = (Math.round(hauteur*100))/100;
          document.getElementById('prototype_taille3').value = (Math.round(profondeur*100))/100;
          document.getElementById('prototype_taille1_base').value = largeur;  
          document.getElementById('prototype_taille2_base').value = hauteur;
          document.getElementById('prototype_taille3_base').value = profondeur; 
          }     

        } );
        loader.load( 'images/'+modele);
</script>
4

0 回答 0