-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip Migrates to using web components
- Loading branch information
Showing
15 changed files
with
314 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
LitElement, html, css, customElement, property, | ||
} from 'lit-element'; | ||
import { WebGLRenderer } from 'three'; | ||
import api from '../api'; | ||
import './three-scene'; | ||
|
||
@customElement('map-scene') | ||
class MapScene extends LitElement { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
connectedCallback = () => { | ||
api.getMap() | ||
.then((res) => { | ||
this.map = res.data.Map[0]; | ||
}); | ||
} | ||
|
||
@property({ attribute: false }) | ||
map = null; | ||
|
||
static getStyles() { | ||
return css` | ||
:host { | ||
// display: block; | ||
// height: 100%; | ||
// width: 100%; | ||
} | ||
`; | ||
} | ||
|
||
render = () => html`<slot></slot>` | ||
} |
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,13 @@ | ||
import { | ||
LitElement, html, css, customElement, property, | ||
} from 'lit-element'; | ||
import { PerspectiveCamera } from 'three'; | ||
|
||
@customElement('three-camera') | ||
export default class ThreeCamera extends LitElement { | ||
constructor() { | ||
super(); | ||
const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | ||
camera.position.z = 5; | ||
} | ||
} |
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,13 @@ | ||
import { | ||
LitElement, html, css, customElement, property, | ||
} from 'lit-element'; | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'; | ||
|
||
@customElement('three-controls') | ||
export default class ThreeControls extends LitElement { | ||
constructor() { | ||
super(); | ||
// const controls = new OrbitControls(camera, renderer.domElement); | ||
// controls.update(); | ||
} | ||
} |
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,86 @@ | ||
import { | ||
LitElement, html, css, customElement, property, internalProperty, | ||
} from 'lit-element'; | ||
import { WebGLRenderer } from 'three'; | ||
|
||
@customElement('three-renderer') | ||
export default class ThreeRenderer extends LitElement { | ||
constructor() { | ||
super(); | ||
this.renderer = new WebGLRenderer(); | ||
this.renderer.setClearColor(this.clearColor); | ||
this.renderer.setSize(window.innerWidth, window.innerHeight); | ||
this.appendChild(this.renderer.domElement); | ||
|
||
// const render = () => { | ||
// renderer.render(scene, camera); | ||
// }; | ||
|
||
// const animate = () => { | ||
// requestAnimationFrame(animate); | ||
|
||
// // controls.update(); // only required if controls.enableDamping = true, or if controls.autoRotate = true | ||
|
||
// render(); | ||
// }; | ||
|
||
// animate(); | ||
} | ||
|
||
@property({ type: String, attribute: 'clear-color' }) | ||
clearColor = 'red'; | ||
|
||
@property({ type: Number, reflect: true }) | ||
width = 0; | ||
|
||
@property({ type: Number, reflect: true }) | ||
height = 0; | ||
|
||
@internalProperty() | ||
renderer: WebGLRenderer; | ||
|
||
animateRenderer = () => { | ||
requestAnimationFrame(this.animateRenderer); | ||
|
||
// TODO: implement this | ||
// this.renderer.render(scene, camera); | ||
} | ||
|
||
connectedCallback = () => { | ||
super.connectedCallback(); | ||
|
||
this.animateRenderer(); | ||
} | ||
|
||
attributeChangedCallback = (name: string, old: any, value: any) => { | ||
super.attributeChangedCallback(name, old, value); | ||
|
||
console.debug(`${name} changed`); | ||
|
||
switch (name) { | ||
case 'clear-color': | ||
this.renderer.setClearColor(value); | ||
break; | ||
case 'width': | ||
this.renderer.setSize(value, this.height); | ||
break; | ||
case 'height': | ||
this.renderer.setSize(this.width, value); | ||
break; | ||
default: | ||
console.debug(`${name} changed`); | ||
} | ||
} | ||
|
||
static getStyles() { | ||
return css` | ||
:host { | ||
display: block; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
`; | ||
} | ||
|
||
render = () => html`<slot></slot>` | ||
} |
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,17 @@ | ||
import { | ||
LitElement, html, css, customElement, property, internalProperty, | ||
} from 'lit-element'; | ||
import { WebGLRenderer, Scene } from 'three'; | ||
|
||
@customElement('three-scene') | ||
class ThreeScene extends LitElement { | ||
constructor() { | ||
super(); | ||
this.scene = new Scene(); | ||
} | ||
|
||
@internalProperty() | ||
scene: Scene; | ||
|
||
render = () => html`<slot></slot>` | ||
} |
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 |
---|---|---|
|
@@ -261,3 +261,8 @@ textarea { | |
} | ||
} | ||
|
||
|
||
html, body { | ||
min-height: 100%; | ||
height: 100%; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<!doctype html><html class="no-js" lang=""><head><meta charset="utf-8"><title></title><meta name="description" content=""><meta name="viewport" content="width=device-width,initial-scale=1"><meta property="og:title" content=""><meta property="og:type" content=""><meta property="og:url" content=""><meta property="og:image" content=""><link rel="manifest" href="site.webmanifest"><link rel="apple-touch-icon" href="icon.png"><link rel="stylesheet" href="css/normalize.css"><link rel="stylesheet" href="css/main.css"><meta name="theme-color" content="#fafafa"></head><body><script src="js/vendor/modernizr-3.11.2.min.js"></script><script src="js/plugins.js"></script><script src="js/main.js"></script><script>window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date; | ||
<!doctype html><html class="no-js" lang=""><head><meta charset="utf-8"><title></title><meta name="description" content=""><meta name="viewport" content="width=device-width,initial-scale=1"><meta property="og:title" content=""><meta property="og:type" content=""><meta property="og:url" content=""><meta property="og:image" content=""><link rel="manifest" href="site.webmanifest"><link rel="apple-touch-icon" href="icon.png"><link rel="stylesheet" href="css/normalize.css"><link rel="stylesheet" href="css/main.css"><meta name="theme-color" content="#fafafa"></head><body><perspective-app></perspective-app><script>window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date; | ||
ga('create', 'UA-XXXXX-Y', 'auto'); ga('set', 'anonymizeIp', true); ga('set', 'transport', 'beacon'); ga('send', 'pageview')</script><script src="https://www.google-analytics.com/analytics.js" async></script></body></html> |
Empty file.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.