// make a cube (all of this is pretty specific to built-in prims and not 3d objects in general)
var cubeprim =newh3d.prim.Cube();
// the cube prim usually translates/rotates around its corner, instead move it to translate around center.
cubeprim.translate(-0.5,-0.5,-0.5);
cubeprim.unindex();// idk, the demo does this
cubeprim.addNormals();// create normals for the faces
cubeprim.addUVs();// create UV (texture) coordinates for the faces
// load a texture from the res/ folder or the resources
var texture =hxd.Res.images.aldercone.toTexture();// this is the semi-magical way to do this, you can also specify
// a filename
var material =h3d.mat.Material.create(texture);// this creates a material, with other properties like emissivity, glossyness etc.
// Actually create the scenegraph object, which is a mesh
this.cube=newh3d.scene.Mesh(cubeprim,material,s3d);// Note: s3d is a global variable pointing at the top level
// 3d scene which contains the 3d objects in the scenegraph
// add some point lights to the scene (note the lighting model in the 'forward' renderer is weird) FIXME we should switch to PBR since the results are more predictable and less weird looking in Heaps 2 and above