MCPcopy
hub / github.com/g3n/engine / Clone

Method Clone

core/node.go:138–171  ·  view source on GitHub ↗

Clone clones the Node and satisfies the INode interface.

()

Source from the content-addressed store, hash-verified

136
137// Clone clones the Node and satisfies the INode interface.
138func (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.
174func (n *Node) Parent() INode {

Callers

nothing calls this directly

Calls 5

UpdateMatrixWorldMethod · 0.95
RotationMethod · 0.95
CloneMethod · 0.65
InitializeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected