以下一些previous post on stackoverflow我試圖在我的畫布中添加標籤。 我做了第二個場景和第二個相機,以在第一個場景上重疊我的標籤。Threejs添加標籤
this.sceneOrtho = new THREE.Scene();//for labels
this.scene = new THREE.Scene();// for Geometry
//camera for geometry
var SCREEN_WIDTH = window.innerWidth-5, SCREEN_HEIGHT = window.innerHeight-5;
var VIEW_ANGLE = 45, ASPECT = SCREEN_WIDTH/SCREEN_HEIGHT, NEAR = 0.1, FAR = 20;
this.camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
var r = 4, phi = Math.PI/4, theta = Math.PI/4;
this.camera.position.set(r*Math.cos(phi)*Math.sin(theta),r*Math.sin(phi), r*Math.cos(phi)*Math.cos(theta));
this.camera.lookAt(new THREE.Vector3(0, 0, 0));
// camera for labels
this.cameraOrtho = new THREE.OrthographicCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
this.cameraOrtho.position.z = 10;
我還添加了THREE.Sprite對象現場sceneOrtho.add(spritey);
並呈現this.model.clearScene(this.scene); this.model.populateScene(this.scene,this.sceneOrtho);//<-------- this.renderer.clear(); this.renderer.render(this.scene, this.camera); this.renderer.clearDepth(); this.renderer.render(this.sceneOrtho, this.cameraOrtho);
,但我只能看到的幾何形狀,而不是我的標籤。 這裏有一個現場example點擊按鈕測試看看它。
您現在太快過敏了。提出對別人有用的問題。詢問關於three.js的問題,並避免help-me-debug-my-code問題。在這種情況下,你應該能夠找到自己的錯誤。 – WestLangley
你是對的,但是我認爲我無法找到這段代碼有什麼問題@WestLangley –
也許這個例子是你在做什麼? http://threejs.org/examples/webgl_loader_pdb.html – mrdoob