import {Utils} from "../../utils.js"; export class CameraAnimationPanel{ constructor(viewer, propertiesPanel, animation){ this.viewer = viewer; this.propertiesPanel = propertiesPanel; this.animation = animation; this.elContent = $(`
Duration: Time:
`); const elPlay = this.elContent.find("input[name=play]"); elPlay.click( () => { animation.play(); }); const elPause = this.elContent.find("input[name=pause]"); elPause.click( () => { animation.pause(); }); const elSlider = this.elContent.find('#sldTime'); elSlider.slider({ value: 0, min: 0, max: 1, step: 0.001, slide: (event, ui) => { animation.set(ui.value); animation.updateFrustum() } }); let elDuration = this.elContent.find(`input[name=spnDuration]`); elDuration.spinner({ min: 0, max: 300, step: 0.01, numberFormat: 'n', start: () => {}, spin: (event, ui) => { let value = elDuration.spinner('value'); animation.setDuration(value); }, change: (event, ui) => { let value = elDuration.spinner('value'); animation.setDuration(value); }, stop: (event, ui) => { let value = elDuration.spinner('value'); animation.setDuration(value); }, incremental: (count) => { let value = elDuration.spinner('value'); let step = elDuration.spinner('option', 'step'); let delta = value * 0.05; let increments = Math.max(1, parseInt(delta / step)); return increments; } }); elDuration.spinner('value', animation.getDuration()); elDuration.spinner('widget').css('width', '100%'); const elKeyframes = this.elContent.find("#animation_keyframes"); const updateKeyframes = () => { elKeyframes.empty(); //let index = 0; // // // const addNewKeyframeItem = (index) => { let elNewKeyframe = $(`
`); const elAdd = elNewKeyframe.find("input[name=add]"); elAdd.click( () => { animation.createControlPoint(index, { position: viewer.scene.view.position, target: viewer.scene.view.getPivot() }); animation.changeCallback() }); elKeyframes.append(elNewKeyframe); }; const addKeyframeItem = (index) => { let elKeyframe = $(`
keyframe
`); const elAssign = elKeyframe.find("img[name=assign]"); const elMove = elKeyframe.find("img[name=move]"); const elDelete = elKeyframe.find("img[name=delete]"); elAssign.click( () => { //修改 animation.posCurve.points[index].copy(viewer.scene.view.position); animation.targets[index].position.copy(viewer.scene.view.getPivot()); animation.changeCallback(index) }); elMove.click( () => { viewer.scene.view.position.copy(animation.posCurve.points[index]); viewer.scene.view.lookAt(animation.targets[index].position); }); elDelete.click( () => { animation.removeControlPoint(index); animation.changeCallback() }); elKeyframes.append(elKeyframe); }; let index = 0; addNewKeyframeItem(index); animation.posCurve.points.forEach(e=>{ addKeyframeItem(index); index++; addNewKeyframeItem(index); }) }; updateKeyframes(); animation.addEventListener("controlpoint_added", updateKeyframes); animation.addEventListener("controlpoint_removed", updateKeyframes); // this._update = () => { this.update(); }; // this.update(); } update(){ } };