forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_batching.js
More file actions
118 lines (87 loc) · 3.25 KB
/
Copy pathtest_batching.js
File metadata and controls
118 lines (87 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
module("pc.Batcher", {
setup: function () {
this.app = new pc.Application(document.createElement("canvas"));
this.bg = this.app.batcher.addGroup("Test Group", false, 100);
},
teardown: function () {
this.app.destroy();
}
// loadAssets: function () {
// this.atlasAsset = new pc.Asset('red-atlas', 'textureatlas', {
// url: '../test-assets/sprite/red-atlas.json'
// });
// this.spriteAsset = new pc.Asset('red-sprite', 'sprite', {
// url: '../test-assets/sprite/red-sprite.json'
// });
// this.app.assets.add(this.atlasAsset);
// this.app.assets.add(this.spriteAsset);
// this.app.assets.load(this.atlasAsset);
// this.app.assets.load(this.spriteAsset);
// }
});
test("generate: removes model component mesh instances from layer", function() {
var e1 = new pc.Entity();
e1.name = "e1";
e1.addComponent("model", {
type: "box",
batchGroupId: this.bg.id
});
var e2 = new pc.Entity();
e2.name = "e2";
e2.addComponent("model", {
type: "box",
batchGroupId: this.bg.id
});
this.app.root.addChild(e1);
this.app.root.addChild(e2);
this.app.batcher.generate();
var layer = this.app.scene.layers.getLayerById(pc.LAYERID_WORLD);
var instances = layer.opaqueMeshInstances;
ok(instances.length === 1, "Too many mesh instances in layer");
ok(instances[0] !== e1.model.model.meshInstances[0], "e1 still references instance in layer");
ok(instances[1] !== e2.model.model.meshInstances[0], "e2 still references instance in layer");
});
// test("generate: removes sprite component mesh instances from layer", function() {
// var e1 = new pc.Entity();
// e1.name = "e1";
// e1.addComponent("sprite", {
// spriteAsset: this.spriteAsset,
// batchGroupId: this.bg.id
// });
// var e2 = new pc.Entity();
// e2.name = "e2";
// e2.addComponent("sprite", {
// spriteAsset: this.spriteAsset,
// batchGroupId: this.bg.id
// });
// this.app.root.addChild(e1);
// this.app.root.addChild(e2);
// this.app.batcher.generate();
// var layer = this.app.scene.layers.getLayerById(pc.LAYERID_WORLD);
// var instances = layer.opaqueMeshInstances;
// ok(instances.length === 1, "Too many mesh instances in layer");
// ok(instances[0] !== e1.model.model.meshInstances[0], "e1 still references instance in layer");
// ok(instances[1] !== e2.model.model.meshInstances[0], "e2 still references instance in layer");
// });
test("disable model component, marks batch group dirty", function() {
var e1 = new pc.Entity();
e1.name = "e1";
e1.addComponent("model", {
type: "box",
batchGroupId: this.bg.id
});
var e2 = new pc.Entity();
e2.name = "e2";
e2.addComponent("model", {
type: "box",
batchGroupId: this.bg.id
});
this.app.root.addChild(e1);
this.app.root.addChild(e2);
this.app.batcher.generate();
var layer = this.app.scene.layers.getLayerById(pc.LAYERID_WORLD);
var batch = this.app.batcher._batchList[0];
var mi = batch.meshInstance;
e2.enabled = false;
strictEqual(this.app.batcher._dirtyGroups[0], this.bg.id);
});