Added init struct (resource loading helpers)
This commit is contained in:
parent
7165f9ee89
commit
a519a9696c
4
sunpy/__init__.js
Normal file
4
sunpy/__init__.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// Map
|
||||||
|
import "./core/__init__.js";
|
||||||
|
import "./node/__init__.js";
|
||||||
|
import "./canvas/__init__.js";
|
10
sunpy/canvas/__init__.js
Normal file
10
sunpy/canvas/__init__.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Depends
|
||||||
|
import "../core/__init__.js";
|
||||||
|
import "../node/__init__.js";
|
||||||
|
|
||||||
|
// Map
|
||||||
|
import "./entity.js";
|
||||||
|
import "./helpers.js";
|
||||||
|
import "./renderer.js";
|
||||||
|
|
||||||
|
import "./gl/texture.js";
|
|
@ -8,5 +8,11 @@ export class Sprite extends Entity {
|
||||||
constructor(image) {
|
constructor(image) {
|
||||||
if (!(image instanceof Image))
|
if (!(image instanceof Image))
|
||||||
throw TypeError("Image has to be instance of `Image`");
|
throw TypeError("Image has to be instance of `Image`");
|
||||||
|
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(renderNode) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
9
sunpy/canvas/gl/shaders/texture.fs
Normal file
9
sunpy/canvas/gl/shaders/texture.fs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
|
varying vec2 v_texcoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = texture2D(u_texture, v_texcoord);
|
||||||
|
}
|
11
sunpy/canvas/gl/shaders/texture.vs
Normal file
11
sunpy/canvas/gl/shaders/texture.vs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
attribute vec4 position;
|
||||||
|
attribute vec2 texcoord;
|
||||||
|
|
||||||
|
uniform mat4 u_matrix;
|
||||||
|
|
||||||
|
varying vec2 v_texcoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_matrix * position;
|
||||||
|
v_texcoord = texcoord;
|
||||||
|
}
|
23
sunpy/canvas/gl/texture.js
Normal file
23
sunpy/canvas/gl/texture.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
//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
|
||||||
|
|
||||||
|
|
||||||
|
}
|
0
sunpy/canvas/helpers.js
Normal file
0
sunpy/canvas/helpers.js
Normal file
3
sunpy/core/__init__.js
Normal file
3
sunpy/core/__init__.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// Map
|
||||||
|
import "./utils.js"
|
||||||
|
import "./vector.js";
|
7
sunpy/node/__init__.js
Normal file
7
sunpy/node/__init__.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// Map
|
||||||
|
import "./node.js";
|
||||||
|
import "./propertyreader.js";
|
||||||
|
|
||||||
|
import "./nodes/basenode.js";
|
||||||
|
import "./nodes/swapnode.js";
|
||||||
|
import "./nodes/propertynode.js";
|
2
sunpy/orep/__init__.js
Normal file
2
sunpy/orep/__init__.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// Map
|
||||||
|
import "./orep.js";
|
|
@ -1,13 +1,3 @@
|
||||||
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/orep/orep.js" async></script>
|
<script type="module" src="/sunpy/__init__.js" async></script>
|
||||||
<script>
|
<script>
|
||||||
var onloadPost = onload || (() => {});
|
var onloadPost = onload || (() => {});
|
||||||
onload = () => {
|
onload = () => {
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
<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" src="/sunpy/orep/orep.js" async></script>
|
<script type="module" async>
|
||||||
|
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