mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
889 fff.
This commit is contained in:
parent
e9fc88feaf
commit
667262ba21
BIN
sandbox/polyline/green.png
Normal file
BIN
sandbox/polyline/green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 319 B |
21
sandbox/polyline/polyline.html
Normal file
21
sandbox/polyline/polyline.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="./polyline.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>
|
||||
60
sandbox/polyline/polyline.js
Normal file
60
sandbox/polyline/polyline.js
Normal file
@ -0,0 +1,60 @@
|
||||
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 e1 = new Entity({
|
||||
polyline: {
|
||||
path3v: [[[1, 0, 1], [3, 5, 3], [0, 10, 0]]],
|
||||
thickness: 12.5,
|
||||
src: "./template3.png",
|
||||
isClosed: false
|
||||
}
|
||||
});
|
||||
|
||||
let e2 = new Entity({
|
||||
polyline: {
|
||||
path3v: [[[5, 0, 5], [5, 15, 5]]],
|
||||
thickness: 5.5,
|
||||
src: "./template2.png",
|
||||
isClosed: true
|
||||
}
|
||||
});
|
||||
|
||||
let collection = new EntityCollection({
|
||||
entities: [e1, e2]
|
||||
});
|
||||
|
||||
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()
|
||||
]);
|
||||
BIN
sandbox/polyline/template.png
Normal file
BIN
sandbox/polyline/template.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
sandbox/polyline/template2.png
Normal file
BIN
sandbox/polyline/template2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 B |
BIN
sandbox/polyline/template3.png
Normal file
BIN
sandbox/polyline/template3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 137 B |
@ -658,14 +658,12 @@ class EntityCollection {
|
||||
* @public
|
||||
*/
|
||||
public updateStrokeTextureAtlas() {
|
||||
|
||||
// Rays
|
||||
let r = this.rayHandler.rays;
|
||||
for (let i = 0; i < r.length; i++) {
|
||||
r[i].setSrc(r[i].getSrc());
|
||||
}
|
||||
this.rayHandler.reloadTextures();
|
||||
|
||||
//Polylines
|
||||
//@todo
|
||||
this.polylineHandler.reloadTextures();
|
||||
|
||||
//Strips
|
||||
//@todo
|
||||
@ -746,6 +744,8 @@ class EntityCollection {
|
||||
this._clearEntity(entity.childEntities[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
type EntityCollectionEventList = [
|
||||
|
||||
@ -338,12 +338,12 @@ class Polyline {
|
||||
ta.addImage(img);
|
||||
ta.createTexture();
|
||||
this._image = img;
|
||||
rn!.updateTexCoords();
|
||||
rn!.updateStrokeTexCoords();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.setTextureDisabled();
|
||||
rn!.updateTexCoords();
|
||||
rn!.updateStrokeTexCoords();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -370,6 +370,7 @@ class Polyline {
|
||||
let index = 0;
|
||||
let i = index * 24;
|
||||
let a = this._texCoordArr;
|
||||
debugger;
|
||||
|
||||
// a[i] = tcoordArr[0];
|
||||
// a[i + 1] = tcoordArr[1];
|
||||
@ -2014,6 +2015,7 @@ class Polyline {
|
||||
this._orders = [];
|
||||
this._indexes = [];
|
||||
this._colors = [];
|
||||
this._texCoordArr = [];
|
||||
|
||||
this._path3v.length = 0;
|
||||
this._pathLonLat.length = 0;
|
||||
|
||||
@ -132,6 +132,36 @@ class PolylineHandler {
|
||||
Vec3.doubleToTwoFloat32Array(rtcEyePosition, this._rtcEyePositionHigh, this._rtcEyePositionLow);
|
||||
}
|
||||
}
|
||||
|
||||
public reloadTextures() {
|
||||
for (let i = 0; i < this._polylines.length; i++) {
|
||||
let ri = this._polylines[i];
|
||||
ri.setSrc(ri.getSrc());
|
||||
}
|
||||
}
|
||||
|
||||
public get polylines(): Polyline[] {
|
||||
return [...this._polylines];
|
||||
}
|
||||
|
||||
public refreshTexCoordsArr() {
|
||||
let bc = this._entityCollection;
|
||||
if (bc && this._renderer) {
|
||||
let ta = this._renderer.strokeTextureAtlas;
|
||||
for (let i = 0; i < this._polylines.length; i++) {
|
||||
let ri = this._polylines[i];
|
||||
let img = ri.getImage();
|
||||
if (img) {
|
||||
let taData = ta.get(img.__nodeIndex!);
|
||||
if (taData) {
|
||||
let minY = taData.texCoords[1],
|
||||
imgHeight = taData.texCoords[3] - minY;
|
||||
ri._setTexCoordArr(taData.texCoords, minY, imgHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {PolylineHandler};
|
||||
@ -198,12 +198,12 @@ class Ray {
|
||||
ta.addImage(img);
|
||||
ta.createTexture();
|
||||
this._image = img;
|
||||
rn!.updateTexCoords();
|
||||
rn!.updateStrokeTexCoords();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bh!.setTextureDisabled(this._handlerIndex);
|
||||
rn!.updateTexCoords();
|
||||
rn!.updateStrokeTexCoords();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,6 +131,13 @@ class RayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public reloadTextures() {
|
||||
for (let i = 0; i < this._rays.length; i++) {
|
||||
let ri = this._rays[i];
|
||||
ri.setSrc(ri.getSrc());
|
||||
}
|
||||
}
|
||||
|
||||
public get rays(): Ray[] {
|
||||
return [...this._rays];
|
||||
}
|
||||
|
||||
@ -313,23 +313,23 @@ class RenderNode extends BaseNode {
|
||||
// // }
|
||||
// }
|
||||
|
||||
/*
|
||||
@todo: use one atlas for both handlers?
|
||||
*/
|
||||
public updateBillboardsTexCoords() {
|
||||
for (let i = 0; i < this.entityCollections.length; i++) {
|
||||
this.entityCollections[i].billboardHandler.refreshTexCoordsArr();
|
||||
}
|
||||
}
|
||||
|
||||
public updateTexCoords() {
|
||||
//Ray
|
||||
public updateStrokeTexCoords() {
|
||||
for (let i = 0; i < this.entityCollections.length; i++) {
|
||||
this.entityCollections[i].rayHandler.refreshTexCoordsArr();
|
||||
let ei = this.entityCollections[i];
|
||||
ei.rayHandler.refreshTexCoordsArr();
|
||||
ei.polylineHandler.refreshTexCoordsArr();
|
||||
//Strips etc.
|
||||
//@todo
|
||||
}
|
||||
|
||||
//Polyline
|
||||
//@todo
|
||||
|
||||
//Strips
|
||||
//@todo
|
||||
}
|
||||
|
||||
public frame() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user