簡體   English   中英

如何修復Three.js Cube細線框?

[英]How to fix Three.js Cube thin wireframe?

問題 :我創建的Three.js 3d多維數據集啟用了線框或輪廓模式屬性。 它可以在台式機/平板電腦上正常工作,但是如果僅限於移動設備,它會變得非常薄且無法使用。 我想阻止這種情況的發生,並保持相同的台式機/平板電腦線框重量,但也適用於移動設備。

示例:以下是演示此行為的屏幕截圖的列表。

  • 桌面(僅限於在Chrome瀏覽器中模仿iPhone 6尺寸)-

在此處輸入圖片說明

  • 移動版(iOS chrome瀏覽器中的實際iPhone 6尺寸)-

在此處輸入圖片說明

這是我當前的代碼:

 var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); //makes the site responsive window.addEventListener('resize', function(){ var width = window.innerWidth; var height = window.innerHeight; renderer.setSize(width, height); camera.aspect = width / height; camera.updateProjectionMatrix(); }); var geometry = new THREE.BoxGeometry( 1.5, 1.5, 1.5 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00, wireframe: true } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); camera.position.z = 5; function render() { requestAnimationFrame( render ); cube.rotation.x += 0.025; cube.rotation.y += 0.025; renderer.render( scene, camera ); } render(); 
 html,body { margin: 0; overflow: hidden; } canvas { width: 100%; height: 100%; background-color: black; } h1 { font-family: 'Maven Pro', sans-serif; font-size: 3em; } p { font-family: 'Lato', sans-serif; font-size: 1em; } #textthing { position: absolute; margin-bottom: 60px; color: #00FF00; /**height: 90%;**/ width:100%; text-align: center; bottom: 0; } 
 <link href='https://fonts.googleapis.com/css?family=Maven+Pro' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Lato:400,300' rel='stylesheet' type='text/css'> <div id="textthing"> <h1>weeflix LLC</h1> <!--<h2>Coming soon.</h2>--> <p>Jake Schnieder || Thomas Bisnitsz</p> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r77/three.min.js"></script> 

嘗試將此行添加到您的<head>部分

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

請參閱此MDN文章以了解viewport設置

暫無
暫無

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

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