(camera, initCamreaMode)
| 74 | class ViewControls { |
| 75 | |
| 76 | constructor(camera, initCamreaMode) { |
| 77 | |
| 78 | this.camera = camera; |
| 79 | this.camera.rotation.order = "YXZ"; |
| 80 | |
| 81 | // current status |
| 82 | this.currentRot = new THREE.Vector3(); |
| 83 | this.currentVp = new THREE.Vector3(); |
| 84 | this.currentDist = 20; |
| 85 | |
| 86 | this.tau = 0.15; // Time parameter, half-life. |
| 87 | |
| 88 | this.allMethod = []; |
| 89 | |
| 90 | let aboveFix = new ControlMethod("Above_fix"); |
| 91 | aboveFix.setUpdateCallback(function (dx, dy, th, ph) { |
| 92 | this.vp.copy(this.frameCenter); |
| 93 | |
| 94 | let x = this.frameEye.x; |
| 95 | let z = this.frameEye.z; |
| 96 | |
| 97 | this.baseTh = Math.atan2(x, z); |
| 98 | this.basePh = -Math.PI / 2; |
| 99 | this.th = 0; |
| 100 | this.ph = 0; |
| 101 | this.ps = 0; |
| 102 | }); |
| 103 | this.allMethod.push(aboveFix); |
| 104 | |
| 105 | let aboveRot = new ControlMethod("Above_rot"); |
| 106 | aboveRot.setUpdateCallback(function (dx, dy, th, ph) { |
| 107 | this.vp.copy(this.frameCenter); |
| 108 | |
| 109 | let x = this.frameEye.x; |
| 110 | let z = this.frameEye.z; |
| 111 | |
| 112 | this.baseTh = Math.atan2(x, z); |
| 113 | this.basePh = -Math.PI / 2; |
| 114 | this.th += th; |
| 115 | this.ph = 0; |
| 116 | this.ps = 0; |
| 117 | }); |
| 118 | this.allMethod.push(aboveRot); |
| 119 | |
| 120 | const angle = Math.PI / 4; |
| 121 | let followFix = new ControlMethod("Follow_fix"); |
| 122 | followFix.setInitialRot(0, -Math.PI / 2 + angle, 0); |
| 123 | followFix.setUpdateCallback(function (dx, dy, th, ph) { |
| 124 | this.vp.copy(this.frameCenter); |
| 125 | |
| 126 | let x = this.frameEye.x; |
| 127 | let z = this.frameEye.z; |
| 128 | this.baseTh = Math.atan2(x, z); |
| 129 | this.basePh = -Math.PI / 2 + angle; |
| 130 | this.th = 0; |
| 131 | this.ph = 0; |
| 132 | this.ps = 0; |
| 133 |
nothing calls this directly
no test coverage detected