Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

相机不能设置旋转? #50

Open
wanghepu opened this issue Apr 21, 2024 · 0 comments
Open

相机不能设置旋转? #50

wanghepu opened this issue Apr 21, 2024 · 0 comments

Comments

@wanghepu
Copy link

function init(canvas): void {
clock = new Clock()
fbxLoader = new FBXLoader()
platform = new WechatPlatform(canvas) // webgl canvas
platform.enableDeviceOrientation('game') // 开启DeviceOrientation
PLATFORM.set(platform)
renderer = new WebGLRenderer({
canvas,
// context: canvas.getContext('webgl'),
// alpha: true,
antialias: true
})
// renderer.setClearAlpha(.6)
console.log('renderer', renderer.getClearAlpha(), renderer.getClearColor(new THREE.Color()))
// renderer.setClearColor(new THREE.Color(0,0,0),0)
const sizeVec2 = new THREE.Vector2()
renderer.getDrawingBufferSize(sizeVec2)
// 创建一个纹理,用于存储视频帧数据
dataTexture = new THREE.DataTexture(null, sizeVec2.x, sizeVec2.y)
dataTexture.format = THREE.RGBAFormat
dataTexture.type = THREE.UnsignedByteType
dataTexture.needsUpdate = true

console.log(canvas.requestAnimationFrame)
// renderer.setPixelRatio(devicePixelRatio)
renderer.outputEncoding = sRGBEncoding
const width = canvas.width
const height = canvas.height
scene = new Scene()
// scene.background = new Color(0xbfe3dd)
const aspectRatio = width / height
camera = new PerspectiveCamera(75, aspectRatio, 0.001, 1000)
camera.position.z = 10
controlls = new OrbitControls(camera, renderer.domElement)
// controlls.autoRotate = true
controlls.enableDamping = true
// controlls.maxZoom = 3
addLight(scene)
const size = 10
const divisions = 10
const gridHelper = new GridHelper(size, divisions)
gridHelper.name = 'GridHelper'
scene.add(gridHelper)
clock.start()
const renderScene = new RenderPass(scene, camera)
finalComposer = new FinalComposer(dataTexture, renderer)
finalComposer.addPass(renderScene)
finalComposer.addPass(finalComposer.finalPass)
euler.set(0,Math.PI/ 2,0)
// camera.quaternion.setFromEuler(euler)
// camera.rotation.setFromQuaternion(camera.quaternion)
camera.rotation.y = 1.2
camera.lookAt(new THREE.Vector3(0,200,0))
startGyroscope()

}
function animate() {
if (!canvas) return
renderId = canvas.requestAnimationFrame(animate)
controlls.update()
renderer.render(scene, camera)
// finalComposer.render()
}
设置的相机旋转不生效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant