diff --git a/examples/scripts/parser/kin.js b/examples/scripts/parser/kin.js index 28841c70b..57edfbffb 100644 --- a/examples/scripts/parser/kin.js +++ b/examples/scripts/parser/kin.js @@ -1,32 +1,41 @@ NGL.autoLoad('data://1crnFH-multi.kin').then(function (kinemage) { for (let master in kinemage.masterDict) { - var shape = new NGL.Shape(master) + var shape = new NGL.Shape(master, { + pointSize: 3, + sizeAttenuation: false, + lineWidth: 3 + }) kinemage.dotLists.forEach(function (dotList) { if (!dotList.master.includes(master)) return - var pointBuffer = new NGL.PointBuffer({ - position: new Float32Array(dotList.position), - color: new Float32Array(dotList.color) - }, { - pointSize: 2, - sizeAttenuation: false, - useTexture: true - }) - shape.addBuffer(pointBuffer) + for (var i = 0, il = dotList.position.length / 3; i < il; ++i) { + var i3 = i * 3 + var x = dotList.position[ i3 ] + var y = dotList.position[ i3 + 1 ] + var z = dotList.position[ i3 + 2 ] + var r = dotList.color[ i3 ] + var g = dotList.color[ i3 + 1 ] + var b = dotList.color[ i3 + 2 ] + shape.addPoint([ x, y, z ], [ r, g, b ], dotList.label[ i ]) + } }) kinemage.vectorLists.forEach(function (vectorList) { if (!vectorList.master.includes(master)) return - var lineBuffer = new NGL.WidelineBuffer({ - position1: new Float32Array(vectorList.position1), - position2: new Float32Array(vectorList.position2), - color: new Float32Array(vectorList.color1), - color2: new Float32Array(vectorList.color2) - }, { - lineWidth: 2 - }) - shape.addBuffer(lineBuffer) + for (var i = 0, il = vectorList.position1.length / 3; i < il; ++i) { + var i3 = i * 3 + var x1 = vectorList.position1[ i3 ] + var y1 = vectorList.position1[ i3 + 1 ] + var z1 = vectorList.position1[ i3 + 2 ] + var x2 = vectorList.position2[ i3 ] + var y2 = vectorList.position2[ i3 + 1 ] + var z2 = vectorList.position2[ i3 + 2 ] + var r = vectorList.color1[ i3 ] + var g = vectorList.color1[ i3 + 1 ] + var b = vectorList.color1[ i3 + 2 ] + shape.addWideline([ x1, y1, z1 ], [ x2, y2, z2 ], [ r, g, b ], vectorList.label1[ i ]) + } }) var visible = kinemage.masterDict[ master ].visible