Thanks. I made it using drawLines
method, but it’s same result.
var CollisionTest = pc.createScript('collisionTest');
CollisionTest.attributes.add('colEntity', { type: 'entity', title: 'Collision Entity'});
// initialize code called once per entity
CollisionTest.prototype.initialize = function() {
this.groundShape = new pc.BoundingBox(this.colEntity.collision.getShapePosition().clone(), this.colEntity.collision.halfExtents.clone());
};
CollisionTest.prototype.update = function(dt) {
this.groundShape.center.copy(this.colEntity.collision.getShapePosition());
//this.app.drawWireAlignedBox(this.groundShape.getMin(), this.groundShape.getMax(), pc.Color.GREEN);
var p1 = this.groundShape.center.clone().add(new pc.Vec3(this.groundShape.halfExtents.x, this.groundShape.halfExtents.y, this.groundShape.halfExtents.z));
var p2 = this.groundShape.center.clone().add(new pc.Vec3(this.groundShape.halfExtents.x, this.groundShape.halfExtents.y, -this.groundShape.halfExtents.z));
var p3 = this.groundShape.center.clone().add(new pc.Vec3(-this.groundShape.halfExtents.x, this.groundShape.halfExtents.y, this.groundShape.halfExtents.z));
var p4 = this.groundShape.center.clone().add(new pc.Vec3(-this.groundShape.halfExtents.x, this.groundShape.halfExtents.y, -this.groundShape.halfExtents.z));
var p5 = this.groundShape.center.clone().add(new pc.Vec3(this.groundShape.halfExtents.x, -this.groundShape.halfExtents.y, this.groundShape.halfExtents.z));
var p6 = this.groundShape.center.clone().add(new pc.Vec3(this.groundShape.halfExtents.x, -this.groundShape.halfExtents.y, -this.groundShape.halfExtents.z));
var p7 = this.groundShape.center.clone().add(new pc.Vec3(-this.groundShape.halfExtents.x, -this.groundShape.halfExtents.y, this.groundShape.halfExtents.z));
var p8 = this.groundShape.center.clone().add(new pc.Vec3(-this.groundShape.halfExtents.x, -this.groundShape.halfExtents.y, -this.groundShape.halfExtents.z));
// upper
this.app.drawLines([p1, p2], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p1, p3], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p3, p4], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p2, p4], [pc.Color.RED, pc.Color.WHITE]);
// lower
this.app.drawLines([p5, p6], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p5, p7], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p7, p8], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p6, p8], [pc.Color.RED, pc.Color.WHITE]);
//pillar
this.app.drawLines([p1, p5], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p2, p6], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p3, p7], [pc.Color.RED, pc.Color.WHITE]);
this.app.drawLines([p4, p8], [pc.Color.RED, pc.Color.WHITE]);
};
CollisionTest.prototype.getBoundingBox = function() {
return this.groundShape;
}