|
@@ -5,8 +5,6 @@ module BABYLON {
|
|
public color = new Color3(1, 1, 1);
|
|
public color = new Color3(1, 1, 1);
|
|
public alpha = 1;
|
|
public alpha = 1;
|
|
|
|
|
|
- private _positionBuffer: { [key: string]: VertexBuffer } = {};
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
|
|
* The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
|
|
* This margin is expressed in world space coordinates, so its value may vary.
|
|
* This margin is expressed in world space coordinates, so its value may vary.
|
|
@@ -36,23 +34,29 @@ module BABYLON {
|
|
private _intersectionThreshold: number;
|
|
private _intersectionThreshold: number;
|
|
private _colorShader: ShaderMaterial;
|
|
private _colorShader: ShaderMaterial;
|
|
|
|
|
|
- constructor(name: string, scene: Scene, parent: Node = null, source?: LinesMesh, doNotCloneChildren?: boolean) {
|
|
|
|
|
|
+ constructor(name: string, scene: Scene, parent: Node = null, source?: LinesMesh, doNotCloneChildren?: boolean, public useVertexColor? : boolean) {
|
|
super(name, scene, parent, source, doNotCloneChildren);
|
|
super(name, scene, parent, source, doNotCloneChildren);
|
|
|
|
|
|
if (source) {
|
|
if (source) {
|
|
this.color = source.color.clone();
|
|
this.color = source.color.clone();
|
|
this.alpha = source.alpha;
|
|
this.alpha = source.alpha;
|
|
|
|
+ this.useVertexColor = source.useVertexColor;
|
|
}
|
|
}
|
|
|
|
|
|
this._intersectionThreshold = 0.1;
|
|
this._intersectionThreshold = 0.1;
|
|
- this._colorShader = new ShaderMaterial("colorShader", scene, "color",
|
|
|
|
- {
|
|
|
|
- attributes: [VertexBuffer.PositionKind],
|
|
|
|
- uniforms: ["worldViewProjection", "color"],
|
|
|
|
- needAlphaBlending: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- this._positionBuffer[VertexBuffer.PositionKind] = null;
|
|
|
|
|
|
+
|
|
|
|
+ var options = {
|
|
|
|
+ attributes: [VertexBuffer.PositionKind],
|
|
|
|
+ uniforms: ["world", "viewProjection"],
|
|
|
|
+ needAlphaBlending: false,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (!useVertexColor) {
|
|
|
|
+ options.uniforms.push("color");
|
|
|
|
+ options.needAlphaBlending = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this._colorShader = new ShaderMaterial("colorShader", scene, "color", options);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -76,15 +80,13 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh {
|
|
public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh {
|
|
- var engine = this.getScene().getEngine();
|
|
|
|
-
|
|
|
|
- this._positionBuffer[VertexBuffer.PositionKind] = this._geometry.getVertexBuffer(VertexBuffer.PositionKind);
|
|
|
|
-
|
|
|
|
// VBOs
|
|
// VBOs
|
|
- engine.bindBuffers(this._positionBuffer, this._geometry.getIndexBuffer(), this._colorShader.getEffect());
|
|
|
|
|
|
+ this._geometry._bind(this._colorShader.getEffect() );
|
|
|
|
|
|
// Color
|
|
// Color
|
|
- this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
|
|
|
|
|
|
+ if (!this.useVertexColor) {
|
|
|
|
+ this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
|
|
|
|
+ }
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|