Skip to content

Commit a041622

Browse files
committed
Flesh out interleaved / instanced buffers
1 parent 748e222 commit a041622

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

js/scripts/three-class-config.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ module.exports = {
269269
relativePath: './geometries/PlainBufferGeometry',
270270
superClass: 'BufferGeometry',
271271
properties: {
272-
attributes: new Types.ThreeTypeDict('BufferAttribute'),
273-
morphAttributes: new Types.ThreeTypeDict('BufferAttribute'),
272+
attributes: new Types.ThreeTypeDict(['BufferAttribute', 'InterleavedBufferAttribute']),
273+
morphAttributes: new Types.ThreeTypeDict(['BufferAttribute', 'InterleavedBufferAttribute']),
274274
MaxIndex: new Types.Int(65535),
275275
//groups: new Types.GeometryGroup(),
276276
//drawRange: new Types.DrawRange(),
@@ -279,18 +279,49 @@ module.exports = {
279279
},
280280
InstancedBufferAttribute: {
281281
relativePath: './core/InstancedBufferAttribute',
282+
superClass: 'BufferAttribute',
283+
properties: {
284+
meshPerAttribute: new Types.Int(1),
285+
},
286+
constructorArgs: ['array', 'meshPerAttribute'],
282287
},
283288
InstancedBufferGeometry: {
284289
relativePath: './core/InstancedBufferGeometry',
290+
superClass: 'PlainBufferGeometry',
291+
properties: {
292+
maxInstancedCount: new Types.Int(null, true),
293+
},
285294
},
286295
InstancedInterleavedBuffer: {
287296
relativePath: './core/InstancedInterleavedBuffer',
297+
superClass: 'InterleavedBuffer',
298+
properties: {
299+
meshPerAttribute: new Types.Int(1),
300+
},
301+
constructorArgs: ['array', 'meshPerAttribute'],
288302
},
289303
InterleavedBuffer: {
290304
relativePath: './core/InterleavedBuffer',
305+
properties: {
306+
array: new Types.ArrayBuffer(),
307+
stride: new Types.Int(null),
308+
dynamic: new Types.Bool(false),
309+
// updateRange: new Types.UpdateRange(),
310+
version: new Types.Int(0),
311+
needsUpdate: new Types.Bool(false),
312+
},
313+
propsDefinedByThree: ['version'],
314+
constructorArgs: ['array', 'stride'],
291315
},
292316
InterleavedBufferAttribute: {
293317
relativePath: './core/InterleavedBufferAttribute',
318+
properties: {
319+
data: new Types.ThreeType('InterleavedBuffer'),
320+
itemSize: new Types.Int(0),
321+
offset: new Types.Int(0),
322+
normalized: new Types.Bool(true),
323+
},
324+
constructorArgs: ['data', 'itemSize', 'offset', 'normalized']
294325
},
295326
Layers: {
296327
relativePath: './core/Layers',

js/src/geometries/PlainBufferGeometry.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var createModel = require('../_base/utils').createModel;
44
var AutogenPlainBufferGeometryModel = require('../geometries/PlainBufferGeometry.autogen').PlainBufferGeometryModel;
55

66
var BufferAttributeModel = require('../core/BufferAttribute.js').BufferAttributeModel;
7+
var InterleavedBufferAttributeModel = require('../core/InterleavedBufferAttribute.autogen.js').InterleavedBufferAttributeModel;
78
var GeometryModel = require('../core/Geometry.autogen.js').GeometryModel;
89
var BufferGeometryModel = require('../core/BufferGeometry.autogen.js').BufferGeometryModel;
910

@@ -58,7 +59,8 @@ var PlainBufferGeometryModel = AutogenPlainBufferGeometryModel.extend({
5859
return chain.then(() => {
5960
// Create models for all attributes:
6061
return Promise.all(_.map(_.pairs(result.attributes), kv => {
61-
return createModel(BufferAttributeModel, this.widget_manager, kv[1]).then(model => {
62+
var modelCtor = kv[1].isInterleavedBufferAttribute ? InterleavedBufferAttributeModel : BufferAttributeModel;
63+
return createModel(modelCtor, this.widget_manager, kv[1]).then(model => {
6264
return [kv[0], model];
6365
});
6466
}));
@@ -67,7 +69,8 @@ var PlainBufferGeometryModel = AutogenPlainBufferGeometryModel.extend({
6769

6870
// Then create models for all morphAttributes:
6971
}).then(Promise.all(_.map(_.pairs(result.morphAttributes), kv => {
70-
return createModel(BufferAttributeModel, this.widget_manager, kv[1]).then(model => {
72+
var modelCtor = kv[1].isInterleavedBufferAttribute ? InterleavedBufferAttributeModel : BufferAttributeModel;
73+
return createModel(modelCtor, this.widget_manager, kv[1]).then(model => {
7174
return [kv[0], model];
7275
});
7376
}))).then((attribModelKVs) => {

0 commit comments

Comments
 (0)