function createTween (params) {
new TWEEN.Tween(params.object) .to(params.to, params.duration) .onComplete(() => onComplete()) .onUpdate(params.onUpdate) .easing(params.easing) .start() } function onComplete() { console.log("onComplete") } var tweenParams = { targetTweenDuration: 2500, posTweenDuration: 2500, upTweenDuration: 2500, targetTweenEasing: { id: TWEEN.Easing.Quadratic.Out, name: "Linear" }, posTweenEasing: { id: TWEEN.Easing.Quadratic.Out, name: "Linear" }, upTweenEasing: { id: TWEEN.Easing.Quadratic.Out, name: "Linear" }, configManager: null, showLoader: true }
function tweenCameraTo (state, immediate) {
immediate = false; const targetEnd = new THREE.Vector3( state.viewport.target[0], state.viewport.target[1], state.viewport.target[2]) const posEnd = new THREE.Vector3( state.viewport.eye[0], state.viewport.eye[1], state.viewport.eye[2]) const upEnd = new THREE.Vector3( state.viewport.up[0], state.viewport.up[1], state.viewport.up[2]) const nav = viewer.navigation const target = new THREE.Vector3().copy( nav.getTarget()) const pos = new THREE.Vector3().copy( nav.getPosition()) const up = new THREE.Vector3().copy( nav.getCameraUpVector()) const targetTween = createTween({ easing: tweenParams.targetTweenEasing.id, onUpdate: (v) => { nav.setTarget(v) }, duration: immediate ? 0 : tweenParams.targetTweenDuration, object: target, to: targetEnd }) const posTween = this.createTween({ easing: tweenParams.posTweenEasing.id, onUpdate: (v) => { nav.setPosition(v) }, duration: immediate ? 0 :tweenParams.posTweenDuration, object: pos, to: posEnd }) const upTween = this.createTween({ easing: tweenParams.upTweenEasing.id, onUpdate: (v) => { nav.setCameraUpVector(v) }, duration: immediate ? 0 : tweenParams.upTweenDuration, object: up, to: upEnd }) Promise.all([ targetTween, posTween, upTween]).then(() => { animate = false console.log(11111) }) } // function animate(time) { // requestAnimationFrame(animate); // TWEEN.update(time); // console.log(1) // } // requestAnimationFrame(animate); function runAnimation (start) { if (start || animate) { this.animId = window.requestAnimationFrame( runAnimation) Tween.update() } }
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/103991.html
摘要:的粒子就不再舉例,和用于的例子差不多,相信大家能夠很快搞定。開(kāi)始使用吧官方網(wǎng)站地址最后,多謝大家對(duì)的建議,有了你們中肯建議和意見(jiàn),才讓它變得更好更靈活更強(qiáng)大。 原文鏈接:https://github.com/AlloyTeam/AlloyTouch/wiki/Powerful-transformjs 寫(xiě)在前面 上星期在React微信群里,有小伙伴覺(jué)得transformjs直接給DOM添...
摘要:的粒子就不再舉例,和用于的例子差不多,相信大家能夠很快搞定。開(kāi)始使用吧官方網(wǎng)站地址最后,多謝大家對(duì)的建議,有了你們中肯建議和意見(jiàn),才讓它變得更好更靈活更強(qiáng)大。 原文鏈接:https://github.com/AlloyTeam/AlloyTouch/wiki/Powerful-transformjs 寫(xiě)在前面 上星期在React微信群里,有小伙伴覺(jué)得transformjs直接給DOM添...
閱讀 2587·2023-04-26 03:00
閱讀 1402·2021-10-12 10:12
閱讀 4197·2021-09-22 15:33
閱讀 2923·2021-09-22 15:06
閱讀 1536·2019-08-30 15:44
閱讀 2150·2019-08-30 13:59
閱讀 536·2019-08-30 11:24
閱讀 2415·2019-08-29 17:07