window = global;RequireScript('@/lib/aurora.js');RequireScript('@/lib/mp3.js');let fs = new FileStream('@/music/chartreuseRewind.mp3', FileOp.Read);let mp3Data = fs.read(fs.fileSize);let asset = AV.Asset.fromBuffer(mp3Data);let stream = null;asset.get('format', format => { // note: Aurora.js always decodes to float32 stream = new SoundStream(format.sampleRate, 32, // 32bit = float32 format.channelsPerFrame);});while (stream === null && Sphere.run());stream.play(Mixer.Default);asset.on('data', buffer => { stream.write(buffer); Sphere.sleep(0.005); // run event pump});asset.start();
// w, h = surface size in pixelsdefaultProjection = new Transform() .project2D(0, 0, w, h, -1, +1);
var wh = screen.width / 2;var hh = screen.height / 2;screen.transform = new Transform() .translate(-wh, -hh) .scale(1 / wh, 1 / wh) .rotate(0.2, 0.0, 1.0, 0.0) .translate(0, 0, -1.0) .project3D(90, wh / hh, 0.1, 2.0); // workaround for miniSphere bug new Shape(ShapeType.Points, new VertexList([{}])).draw(new Surface(1, 1));
Fun thing about the Z coordinate: while the near- and farplanes are specified as positive values, Z coordinates of things you draw should actually be negative! 0 is exactly at the camera (and will be clipped, because you can't have a nearplane at 0), and moves in the negative direction "away" from the screen. That caught me off-guard for a bit when I first starting playing around with 3D.
What is the purpose of using radians over degrees?
Debating whether I should add a SphereFS prefix for temp files or not. The prefix would be %/ and to maintain sandboxing purity, would be guaranteed by the engine to have nothing in it on startup. Anything written into %/ would be deleted on shutdown.The main thing that's stopping me is that I'm not sure how useful the ability to write temp files would be in practice, particularly for game development. Any insights for me to help me decide?