1. 首页
  2. three.js

three.js根据鼠标位置旋转GLTF对象

大家好,n我正在尝试根据鼠标的位置旋转GLTF对象。n旋转代码基于本教程(开始使用THREE.JS2021年!-YouTube 5)第43分钟。n我正试图在GLTF上应用它,但它不起作用。n这是我的全部代码:nimport \”./style.css\”import * as THREE from \”three\”import { OrbitControls } from \”three/examples/jsm/controls/OrbitControls.js\”import { GLTFLoader } from \”three/examples/jsm/loaders/GLTFLoader.js\”import { EffectComposer } from \”three/examples/jsm/postprocessing/EffectComposer.js\”import { RenderPass } from \”three/examples/jsm/postprocessing/RenderPass.js\”import { UnrealBloomPass } from \”three/examples/jsm/postprocessing/UnrealBloomPass.js\”import * as dat from \”dat.gui\”/** *Loaders */ = new = =>{// = new THREE.PerspectiveCamera(75, sizes.width / sizes.height, = new THREE.WebGLRenderer({canvas: canvas,antialias: true})renderer.setSize(sizes.width, sizes.height)renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))/** * Post processing */ = = 0.6gui.add(unrealBloomPass, \”enabled\”)gui.add(unrealBloomPass, \”strength\”).min(0).max(2).step(0.001)gui.add(unrealBloomPass, \”radius\”).min(0).max(2).step(0.001)gui.add(unrealBloomPass, \”threshold\”).min(0).max(1).step(0.001)/** * Animate = = (event.clientX = mouseX += (.5 * (targetX – sphere.rotation.y)) * .1sphere.rotation.x += (.5 * (targetY – sphere.rotation.x)) * .1// Update Orbital Controls//controls.update()// Render//renderer.render(scene, camera)effectComposer.render()// Call tick again on the next framewindow.requestAnimationFrame(tick)}tick()n1. 请使用代码格式-没有它的代码“不太可读:”)n2. 你能再解释一下“它不起作用”是什么意思吗?哪一部分不起作用?你有什么特别的错误吗?你有没有试图指出这个问题?n可能像这样,只有头部:交互式3D角色Three.js|Codrops 16n Rotate GLTF Object Based on the Position of mousen

three.js根据鼠标位置旋转GLTF对象 为WP2原创文章,链接:https://www.wp2.cn/three-js/three-js%e6%a0%b9%e6%8d%ae%e9%bc%a0%e6%a0%87%e4%bd%8d%e7%bd%ae%e6%97%8b%e8%bd%acgltf%e5%af%b9%e8%b1%a1/