mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
889 added ray test
This commit is contained in:
parent
c55eff653c
commit
0acc441acf
21
sandbox/ray/ray.html
Normal file
21
sandbox/ray/ray.html
Normal file
@ -0,0 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Draco loader sample</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="./ray.js" type="module"></script>
|
||||
<link rel="stylesheet" href="../../css/og.css" type="text/css" />
|
||||
<style>
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="width: 100%; height: 100%">
|
||||
<canvas id="frame" style="width: 100%; height: 100%"> </canvas>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
54
sandbox/ray/ray.js
Normal file
54
sandbox/ray/ray.js
Normal file
@ -0,0 +1,54 @@
|
||||
import {
|
||||
control,
|
||||
Entity,
|
||||
Object3d,
|
||||
Renderer,
|
||||
Vec3,
|
||||
Mat4,
|
||||
RenderNode,
|
||||
EntityCollection,
|
||||
scene,
|
||||
} from "../../lib/og.es.js";
|
||||
|
||||
let renderer = new Renderer("frame", {
|
||||
msaa: 8,
|
||||
controls: [new control.SimpleNavigation({ speed: 0.01 })],
|
||||
autoActivate: true
|
||||
});
|
||||
|
||||
class MyScene extends RenderNode {
|
||||
constructor() {
|
||||
super("MyScene");
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
let rayEntity = new Entity({
|
||||
cartesian: new Vec3(1, 1, 1),
|
||||
independentPicking: true,
|
||||
ray: {
|
||||
thickness: 5,
|
||||
startPosition: [0, 0, 0],
|
||||
endPosition: [10, 10, 10],
|
||||
startColor: "red",
|
||||
endColor: "green",
|
||||
}
|
||||
});
|
||||
|
||||
let collection = new EntityCollection({
|
||||
entities: [rayEntity]
|
||||
});
|
||||
|
||||
collection.addTo(this);
|
||||
|
||||
window.collection = collection;
|
||||
|
||||
this.renderer.activeCamera.set(new Vec3(-4, 11, 13), new Vec3(1, 0, 0));
|
||||
this.renderer.activeCamera.update();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.addNodes([
|
||||
new scene.Axes(),
|
||||
new MyScene()
|
||||
]);
|
||||
@ -316,6 +316,8 @@ class RayHandler {
|
||||
|
||||
gl.uniform1f(shu.uOpacity, ec._fadingOpacity);
|
||||
|
||||
gl.uniform1i(shu.u_texAtlas, 0);
|
||||
|
||||
gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera!.getViewMatrix());
|
||||
gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera!.getProjectionMatrix());
|
||||
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
varying vec2 v_texCoords;
|
||||
varying vec4 v_rgba;
|
||||
|
||||
void main () {
|
||||
vec4 color = texture2D(u_texture, v_texCoords);
|
||||
if(color.a < 0.1)
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D texAtlas;
|
||||
|
||||
varying vec4 v_rgba;
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
void main () {
|
||||
gl_FragColor = v_rgba;
|
||||
|
||||
vec4 color = texture2D(texAtlas, v_texCoord);
|
||||
|
||||
gl_FragColor = v_rgba + color;
|
||||
}
|
||||
@ -15,7 +15,7 @@ export function rayScreen(): Program {
|
||||
texAtlas: "sampler2d"
|
||||
},
|
||||
attributes: {
|
||||
a_texCoords: "vec2",
|
||||
a_texCoord: "vec2",
|
||||
a_vertices: "vec2",
|
||||
a_startPosHigh: "vec3",
|
||||
a_startPosLow: "vec3",
|
||||
|
||||
@ -7,8 +7,10 @@ attribute vec3 a_endPosHigh;
|
||||
attribute vec3 a_endPosLow;
|
||||
attribute vec2 a_vertices;
|
||||
attribute float a_thickness;
|
||||
attribute vec2 a_texCoord;
|
||||
|
||||
varying vec4 v_rgba;
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
uniform mat4 viewMatrix;
|
||||
uniform mat4 projectionMatrix;
|
||||
@ -20,6 +22,7 @@ uniform float uOpacity;
|
||||
void main() {
|
||||
|
||||
v_rgba = vec4(a_rgba.rgb, a_rgba.a * uOpacity);
|
||||
v_texCoord = a_texCoord;
|
||||
|
||||
vec3 v = (a_endPosHigh - a_startPosHigh) + (a_endPosLow - a_startPosLow);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user