咨询camera.add(this.obj)显示不出图形的问题
来源:5-14 scene和camera的设置

慕工程053222
2019-05-03
开始界面的的绘制的时候,老师把PlaneGeometry生成的mesh:this.obj加到了camera里。
camera.add(this.obj)
我在自己长是threejs的里的时候,按照threejs的example写法把mesh加到scene里可以显示出来图形。
按照老师的写法把mesh加到camera里,然后scene.add(camera)
这样的写法就显示不出来图形。
老师,你知道我这可能是什么问题么?
下面跳一跳里面startPage的部分代码。
this.camera = options.camera
this.canvas = document.createElement(‘canvas’)
this.canvas.width = window.innerWidth
this.canvas.height = window.innerHeight
this.texture = new THREE.Texture(this.canvas)
this.material = new THREE.MeshBasicMaterial({ map: this.texture, transparent: true });
this.geometry = new THREE.PlaneGeometry(sceneConf.frustumSize * 2, aspect * sceneConf.frustumSize * 2)
this.obj = new THREE.Mesh(this.geometry, this.material)
this.obj.position.z = 60
this.context = this.canvas.getContext(‘2d’)
this.context.fillStyle = 'rgba(0,0,0,0.3)'
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height)
const titleImage = wx.createImage()
titleImage.src = 'res/images/title.png’
titleImage.onload = () => {
this.context.drawImage(titleImage, (this.canvas.width - 200) / 2, 150, 200, 55)
this.texture.needsUpdate = true
}
const startImage = wx.createImage()
startImage.src = 'res/images/play.png’
startImage.onload = () => {
this.context.drawImage(startImage, (this.canvas.width - 200) / 2, (window.innerHeight - 100) / 2 + 200, 200, 85)
this.texture.needsUpdate = true
}
this.texture.needsUpdate = true
this.camera.add(this.obj)
1回答
-
千迦
2019-05-07
你可以参考一下课程提供的源码改一下,你这个代码我也看看
00
相似问题