Add browser-only editor export and 2.5D runtime presentation
This commit is contained in:
@@ -220,3 +220,95 @@ test(
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"fixed orthographic camera, alpha events and legacy projection restore",
|
||||
{ timeout: 10000 },
|
||||
async () => {
|
||||
const r = runtime(),
|
||||
p = defaultProject(true);
|
||||
p.settings.rendering = { toneMapping: false };
|
||||
p.scripts = [
|
||||
{
|
||||
id: "fade",
|
||||
name: "Fade",
|
||||
fields: {},
|
||||
source:
|
||||
'({start(api){api.patch("visual",{components:{material:{alpha:.3,unlit:true}}})}})',
|
||||
},
|
||||
];
|
||||
activeScene(p).entities = [
|
||||
entity(
|
||||
"Camera",
|
||||
{
|
||||
camera: {
|
||||
mode: "fixed",
|
||||
projection: "orthographic",
|
||||
orthoWidth: 24,
|
||||
aspect: 16 / 9,
|
||||
lookAt: [0, 0, 0],
|
||||
},
|
||||
},
|
||||
[10, 20, 30],
|
||||
"camera",
|
||||
),
|
||||
entity(
|
||||
"Visual",
|
||||
{
|
||||
mesh: { type: "box", size: [1, 1, 1] },
|
||||
material: { color: "#ff8800", alpha: 1 },
|
||||
script: { scriptId: "fade" },
|
||||
},
|
||||
[0, 0, 0],
|
||||
"visual",
|
||||
),
|
||||
];
|
||||
try {
|
||||
await r.play(p);
|
||||
for (
|
||||
let i = 0;
|
||||
i < 60 &&
|
||||
r.state.find((n) => n.id === "visual")?.components.material.alpha !==
|
||||
0.3;
|
||||
i++
|
||||
)
|
||||
await wait(50);
|
||||
assert.equal(r.gameCamera.mode, 1);
|
||||
assert.deepEqual(r.gameCamera.position.asArray(), [10, 20, 30]);
|
||||
assert.equal(r.gameCamera.orthoLeft, -12);
|
||||
assert.equal(r.gameCamera.orthoTop, 6.75);
|
||||
assert.equal(r.gameCamera.viewport.height, 0.75);
|
||||
assert.equal(
|
||||
r.scene.imageProcessingConfiguration.toneMappingEnabled,
|
||||
false,
|
||||
);
|
||||
const mat: any = r.nodes.get("visual")!.getChildMeshes()[0].material;
|
||||
assert.equal(mat.alpha, 0.3);
|
||||
assert.equal(mat.unlit, true);
|
||||
await r.stop(p);
|
||||
assert.equal(
|
||||
r.state.find((n) => n.id === "visual")!.components.material.alpha,
|
||||
1,
|
||||
);
|
||||
const legacy = defaultProject(true);
|
||||
activeScene(legacy).entities = [
|
||||
entity(
|
||||
"Camera",
|
||||
{ camera: { offset: [0, 13, -10] } },
|
||||
[0, 13, -10],
|
||||
"camera",
|
||||
),
|
||||
];
|
||||
await r.play(legacy);
|
||||
await wait(50);
|
||||
assert.equal(r.gameCamera.mode, 0);
|
||||
assert.equal(r.gameCamera.viewport.height, 1);
|
||||
assert.equal(
|
||||
r.scene.imageProcessingConfiguration.toneMappingEnabled,
|
||||
true,
|
||||
);
|
||||
} finally {
|
||||
r.dispose();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user