Class: Collada::Parser::VisualScene

Inherits:
Object
  • Object
show all
Defined in:
lib/collada/parser/scene.rb,
lib/collada/parser/visual_scene.rb

Defined Under Namespace

Classes: ControllerInstance, GeometryInstance, Node, NodeReference

Constant Summary collapse

INSTANCE_ELEMENTS =
[
	['instance_geometry', GeometryInstance],
	['instance_controller', ControllerInstance],
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ VisualScene

Returns a new instance of VisualScene.



221
222
223
# File 'lib/collada/parser/scene.rb', line 221

def initialize(nodes = [])
	@nodes = nodes
end

Instance Attribute Details

#namedObject (readonly)

Returns the value of attribute named.



189
190
191
# File 'lib/collada/parser/visual_scene.rb', line 189

def named
  @named
end

#nodesObject (readonly)

Returns the value of attribute nodes.



225
226
227
# File 'lib/collada/parser/scene.rb', line 225

def nodes
  @nodes
end

Class Method Details

.parse(doc, element) ⇒ Object



227
228
229
230
231
232
233
234
235
# File 'lib/collada/parser/scene.rb', line 227

def self.parse(doc, element)
	nodes = []
	
	element.elements.each('node') do |element|
		nodes << Node.parse(doc, element)
	end
	
	self.new(nodes)
end

Instance Method Details

#[](id) ⇒ Object



191
192
193
# File 'lib/collada/parser/visual_scene.rb', line 191

def [] (id)
	@named[id]
end

#traverse(nodes = @nodes, &block) ⇒ Object



201
202
203
204
205
206
207
208
209
# File 'lib/collada/parser/visual_scene.rb', line 201

def traverse(nodes = @nodes, &block)
	nodes.each do |node|
		catch(:pass) do
			yield node
			
			traverse(node.children, &block)
		end
	end
end