Search the Community
Showing results for tags 'linesystem'.
-
Hi people, Based on the internal initial code from @JCPalmer, here are the per point colors for LineMesh and LineSystem var points = [arrayVector3]; var lineColors = [arrayColor4]; var line = BABYLON.MeshBuilder.CreateLines("l", {points: points, colors: lineColors}, scene); // same for LineSystems var lines = [arrayVector3[] ]; var colors = [arrayColor4[] ]; var lineSystem = BABYLON.MeshBuilder.CreateLineSystem("ls", {lines: lines, colors: colors}, scene); Note1 : this works also with updatable LineMesh or LineSystem objects as the colors array can be updated live. Note2 : when set at construction time, the parameter colors overwrite the hypothetical line or lineSystem .color property. If colors is passed but undefined, the object color falls back to the .color property value. [EDITED]Note3 : if you need to enable the alpha blending (line or segment transparency), just set the parameter "useVertexAlpha" to true at construction time : [EDITED 2] the alpha blending is now enabled by default. So when you don't need it, just set "useVertexAlpha" to false instead : var lineSystem = BABYLON.MeshBuilder.CreateLineSystem("ls", {lines: lines, colors: colors, useVertexAlpha: true}, scene); var line = BABYLON.MeshBuilder.CreateLines("l", {points: points, colors: colors, useVertexAlpha: true}, scene); This will allow you to create rulers, axes, graduation systems with multiple colors and to draw them in a single draw call. As usual, documentation and PG examples coming soon ... meanwhile : http://jerome.bousquie.fr/BJS/test/linesystem.html
- 16 replies
-
- colors
- linesystem
-
(and 1 more)
Tagged with:
-
Hi people, It was expected for a long time, so here is it : the brand new LineSystem. This allow you to create a single mesh with as many lines you want. Just pass an array populated with lines, each line being an array of successive Vector3. var nbLines = 30; var nbPoints = 100; var lines = []; for (var l = 0; l < nbLines; l++) { var points = []; for (var p = 0; p < nbPoints; p++) { points.push(new BABYLON.Vector3(p - nbPoints/2, Math.sin(p), l - nbLines/2)); } lines.push(points); } var lineSystem = BABYLON.MeshBuilder.CreateLineSystem("ls", {lines: lines, updatable: true}, scene); http://www.babylonjs-playground.com/#2K1IS4 Is this updatable/morphable ? Yes sir ! As usual with the parameter instance : lineSystem = BABYLON.MeshBuilder.CreateLineSystem(null, {lines: lines, instance: lineSystem}); http://www.babylonjs-playground.com/#2K1IS4#1 Have fun :-)