| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 * @type {o3djs.io.ArchiveInfo} | 89 * @type {o3djs.io.ArchiveInfo} |
| 90 */ | 90 */ |
| 91 this.archiveInfo = null; | 91 this.archiveInfo = null; |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * A map from classname to a function that will create | 94 * A map from classname to a function that will create |
| 95 * instances of objects. Add entries to support additional classes. | 95 * instances of objects. Add entries to support additional classes. |
| 96 * @type {!Object} | 96 * @type {!Object} |
| 97 */ | 97 */ |
| 98 this.createCallbacks = { | 98 this.createCallbacks = { |
| 99 'o3djs.DestinationBuffer': function(deserializer, json) { |
| 100 var object = deserializer.pack.createObject('o3d.VertexBuffer'); |
| 101 if ('custom' in json) { |
| 102 for (var i = 0; i < json.custom.fields.length; ++i) { |
| 103 var fieldInfo = json.custom.fields[i] |
| 104 var field = object.createField(fieldInfo.type, |
| 105 fieldInfo.numComponents); |
| 106 deserializer.addObject(fieldInfo.id, field); |
| 107 } |
| 108 object.allocateElements(json.custom.numElements); |
| 109 } |
| 110 return object; |
| 111 }, |
| 112 |
| 99 'o3d.VertexBuffer': function(deserializer, json) { | 113 'o3d.VertexBuffer': function(deserializer, json) { |
| 100 var object = deserializer.pack.createObject('o3d.VertexBuffer'); | 114 var object = deserializer.pack.createObject('o3d.VertexBuffer'); |
| 101 if ('custom' in json) { | 115 if ('custom' in json) { |
| 102 var rawData = deserializer.archiveInfo.getFileByURI( | 116 var rawData = deserializer.archiveInfo.getFileByURI( |
| 103 'vertex-buffers.bin'); | 117 'vertex-buffers.bin'); |
| 104 object.set(rawData, | 118 object.set(rawData, |
| 105 json.custom.binaryRange[0], | 119 json.custom.binaryRange[0], |
| 106 json.custom.binaryRange[1] - json.custom.binaryRange[0]); | 120 json.custom.binaryRange[1] - json.custom.binaryRange[0]); |
| 107 for (var i = 0; i < json.custom.fields.length; ++i) { | 121 for (var i = 0; i < json.custom.fields.length; ++i) { |
| 108 deserializer.addObject(json.custom.fields[i], object.fields[i]); | 122 deserializer.addObject(json.custom.fields[i], object.fields[i]); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 if (errorCollector.errors.length > 0) { | 749 if (errorCollector.errors.length > 0) { |
| 736 exception = errorCollector.errors.join('\n') + | 750 exception = errorCollector.errors.join('\n') + |
| 737 (exception ? ('\n' + exception.toString()) : ''); | 751 (exception ? ('\n' + exception.toString()) : ''); |
| 738 } | 752 } |
| 739 errorCollector.finish(); | 753 errorCollector.finish(); |
| 740 finishCallback(pack, exception); | 754 finishCallback(pack, exception); |
| 741 } | 755 } |
| 742 }; | 756 }; |
| 743 | 757 |
| 744 | 758 |
| OLD | NEW |