This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
237 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { expect, fixture, html, nextFrame } from "@open-wc/testing" | ||
import * as THREE from "three" | ||
import "../src" | ||
|
||
import { ThreeElement, ThreeGame } from "../src" | ||
|
||
describe("using custom renderers", () => { | ||
describe("when no custom renderer is configured", () => { | ||
const render = () => | ||
fixture(html` | ||
<three-game> | ||
<three-scene></three-scene> | ||
</three-game> | ||
`) | ||
|
||
it("uses the default renderer", async () => { | ||
const game = (await render()) as ThreeGame | ||
expect(game.renderer).to.be.instanceOf(THREE.WebGLRenderer) | ||
}) | ||
}) | ||
|
||
describe("with a custom renderer configured", () => { | ||
const render = () => | ||
fixture(html` | ||
<three-game> | ||
<three-web-gl-renderer xr.enabled></three-web-gl-renderer> | ||
<three-scene></three-scene> | ||
</three-game> | ||
`) | ||
|
||
it("creates an element that wraps a renderer", async () => { | ||
const game = (await render()) as ThreeGame | ||
const renderer = game.querySelector("three-web-gl-renderer") as ThreeElement | ||
|
||
expect(renderer.object).to.be.instanceOf(THREE.WebGLRenderer) | ||
}) | ||
|
||
it("automatically attaches the custom renderer to the three-game element", async () => { | ||
const game = (await render()) as ThreeGame | ||
const renderer = game.querySelector("three-web-gl-renderer") as ThreeElement | ||
|
||
expect(game.renderer).to.eq(renderer.object) | ||
}) | ||
|
||
it("passes custom options to the renderer", async () => { | ||
const game = (await render()) as ThreeGame | ||
const renderer = game.querySelector("three-web-gl-renderer") as ThreeElement | ||
|
||
expect(renderer.object.xr.enabled).to.eq(true) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.