From 8653167fd370f88b3bcc2be052a9aa26873dbe44 Mon Sep 17 00:00:00 2001 From: "gman@google.com" Date: Wed, 19 Aug 2009 00:07:49 +0000 Subject: expose Bitmap to JavaScript. Also added Texture.drawImage(canvas...) There's still the big question of whether we should flip textures by default in the o3d code. Currently I'm flipping them by default in o3djs.texture.createTextureFromRawData and I'm flipping them by default in o3djs.canvas.CanvasQuad.updateTexture. I'm torn whether or not I should be flipping them. I feel like 2d examples and examples of displaying images, like a picasa viewer, would be simpler if we didn't flip by default but the problem then is if you load some textures through a collada scene they'll be flipped the opposite of any textures you load by hand. Review URL: http://codereview.chromium.org/171060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23678 0039d316-1c4b-4281-b951-d872f2087c98 --- o3d/samples/o3djs/io.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'o3d/samples/o3djs/io.js') diff --git a/o3d/samples/o3djs/io.js b/o3d/samples/o3djs/io.js index 690bd2c..f575eff 100644 --- a/o3d/samples/o3djs/io.js +++ b/o3d/samples/o3djs/io.js @@ -36,6 +36,9 @@ o3djs.provide('o3djs.io'); +o3djs.require('o3djs.texture'); + + /** * A Module with various io functions and classes. * @namespace @@ -543,11 +546,10 @@ o3djs.io.loadArchiveAdvanced = function(pack, * texture is loaded. It will be passed the texture and an exception on * error or null on success. * @return {!o3djs.io.LoadInfo} A LoadInfo to track progress. - * @see o3djs.io.createLoader + * @see o3djs.loader.createLoader */ o3djs.io.loadTexture = function(pack, url, callback) { - // TODO: change this to get use RawData and Bitmap - var request = pack.createFileRequest('TEXTURE'); + var request = pack.createFileRequest('RAWDATA'); var loadInfo = o3djs.io.createLoadInfo( /** @type {!o3d.FileRequest} */ (request), false); @@ -557,9 +559,13 @@ o3djs.io.loadTexture = function(pack, url, callback) { */ request.onreadystatechange = function() { if (request.done) { - var texture = request.texture; + var rawData = /** @type {!o3d.RawData} */ request.data; var success = request.success; var exception = request.error; + var texture = null; + if (success) { + texture = o3djs.texture.createTextureFromRawData(pack, rawData, true); + } loadInfo.finish(); pack.removeObject(request); if (!success && !exception) { @@ -572,4 +578,3 @@ o3djs.io.loadTexture = function(pack, url, callback) { return loadInfo; }; - -- cgit v1.1