-
Notifications
You must be signed in to change notification settings - Fork 3
/
SolarArray.js
47 lines (43 loc) · 2.11 KB
/
SolarArray.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as tram from './tram.js'
export class virtualSolarArray {
constructor(positionInFrameOfReference, unallocatedModelsArray) {
this.p = positionInFrameOfReference
this.unallocatedModels = unallocatedModelsArray
}
// The following properties are common to all virtual habitats...
static currentEquivalentLatitude
static solarArrayRotZ
static isVisible
static isDynamic
static hasChanged
static update(dParamWithUnits, crv) {
const solarArrayOutwardOffset = dParamWithUnits['solarArrayOutwardOffset'].value
const solarArrayUpwardOffset = dParamWithUnits['solarArrayUpwardOffset'].value
virtualSolarArray.solarArrayRelativePosition_r = tram.offset_r(solarArrayOutwardOffset, solarArrayUpwardOffset, crv.currentEquivalentLatitude)
virtualSolarArray.solarArrayRelativePosition_y = tram.offset_y(solarArrayOutwardOffset, solarArrayUpwardOffset, crv.currentEquivalentLatitude)
virtualSolarArray.currentEquivalentLatitude = crv.currentEquivalentLatitude
virtualSolarArray.solarArrayRotZ = crv.currentEquivalentLatitude - Math.PI/2
virtualSolarArray.isVisible = dParamWithUnits['showSolarArrays'].value
virtualSolarArray.isDynamic = false
virtualSolarArray.hasChanged = true
}
placeAndOrientModel(om, refFrame, wedgeToCameraDistance) {
const modelsTrackPosition = (this.p + refFrame.p) % 1
if (modelsTrackPosition==='undefined' || (modelsTrackPosition<0) || (modelsTrackPosition>1)) {
console.log("error!!!")
}
else {
const pointOnRingCurve = refFrame.curve.getPoint(modelsTrackPosition)
const angle = 2 * Math.PI * modelsTrackPosition
om.position.set(
pointOnRingCurve.x + virtualSolarArray.solarArrayRelativePosition_r * Math.cos(angle),
pointOnRingCurve.y + virtualSolarArray.solarArrayRelativePosition_y,
pointOnRingCurve.z + virtualSolarArray.solarArrayRelativePosition_r * Math.sin(angle))
om.rotation.set(0, -angle, virtualSolarArray.solarArrayRotZ)
om.rotateX(-Math.PI/4)
om.visible = virtualSolarArray.isVisible
om.matrixValid = false
if (this.perfOptimizedThreeJS) om.freeze()
}
}
}