Clone clones the Node and satisfies the INode interface.
()
| 136 | |
| 137 | // Clone clones the Node and satisfies the INode interface. |
| 138 | func (n *Node) Clone() INode { |
| 139 | |
| 140 | clone := new(Node) |
| 141 | |
| 142 | // TODO clone Dispatcher? |
| 143 | clone.Dispatcher.Initialize() |
| 144 | |
| 145 | clone.parent = n.parent |
| 146 | clone.name = n.name + " (Clone)" // TODO append count? |
| 147 | clone.loaderID = n.loaderID |
| 148 | clone.visible = n.visible |
| 149 | clone.userData = n.userData |
| 150 | |
| 151 | // Update matrix world and rotation if necessary |
| 152 | n.UpdateMatrixWorld() |
| 153 | n.Rotation() |
| 154 | |
| 155 | // Clone spatial properties |
| 156 | clone.position = n.position |
| 157 | clone.scale = n.scale |
| 158 | clone.direction = n.direction |
| 159 | clone.rotation = n.rotation |
| 160 | clone.quaternion = n.quaternion |
| 161 | clone.matrix = n.matrix |
| 162 | clone.matrixWorld = n.matrixWorld |
| 163 | clone.children = make([]INode, 0) |
| 164 | |
| 165 | // Clone children recursively |
| 166 | for _, child := range n.children { |
| 167 | clone.Add(child.Clone()) |
| 168 | } |
| 169 | |
| 170 | return clone |
| 171 | } |
| 172 | |
| 173 | // Parent returns the parent. |
| 174 | func (n *Node) Parent() INode { |
nothing calls this directly
no test coverage detected