I am a tad weary of squares and pyramids in Gladius. Tonight I would like to generate something a little different. How about a nice, simple sphere?
Well, looking through the CubicVr.js Primitives class, it does not seem like a simple thing to do manually. The sphere primitive calculates sever point around the center in order to call a "lathe" primitive to actually build the mesh. That seems... hard manually.
So how do I access the sphere primitive from the gladius-cubicvr.js?
At first I try:
require(['gladius-core', 'gladius-cubicvr'],
function(Gladius, cubicvrExtension){
// ...
var resources = {
mesh: cubicvrExtension.sphere(),
material: {
textures: {
color: '/images/rygb.png'
}
}
};
game.bind( null, engine, resources );
// ...
}
By virtue of require.js, I have access to the cubicvrExtension
object. It would be nice if the sphere()
primitive just exists on that extension. Unfortunately, when I load the thing in the browser, I see the following in the Javascript console:Uncaught TypeError: Object #<Object> has no method 'sphere'That would be too easy. Digging through the code, I find that Mesh can generate a sphere with the right primitive. I find a Mesh function in the cubicvr Gladius extension and try to use it like this:
var Mesh = cubicvrExtension.services.renderer.resources.Mesh;
var resources = {
mesh: Mesh({
primitive: {
type: "sphere",
radius: 0.5,
lat: 24,
lon: 24,
material: {
textures: {
color: '/images/rygb.png'
}
}
}
})
};
Unfortunately, that turns out to be the wrong Mesh. I have to call it a night here, but I will keep digging for an easy way to generate primitive shapes in Gladius + CubicVR.js.Day #412
No comments:
Post a Comment