What steps will reproduce the problem?
1. Read tutorial & docs, which say that a shape is "a collection of primitives"
(see the diagrams for Materials and Effects under
http://code.google.com/apis/o3d/docs/techoverview.html#whatisscenegraph,
and http://code.google.com/apis/o3d/docs/devguidechap02.html#shapes).
2. Try to create a shape with multiple primitives such as cubes, cylinders, etc.
3. Find that this is done in the samples with e.g.
o3djs.primitives.createCylinder(), but that function returns a shape, not just
a primitive.
What is the expected output? What do you see instead?
Research further and discover there is apparently no straightforward way to do
this; you must either (a) create multiple shapes, excise their elements and
discard the extra shapes (counterintuitive, plus extra garbage collection
overhead); or
(b) duplicate a fairly long stretch of code used for creating a primitive
(VertexInfoBase.prototype.createShapeByType()), except for a couple of lines
related to wrapping it in a shape.
The attached patch adds VertexInfo.createPrimitiveByType(), which would allow
the developer to create multiple primitives individually, then easily wrap them
in a shape. It would also allow current samples and others who have the common
one-primitive-per-shape use case to continue using the
convenient VertexInfo.createShape(). (The patch makes the existing
createShapeByType() into a short wrapper for createPrimitiveByType().)
(The patch is tested against the "Primitives" sample.)
One could also add createCubePrimitive(), createCylinderPrimitive(),
etc., but I don't think that's as critical to have as part of the
official library.
Maybe they could be provided in a sample.
What version of the product are you using? On what operating system?
svn revision 50044 of o3djs library, on Windows 7.
What hardware are you using: graphics card type? motherboard type?
not applicable
Please provide any additional information below.
Attached a patch to o3djs/primitives.js
Original issue reported on code.google.com by hutt...@gmail.com on 23 Jun 2010 at 6:51
Original issue reported on code.google.com by
hutt...@gmail.com
on 23 Jun 2010 at 6:51Attachments: