Compare commits
No commits in common. "a519a9696c4f25716bd6f7f50c85ef599a0fb640" and "93eea321a8dffe3402e0bbb71488ba1e03c92ba3" have entirely different histories.
a519a9696c
...
93eea321a8
|
@ -1,4 +0,0 @@
|
||||||
// Map
|
|
||||||
import "./core/__init__.js";
|
|
||||||
import "./node/__init__.js";
|
|
||||||
import "./canvas/__init__.js";
|
|
|
@ -1,10 +0,0 @@
|
||||||
// Depends
|
|
||||||
import "../core/__init__.js";
|
|
||||||
import "../node/__init__.js";
|
|
||||||
|
|
||||||
// Map
|
|
||||||
import "./entity.js";
|
|
||||||
import "./helpers.js";
|
|
||||||
import "./renderer.js";
|
|
||||||
|
|
||||||
import "./gl/texture.js";
|
|
|
@ -1,18 +0,0 @@
|
||||||
export class Entity {
|
|
||||||
constructor() {}
|
|
||||||
async render(renderNode) {}
|
|
||||||
async update(renderNode) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Sprite extends Entity {
|
|
||||||
constructor(image) {
|
|
||||||
if (!(image instanceof Image))
|
|
||||||
throw TypeError("Image has to be instance of `Image`");
|
|
||||||
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
async render(renderNode) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
precision mediump float;
|
|
||||||
|
|
||||||
uniform sampler2D u_texture;
|
|
||||||
|
|
||||||
varying vec2 v_texcoord;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
gl_FragColor = texture2D(u_texture, v_texcoord);
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
attribute vec4 position;
|
|
||||||
attribute vec2 texcoord;
|
|
||||||
|
|
||||||
uniform mat4 u_matrix;
|
|
||||||
|
|
||||||
varying vec2 v_texcoord;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
gl_Position = u_matrix * position;
|
|
||||||
v_texcoord = texcoord;
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
//const fs = await (await fetch("./shaders/texture.fs")).text();
|
|
||||||
|
|
||||||
export async function compile() {
|
|
||||||
/*
|
|
||||||
const fs = await (await fetch("./shaders/texture.fs")).text();
|
|
||||||
const vs = await (await fetch("./shaders/texture.vs")).text();
|
|
||||||
*/
|
|
||||||
|
|
||||||
const fs = import("./shaders/texture.fs");
|
|
||||||
const vs = import("./shaders/texture.vs");
|
|
||||||
|
|
||||||
window.fs = fs;
|
|
||||||
window.vs = vs;
|
|
||||||
console.log("done");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function drawImage(gl, tex, texWidth, texHeight, dstX, dstY) {
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
||||||
|
|
||||||
gl.useProgram(program); // TODO
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ import { PropertyNode } from "../node/nodes/propertynode.js";
|
||||||
import { PropertyReader, Property } from "../node/propertyreader.js";
|
import { PropertyReader, Property } from "../node/propertyreader.js";
|
||||||
import { sleep } from "../core/utils.js";
|
import { sleep } from "../core/utils.js";
|
||||||
import { Vector } from "../core/vector.js";
|
import { Vector } from "../core/vector.js";
|
||||||
import { Entity } from "./entity.js";
|
|
||||||
|
|
||||||
register("canvas", initRenderNode);
|
register("canvas", initRenderNode);
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ export class RenderNode extends PropertyNode {
|
||||||
this.gl.depthFunc(this.gl.LEQUAL);
|
this.gl.depthFunc(this.gl.LEQUAL);
|
||||||
|
|
||||||
this.fps = 0;
|
this.fps = 0;
|
||||||
this.entities = [];
|
this.objects = [];
|
||||||
this.running = false;
|
this.running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +52,11 @@ export class RenderNode extends PropertyNode {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(entity) {
|
add(object) {
|
||||||
if (!(entity instanceof Entity))
|
if (!(object instanceof Renderable))
|
||||||
throw TypeError("entity must be instance of `Entity`");
|
throw TypeError("Object must be instance of Renderable");
|
||||||
|
|
||||||
this.entities.push(entity);
|
this.objects.push(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
async loop() { // TODO: Fix all variables
|
async loop() { // TODO: Fix all variables
|
||||||
|
@ -84,11 +83,22 @@ export class RenderNode extends PropertyNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
async render() {
|
async render() {
|
||||||
|
|
||||||
this.gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
this.gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
for (const entity of this.entities) {
|
for (const object of this.objects) {
|
||||||
await entity.render(this);
|
await object.render(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Renderable {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(renderNode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
// Map
|
|
||||||
import "./utils.js"
|
|
||||||
import "./vector.js";
|
|
|
@ -1,7 +0,0 @@
|
||||||
// Map
|
|
||||||
import "./node.js";
|
|
||||||
import "./propertyreader.js";
|
|
||||||
|
|
||||||
import "./nodes/basenode.js";
|
|
||||||
import "./nodes/swapnode.js";
|
|
||||||
import "./nodes/propertynode.js";
|
|
|
@ -6,7 +6,7 @@ export class PropertyNode extends SwapNode {
|
||||||
super(node, swapNode);
|
super(node, swapNode);
|
||||||
|
|
||||||
if (!(propertyReader instanceof PropertyReader))
|
if (!(propertyReader instanceof PropertyReader))
|
||||||
throw TypeError("propertyReader must be an instance of `PropertyReader`");
|
throw TypeError("propertyReader must be an instance of PropertyReader");
|
||||||
|
|
||||||
this.propertyReader = propertyReader;
|
this.propertyReader = propertyReader;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ export class SwapNode extends BaseNode {
|
||||||
super(node);
|
super(node);
|
||||||
|
|
||||||
if (!(swapNode instanceof Node))
|
if (!(swapNode instanceof Node))
|
||||||
throw TypeError("swapNode must be instance of `Node`");
|
throw TypeError("swapNode must be instance of Node");
|
||||||
|
|
||||||
this.swapNode = swapNode;
|
this.swapNode = swapNode;
|
||||||
|
|
||||||
|
@ -16,12 +16,6 @@ export class SwapNode extends BaseNode {
|
||||||
if (this.hasReplaceNodes)
|
if (this.hasReplaceNodes)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Copy id and classes to new node
|
|
||||||
if (this.node.id)
|
|
||||||
this.swapNode.id = this.node.id;
|
|
||||||
if (this.node.classList.length)
|
|
||||||
this.swapNode.classList = this.node.classList;
|
|
||||||
|
|
||||||
this.linker(this.node, this.swapNode);
|
this.linker(this.node, this.swapNode);
|
||||||
|
|
||||||
this.node.parentNode.replaceChild(this.swapNode, this.node);
|
this.node.parentNode.replaceChild(this.swapNode, this.node);
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
// Map
|
|
||||||
import "./orep.js";
|
|
|
@ -1,3 +1,13 @@
|
||||||
import { RenderNode } from "../canvas/renderer.js";
|
import { RenderNode } from "../canvas/renderer.js";
|
||||||
import { compile } from "../canvas/gl/texture.js";
|
|
||||||
window.compile = compile;
|
/*
|
||||||
|
var onloadOld = onload || (() => {});
|
||||||
|
onload = () => {
|
||||||
|
onloadOld();
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
|
@ -11,7 +11,7 @@
|
||||||
console.log("TEST - onload defined before module load");
|
console.log("TEST - onload defined before module load");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="module" src="/sunpy/__init__.js" async></script>
|
<script type="module" src="/sunpy/orep/orep.js" async></script>
|
||||||
<script>
|
<script>
|
||||||
var onloadPost = onload || (() => {});
|
var onloadPost = onload || (() => {});
|
||||||
onload = () => {
|
onload = () => {
|
||||||
|
@ -21,10 +21,10 @@
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="orep/canvas" class="test" id="render">
|
<script type="orep/canvas">
|
||||||
size = 400x300
|
size = 400x300
|
||||||
</script>
|
</script>
|
||||||
<script type="orep/canvas" class="test abc" id="stats">
|
<script type="orep/canvas">
|
||||||
size = 600x450
|
size = 600x450
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Tests - render</title>
|
<title>Tests - render</title>
|
||||||
<script type="module" async>
|
<script type="module" src="/sunpy/orep/orep.js" async></script>
|
||||||
import "../sunpy/__init__.js";
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="orep/canvas">
|
<script type="orep/canvas">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user