(node core.INode)
| 115 | type PositionChannel NodeChannel |
| 116 | |
| 117 | func NewPositionChannel(node core.INode) *PositionChannel { |
| 118 | |
| 119 | pc := new(PositionChannel) |
| 120 | pc.target = node |
| 121 | pc.updateInterpAction = func() { |
| 122 | // Get node |
| 123 | node := pc.target.GetNode() |
| 124 | // Update interpolation function |
| 125 | switch pc.interpType { |
| 126 | case STEP: |
| 127 | pc.interpAction = func(idx int, k float32) { |
| 128 | var v math32.Vector3 |
| 129 | pc.values.GetVector3(idx*3, &v) |
| 130 | node.SetPositionVec(&v) |
| 131 | } |
| 132 | case LINEAR: |
| 133 | pc.interpAction = func(idx int, k float32) { |
| 134 | var v1, v2 math32.Vector3 |
| 135 | pc.values.GetVector3(idx*3, &v1) |
| 136 | pc.values.GetVector3((idx+1)*3, &v2) |
| 137 | v1.Lerp(&v2, k) |
| 138 | node.SetPositionVec(&v1) |
| 139 | } |
| 140 | case CUBICSPLINE: // TODO |
| 141 | pc.interpAction = func(idx int, k float32) { |
| 142 | var v1, v2 math32.Vector3 |
| 143 | pc.values.GetVector3(idx*3, &v1) |
| 144 | pc.values.GetVector3((idx+1)*3, &v2) |
| 145 | v1.Lerp(&v2, k) |
| 146 | node.SetPositionVec(&v1) |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | pc.SetInterpolationType(LINEAR) |
| 151 | return pc |
| 152 | } |
| 153 | |
| 154 | // RotationChannel is the animation channel for a node's rotation. |
| 155 | type RotationChannel NodeChannel |
no test coverage detected