Skip to content

Commit

Permalink
adapted kin example to use point and wideline shape methods
Browse files Browse the repository at this point in the history
  • Loading branch information
arose committed Mar 7, 2018
1 parent 545cc93 commit 950e09f
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions examples/scripts/parser/kin.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 950e09f

Please sign in to comment.