Skip to content

Commit e8d5bd8

Browse files
authored
RenderLine fix when no options specified (playcanvas#2050)
* RenderLine fix when no options specified * _addLines handles undefined options * fix
1 parent 1800d29 commit e8d5bd8

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/scene/immediate.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,29 @@ Object.assign(pc.Application.prototype, function () {
134134
}
135135

136136
function _addLines(position, color, options) {
137-
if (options.layer === undefined) options.layer = this.scene.layers.getLayerById(pc.LAYERID_IMMEDIATE);
138-
if (options.depthTest === undefined) options.depthTest = true;
137+
var layer = (options && options.layer) ? options.layer : this.scene.layers.getLayerById(pc.LAYERID_IMMEDIATE);
138+
var depthTest = (options && options.depthTest !== undefined) ? options.depthTest : true;
139+
var mask = (options && options.mask) ? options.mask : undefined;
139140

140141
this._initImmediate();
141142

142-
var layer = options.layer;
143143
this._immediateData.addLayer(layer);
144144

145145
var idx = this._immediateData.getLayerIdx(layer);
146146
if (idx === undefined) {
147147
// Init used batch once
148148
var batch = new LineBatch();
149149
batch.init(this.graphicsDevice, this._immediateData.lineVertexFormat, layer, position.length / 2);
150-
batch.material.depthTest = options.depthTest;
151-
if (options.mask) batch.meshInstance.mask = options.mask;
150+
batch.material.depthTest = depthTest;
151+
if (mask) batch.meshInstance.mask = mask;
152152

153153
idx = this._immediateData.lineBatches.push(batch) - 1; // push into list and get index
154154
this._immediateData.addLayerIdx(idx, layer);
155155
} else {
156156
// Possibly reallocate buffer if it's small
157157
this._immediateData.lineBatches[idx].init(this.graphicsDevice, this._immediateData.lineVertexFormat, layer, position.length / 2);
158-
this._immediateData.lineBatches[idx].material.depthTest = options.depthTest;
159-
if (options.mask) this._immediateData.lineBatches[idx].meshInstance.mask = options.mask;
158+
this._immediateData.lineBatches[idx].material.depthTest = depthTest;
159+
if (mask) this._immediateData.lineBatches[idx].meshInstance.mask = mask;
160160
}
161161
// Append
162162
this._immediateData.lineBatches[idx].addLines(position, color);
@@ -266,12 +266,6 @@ Object.assign(pc.Application.prototype, function () {
266266
} else if (arg3) {
267267
// options passed in
268268
options = arg3;
269-
} else {
270-
// no arg3, use default options
271-
options = {
272-
layer: this.scene.layers.getLayerById(pc.LAYERID_IMMEDIATE),
273-
depthTest: true
274-
};
275269
}
276270

277271
this._addLines([start, end], [color, endColor], options);

0 commit comments

Comments
 (0)