我創建的線框球體對象,但我堅持我想要定義的頂點和應用back-face culling來襲用於創建的線框球體對象。
任何人都可以請幫忙嗎?以及如何定義線框球體對象的頂點?我想設置背面剔除了我的領域對象,但我在定義頂點我線框球體對象
我的HTML文件:這裏我使用的是three.js庫,因爲我是WebGL的新手我無法對此問題做些什麼。
<html>
<head>
<title> Construct a sphere model in WebGL </title>
<script src ="./three.js-master/three.js-master/build/three.js"></script>
<script src ="./three.js-master/three.js-master/build/three.min.js"></script>
<script type="text/javascript" src="Three.js"></script>
</head>
<body onload="createsphere()">
<canvas id="glcanvas" width="840" height="620"></canvas>
</body>
</html>
Three.js是我的JavaScript文件鏈接。
function createsphere() {
var pos = function(d) { return document.getElementById(d); };
//def scene, camera, renderer
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);
//creating a sphere object
var spheregeometry = new THREE.SphereGeometry(1.0, 30, 30);
var texture = THREE.ImageUtils.loadTexture('earth.jpg', {}, function() { alert('texture loaded');}, function(){ alert('error loading texture');});
var spherematerial = new THREE.MeshBasicMaterial({wireframe: true, map: texture});
var sphere = new THREE.Mesh(spheregeometry, spherematerial);
scene.add(sphere);
camera.position.z = 5;
//renderer
var render = function(e) {
requestAnimationFrame(render);
renderer.render(scene, camera);
};
render();
}
歡迎來到Stack Overflow!你能否提供更多細節?屏幕截圖,錯誤堆棧跟蹤等。 – naXa
正如我所想的,您正在使用[three.js](http://threejs.org)庫並詢問[MeshBasicMaterial](http://threejs.org/docs/#Reference /材料/ MeshBasicMaterial)。請將其納入您的問題中。有很多人可以幫助你,他們不應該花時間去猜測重要的細節。 – naXa
是的,我使用three.js庫,在這裏我也加我的html文件 – sravan