Files
cocos4/cocos/3d/debugger/utils.js
T
Leslie Leigh 4488d0d363 Vmath (#3700)
* * do not run phy system in editor
* support center of phy shape
* fix setWorldPosition() bug

* add interface pullTransform() for sync dynamic phy body's transform

* rename to ts

* remove type in jsdoc annotation

* set indent to 4

* tslint auto fix

* tslint auto fix

* update bits.ts

* update package.json;update vecs, quat and util.

* correct exporting/importing in index.js/export renderer as non-default because dumplicated Scene export

* components exporting
2019-01-03 18:50:17 +08:00

42 lines
1.1 KiB
JavaScript

import { renderer } from '../renderer';
import { vec3, color3 } from '../vmath';
import { Node } from '../scene-graph';
export function createGrid(app, width, length, seg) {
let linePass = new renderer.Pass('line');
linePass.setDepth(true, false);
let lineTech = new renderer.Technique(
['opaque'],
[],
[linePass]
);
let lineEffect = new renderer.Effect([lineTech], {}, []);
let model = new renderer.LineBatchModel();
model.setNode(new Node('debug-grid'));
model.setEffect(lineEffect);
// create mesh
let hw = width * 0.5;
let hl = length * 0.5;
let dw = width / seg;
let dl = length / seg;
for (let x = -hw; x <= hw; x += dw) {
model.addLine(
vec3.create(x, 0, -hl), // start
vec3.create(x, 0, hl), // end
color3.create(0.4, 0.4, 0.4), // color
vec3.create(0, 1, 0)); // normal
}
for (let z = -hl; z <= hl; z += dl) {
model.addLine(
vec3.create(-hw, 0, z), // start
vec3.create(hw, 0, z), // end
color3.create(0.4, 0.4, 0.4), // color
vec3.create(0, 1, 0)); // normal
}
return model;
}