@openglobus/og 0.22.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/og.css +137 -1
- package/lib/@openglobus/js/Globe.d.ts +0 -1
- package/lib/@openglobus/js/Object3d.d.ts +20 -10
- package/lib/@openglobus/js/camera/Camera.d.ts +57 -15
- package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
- package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
- package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
- package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/@openglobus/js/control/index.d.ts +3 -2
- package/lib/@openglobus/js/entity/Entity.d.ts +282 -19
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
- package/lib/@openglobus/js/entity/GeoObject.d.ts +135 -39
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
- package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
- package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/@openglobus/js/index.d.ts +2 -1
- package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
- package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
- package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
- package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
- package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
- package/lib/@openglobus/js/math/Plane.d.ts +3 -1
- package/lib/@openglobus/js/math/Quat.d.ts +47 -33
- package/lib/@openglobus/js/math/Ray.d.ts +10 -14
- package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
- package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
- package/lib/@openglobus/js/math.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +15 -7
- package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
- package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
- package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
- package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
- package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
- package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
- package/lib/@openglobus/js/ui/Input.d.ts +32 -0
- package/lib/@openglobus/js/ui/View.d.ts +3 -1
- package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
- package/lib/@openglobus/js/utils/shared.d.ts +22 -0
- package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/@openglobus/js/webgl/Handler.d.ts +22 -12
- package/lib/@openglobus/og.css +1 -1
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Globe.d.ts +0 -1
- package/lib/js/Globe.js +4 -2
- package/lib/js/Object3d.d.ts +20 -10
- package/lib/js/Object3d.js +124 -48
- package/lib/js/Popup.js +1 -1
- package/lib/js/camera/Camera.d.ts +57 -15
- package/lib/js/camera/Camera.js +109 -29
- package/lib/js/camera/Frustum.d.ts +3 -0
- package/lib/js/camera/Frustum.js +7 -0
- package/lib/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/js/camera/PlanetCamera.js +52 -5
- package/lib/js/control/Atmosphere.js +10 -6
- package/lib/js/control/CameraLock.d.ts +38 -0
- package/lib/js/control/CameraLock.js +216 -0
- package/lib/js/control/Control.js +1 -1
- package/lib/js/control/DebugInfo.js +38 -8
- package/lib/js/control/KeyboardNavigation.js +9 -9
- package/lib/js/control/MouseNavigation.d.ts +62 -51
- package/lib/js/control/MouseNavigation.js +361 -305
- package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/MouseWheelZoomControl.js +270 -181
- package/lib/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/js/control/OldMouseNavigation.js +368 -0
- package/lib/js/control/ScaleControl.js +11 -5
- package/lib/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/js/control/SimpleNavigation.js +149 -49
- package/lib/js/control/Sun.js +6 -6
- package/lib/js/control/TouchNavigation.js +11 -8
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +6 -5
- package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +488 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +107 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +31 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
- package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/js/control/geoObjectEditor/colors.js +8 -0
- package/lib/js/control/index.d.ts +3 -2
- package/lib/js/control/index.js +3 -2
- package/lib/js/control/timeline/TimelineControl.js +2 -0
- package/lib/js/control/visibleExtent/Segment.js +4 -4
- package/lib/js/entity/Entity.d.ts +282 -19
- package/lib/js/entity/Entity.js +497 -62
- package/lib/js/entity/EntityCollection.d.ts +8 -9
- package/lib/js/entity/EntityCollection.js +48 -45
- package/lib/js/entity/GeoObject.d.ts +135 -39
- package/lib/js/entity/GeoObject.js +150 -90
- package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/js/entity/GeoObjectHandler.js +198 -295
- package/lib/js/entity/InstanceData.d.ts +76 -0
- package/lib/js/entity/InstanceData.js +347 -0
- package/lib/js/entity/Polyline.d.ts +19 -6
- package/lib/js/entity/Polyline.js +76 -36
- package/lib/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/js/entity/PolylineHandler.js +26 -1
- package/lib/js/index.d.ts +2 -1
- package/lib/js/index.js +2 -1
- package/lib/js/input/MouseHandler.d.ts +1 -0
- package/lib/js/input/MouseHandler.js +12 -1
- package/lib/js/layer/Bing.js +2 -2
- package/lib/js/layer/Vector.d.ts +4 -0
- package/lib/js/layer/Vector.js +16 -0
- package/lib/js/light/LightSource.d.ts +1 -139
- package/lib/js/light/LightSource.js +21 -227
- package/lib/js/math/Mat3.d.ts +1 -1
- package/lib/js/math/Mat3.js +1 -1
- package/lib/js/math/Mat4.d.ts +10 -1
- package/lib/js/math/Mat4.js +17 -1
- package/lib/js/math/Plane.d.ts +3 -1
- package/lib/js/math/Plane.js +11 -1
- package/lib/js/math/Quat.d.ts +47 -33
- package/lib/js/math/Quat.js +92 -90
- package/lib/js/math/Ray.d.ts +10 -14
- package/lib/js/math/Ray.js +56 -33
- package/lib/js/math/Vec2.d.ts +22 -0
- package/lib/js/math/Vec2.js +32 -0
- package/lib/js/math/Vec3.d.ts +15 -0
- package/lib/js/math/Vec3.js +30 -1
- package/lib/js/math.d.ts +2 -2
- package/lib/js/math.js +3 -3
- package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/js/quadTree/EntityCollectionNode.js +8 -8
- package/lib/js/quadTree/Node.d.ts +1 -1
- package/lib/js/quadTree/Node.js +2 -2
- package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/renderer/Renderer.d.ts +63 -44
- package/lib/js/renderer/Renderer.js +267 -266
- package/lib/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/js/renderer/RendererEvents.js +5 -2
- package/lib/js/scene/Planet.d.ts +15 -7
- package/lib/js/scene/Planet.js +133 -90
- package/lib/js/scene/RenderNode.d.ts +10 -25
- package/lib/js/scene/RenderNode.js +70 -58
- package/lib/js/segment/Segment.js +4 -4
- package/lib/js/shaders/depth.js +2 -5
- package/lib/js/shaders/drawnode.d.ts +1 -0
- package/lib/js/shaders/drawnode.js +51 -52
- package/lib/js/shaders/geoObject.d.ts +1 -0
- package/lib/js/shaders/geoObject.js +154 -91
- package/lib/js/shaders/polyline.js +68 -51
- package/lib/js/shaders/utils.d.ts +1 -1
- package/lib/js/shaders/utils.js +11 -0
- package/lib/js/terrain/GlobusTerrain.js +2 -2
- package/lib/js/ui/Checkbox.d.ts +31 -0
- package/lib/js/ui/Checkbox.js +110 -0
- package/lib/js/ui/Color.js +2 -1
- package/lib/js/ui/Dialog.d.ts +3 -0
- package/lib/js/ui/Dialog.js +20 -0
- package/lib/js/ui/Input.d.ts +32 -0
- package/lib/js/ui/Input.js +107 -0
- package/lib/js/ui/View.d.ts +3 -1
- package/lib/js/ui/View.js +6 -0
- package/lib/js/utils/objParser.d.ts +44 -12
- package/lib/js/utils/objParser.js +241 -149
- package/lib/js/utils/shared.d.ts +22 -0
- package/lib/js/utils/shared.js +34 -0
- package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/js/webgl/Framebuffer.js +136 -29
- package/lib/js/webgl/Handler.d.ts +22 -12
- package/lib/js/webgl/Handler.js +53 -34
- package/lib/js/webgl/Program.js +0 -8
- package/package.json +5 -3
- package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
- package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/EarthNavigation.d.ts +0 -50
- package/lib/js/control/EarthNavigation.js +0 -202
|
@@ -1,179 +1,271 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
function getTexturePath(path) {
|
|
2
|
+
let p = path.split('/');
|
|
3
|
+
let filename = p[p.length - 1];
|
|
4
|
+
let folder = p[p.length - 2];
|
|
5
|
+
return `${folder ? folder + "/" : ""}${filename}`;
|
|
6
|
+
}
|
|
7
|
+
export class Obj {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.objPositions = [];
|
|
10
|
+
this.objTexcoords = [];
|
|
11
|
+
this.objNormals = [];
|
|
12
|
+
// same order as `f` indices
|
|
13
|
+
this.objVertexData = [
|
|
14
|
+
this.objPositions,
|
|
15
|
+
this.objTexcoords,
|
|
16
|
+
this.objNormals,
|
|
17
|
+
];
|
|
18
|
+
// same order as `f` indices
|
|
19
|
+
this.vertexData = [
|
|
20
|
+
[], // positions
|
|
21
|
+
[], // texcoords
|
|
22
|
+
[], // normals
|
|
23
|
+
];
|
|
24
|
+
this._materialLibs = [];
|
|
25
|
+
this.geometries = [];
|
|
26
|
+
this.geometry = null;
|
|
27
|
+
this.materials = {};
|
|
28
|
+
this.material = {};
|
|
29
|
+
this.object = 'default';
|
|
30
|
+
this.groups = ['default'];
|
|
31
|
+
this._path = "";
|
|
32
|
+
this.keywords = {
|
|
33
|
+
v: (parts) => {
|
|
34
|
+
this.objPositions.push(parts.map(parseFloat));
|
|
35
|
+
},
|
|
36
|
+
vn: (parts) => {
|
|
37
|
+
this.objNormals.push(parts.map(parseFloat));
|
|
38
|
+
},
|
|
39
|
+
vt: (parts) => {
|
|
40
|
+
// should check for missing v and extra w?
|
|
41
|
+
this.objTexcoords.push([parseFloat(parts[0]), 1.0 - parseFloat(parts[1])]);
|
|
42
|
+
},
|
|
43
|
+
f: (parts) => {
|
|
44
|
+
this.setGeometry();
|
|
45
|
+
const numTriangles = parts.length - 2;
|
|
46
|
+
for (let tri = 0; tri < numTriangles; ++tri) {
|
|
47
|
+
this.addVertex(parts[0]);
|
|
48
|
+
this.addVertex(parts[tri + 1]);
|
|
49
|
+
this.addVertex(parts[tri + 2]);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
s: () => {
|
|
53
|
+
// skip texture scale
|
|
54
|
+
},
|
|
55
|
+
mtllib: (parts, unparsedArgs) => {
|
|
56
|
+
// the spec says there can be multiple filenames here
|
|
57
|
+
// but many exist with spaces in a single filename
|
|
58
|
+
this._materialLibs.push(unparsedArgs);
|
|
59
|
+
},
|
|
60
|
+
usemtl: (parts, unparsedArgs) => {
|
|
61
|
+
this.newGeometry();
|
|
62
|
+
this.setGeometry();
|
|
63
|
+
if (this.geometry) {
|
|
64
|
+
this.geometry.material = unparsedArgs;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
g: (parts) => {
|
|
68
|
+
this.groups = parts;
|
|
69
|
+
this.newGeometry();
|
|
70
|
+
},
|
|
71
|
+
o: (parts, unparsedArgs) => {
|
|
72
|
+
this.object = unparsedArgs;
|
|
73
|
+
this.newGeometry();
|
|
74
|
+
},
|
|
75
|
+
newmtl: (parts, unparsedArgs) => {
|
|
76
|
+
const material = {};
|
|
77
|
+
this.material = material;
|
|
78
|
+
this.materials[unparsedArgs] = material;
|
|
79
|
+
},
|
|
80
|
+
Ns: (parts, unparsedArgs) => {
|
|
81
|
+
this.material.shininess = parseFloat(unparsedArgs);
|
|
82
|
+
},
|
|
83
|
+
Ni: (parts, unparsedArgs) => {
|
|
84
|
+
// skip refraction
|
|
85
|
+
},
|
|
86
|
+
Ka: (parts, unparsedArgs) => {
|
|
87
|
+
this.material.ambient = parts.map(v => parseFloat(v));
|
|
88
|
+
},
|
|
89
|
+
Kd: (parts, unparsedArgs) => {
|
|
90
|
+
this.material.diffuse = parts.map(v => parseFloat(v));
|
|
91
|
+
},
|
|
92
|
+
Ks: (parts, unparsedArgs) => {
|
|
93
|
+
this.material.specular = parts.map(v => parseFloat(v));
|
|
94
|
+
},
|
|
95
|
+
Ke: (parts, unparsedArgs) => {
|
|
96
|
+
this.material.color = parts.map(v => parseFloat(v));
|
|
97
|
+
},
|
|
98
|
+
illum: (parts, unparsedArgs) => {
|
|
99
|
+
this.material.illum = parseFloat(unparsedArgs);
|
|
100
|
+
},
|
|
101
|
+
d: (parts, unparsedArgs) => {
|
|
102
|
+
this.material.opacity = parseFloat(unparsedArgs);
|
|
103
|
+
},
|
|
104
|
+
Tr: (parts, unparsedArgs) => {
|
|
105
|
+
this.material.opacity = parseFloat(unparsedArgs);
|
|
106
|
+
},
|
|
107
|
+
Tf: (parts, unparsedArgs) => {
|
|
108
|
+
// skip transmission filter
|
|
109
|
+
},
|
|
110
|
+
map_Ka: (parts, unparsedArgs) => {
|
|
111
|
+
// skip ambient texture
|
|
112
|
+
},
|
|
113
|
+
map_Kd: (parts, unparsedArgs) => {
|
|
114
|
+
this.material.colorTexture = `${this._path}/${getTexturePath(unparsedArgs)}`;
|
|
115
|
+
},
|
|
116
|
+
map_Bump: (parts, unparsedArgs) => {
|
|
117
|
+
this.material.normalTexture = `${this._path}/${getTexturePath(unparsedArgs)}`;
|
|
118
|
+
},
|
|
119
|
+
map_Ns: (parts, unparsedArgs) => {
|
|
120
|
+
this.material.metallicRoughnessTexture = `${this._path}/${getTexturePath(unparsedArgs)}`;
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
newGeometry() {
|
|
24
125
|
// If there is an existing geometry and it's
|
|
25
126
|
// not empty then start a new one.
|
|
26
|
-
if (geometry && geometry.data.vertices.length) {
|
|
27
|
-
geometry = null;
|
|
127
|
+
if (this.geometry && this.geometry.data.vertices.length) {
|
|
128
|
+
this.geometry = null;
|
|
28
129
|
}
|
|
29
130
|
}
|
|
30
|
-
|
|
31
|
-
if (!geometry) {
|
|
131
|
+
setGeometry() {
|
|
132
|
+
if (!this.geometry) {
|
|
32
133
|
const vertices = [];
|
|
33
|
-
const
|
|
134
|
+
const texCoords = [];
|
|
34
135
|
const normals = [];
|
|
35
|
-
vertexData = [
|
|
136
|
+
this.vertexData = [
|
|
36
137
|
vertices,
|
|
37
|
-
|
|
138
|
+
texCoords,
|
|
38
139
|
normals,
|
|
39
140
|
];
|
|
40
|
-
geometry = {
|
|
41
|
-
object,
|
|
42
|
-
groups,
|
|
43
|
-
material,
|
|
141
|
+
this.geometry = {
|
|
142
|
+
object: this.object,
|
|
143
|
+
groups: this.groups,
|
|
144
|
+
material: "",
|
|
44
145
|
data: {
|
|
45
146
|
vertices,
|
|
46
|
-
|
|
147
|
+
texCoords,
|
|
47
148
|
normals,
|
|
48
149
|
},
|
|
49
150
|
};
|
|
50
|
-
geometries.push(geometry);
|
|
151
|
+
this.geometries.push(this.geometry);
|
|
51
152
|
}
|
|
52
153
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
ptn.
|
|
154
|
+
addVertex(vert) {
|
|
155
|
+
let ptn = vert.split('/');
|
|
156
|
+
for (let i = 0; i < ptn.length; i++) {
|
|
157
|
+
let objIndexStr = ptn[i];
|
|
56
158
|
if (!objIndexStr) {
|
|
57
|
-
|
|
159
|
+
continue;
|
|
58
160
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
vn(parts) {
|
|
69
|
-
objNormals.push(parts.map(parseFloat));
|
|
70
|
-
},
|
|
71
|
-
vt(parts) {
|
|
72
|
-
// should check for missing v and extra w?
|
|
73
|
-
objTexcoords.push(parts.map(parseFloat));
|
|
74
|
-
},
|
|
75
|
-
f(parts) {
|
|
76
|
-
setGeometry();
|
|
77
|
-
const numTriangles = parts.length - 2;
|
|
78
|
-
for (let tri = 0; tri < numTriangles; ++tri) {
|
|
79
|
-
addVertex(parts[0]);
|
|
80
|
-
addVertex(parts[tri + 1]);
|
|
81
|
-
addVertex(parts[tri + 2]);
|
|
161
|
+
let index = parseInt(objIndexStr) - 1;
|
|
162
|
+
let v = this.vertexData[i];
|
|
163
|
+
let len = v.length;
|
|
164
|
+
let d = this.objVertexData[i][index];
|
|
165
|
+
let dlen = d.length;
|
|
166
|
+
this.vertexData[i].length = len + dlen;
|
|
167
|
+
for (let j = 0; j < dlen; j++) {
|
|
168
|
+
v[len + j] = d[j];
|
|
82
169
|
}
|
|
83
|
-
},
|
|
84
|
-
s: () => {
|
|
85
|
-
}, // smoothing group
|
|
86
|
-
mtllib(parts, unparsedArgs) {
|
|
87
|
-
// the spec says there can be multiple filenames here
|
|
88
|
-
// but many exist with spaces in a single filename
|
|
89
|
-
materialLibs.push(unparsedArgs);
|
|
90
|
-
},
|
|
91
|
-
usemtl(parts, unparsedArgs) {
|
|
92
|
-
material = unparsedArgs;
|
|
93
|
-
newGeometry();
|
|
94
|
-
},
|
|
95
|
-
g(parts) {
|
|
96
|
-
groups = parts;
|
|
97
|
-
newGeometry();
|
|
98
|
-
},
|
|
99
|
-
o(parts, unparsedArgs) {
|
|
100
|
-
object = unparsedArgs;
|
|
101
|
-
newGeometry();
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
const keywordRE = /(\w*)(?: )*(.*)/;
|
|
105
|
-
const lines = text.split('\n');
|
|
106
|
-
for (let lineNo = 0; lineNo < lines.length; ++lineNo) {
|
|
107
|
-
const line = lines[lineNo].trim();
|
|
108
|
-
if (line === '' || line.startsWith('#')) {
|
|
109
|
-
continue;
|
|
110
170
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
171
|
+
}
|
|
172
|
+
_innerParser(text, fileName) {
|
|
173
|
+
const keywordRE = /(\w*)(?: )*(.*)/;
|
|
174
|
+
const lines = text.split('\n');
|
|
175
|
+
for (let lineNo = 0; lineNo < lines.length; ++lineNo) {
|
|
176
|
+
const line = lines[lineNo].trim();
|
|
177
|
+
if (line === '' || line.startsWith('#')) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const m = keywordRE.exec(line);
|
|
181
|
+
if (!m) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const [, keyword, unparsedArgs] = m;
|
|
185
|
+
const parts = line.split(/\s+/).slice(1);
|
|
186
|
+
const handler = this.keywords[keyword];
|
|
187
|
+
if (!handler) {
|
|
188
|
+
console.warn(`Unknown keyword '${keyword}' in '${fileName}:${lineNo}'`); // eslint-disable-line no-console
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
handler(parts, unparsedArgs);
|
|
121
192
|
}
|
|
122
|
-
handler(parts, unparsedArgs);
|
|
123
193
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
194
|
+
get data() {
|
|
195
|
+
return {
|
|
196
|
+
geometries: this.geometries,
|
|
197
|
+
materials: this.materials
|
|
198
|
+
};
|
|
127
199
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
export function transformLeftToRightCoordinateSystem(objData) {
|
|
134
|
-
const convertedGeometries = objData.geometries.map(geometry => {
|
|
135
|
-
const vertices = geometry.data.vertices;
|
|
136
|
-
const normals = geometry.data.normals;
|
|
137
|
-
const textures = geometry.data.textures;
|
|
138
|
-
rotateObject(geometry.data, 0);
|
|
139
|
-
let convertedVertices = [];
|
|
140
|
-
let convertedNormals = [];
|
|
141
|
-
let convertedTextures = [];
|
|
142
|
-
// Convert positions
|
|
143
|
-
for (let i = 0; i < vertices.length; i += 3) {
|
|
144
|
-
const x = vertices[i];
|
|
145
|
-
const y = vertices[i + 1];
|
|
146
|
-
const z = vertices[i + 2];
|
|
147
|
-
convertedVertices.push(x, y, z);
|
|
200
|
+
async load(src) {
|
|
201
|
+
this._path = src.substring(0, src.lastIndexOf("/"));
|
|
202
|
+
const response = await fetch(src);
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
throw new Error(`Unable to load '${src}'`);
|
|
148
205
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
206
|
+
const reader = response.body.getReader();
|
|
207
|
+
const decoder = new TextDecoder();
|
|
208
|
+
let { value, done } = await reader.read();
|
|
209
|
+
let partialLine = '';
|
|
210
|
+
while (!done) {
|
|
211
|
+
const text = decoder.decode(value, { stream: true });
|
|
212
|
+
const lines = (partialLine + text).split('\n');
|
|
213
|
+
partialLine = lines.pop();
|
|
214
|
+
for (const line of lines) {
|
|
215
|
+
this._innerParser(line, src);
|
|
216
|
+
}
|
|
217
|
+
({ value, done } = await reader.read());
|
|
155
218
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const s = textures[i];
|
|
159
|
-
const t = 1 - textures[i + 1];
|
|
160
|
-
convertedTextures.push(s, t);
|
|
219
|
+
if (partialLine) {
|
|
220
|
+
this._innerParser(partialLine, src);
|
|
161
221
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
222
|
+
this._cleanupGeometryArrays();
|
|
223
|
+
let defArr = this._materialLibs.map(filename => {
|
|
224
|
+
filename = `${this._path}/${filename}`;
|
|
225
|
+
return fetch(filename)
|
|
226
|
+
.then((response) => response.text())
|
|
227
|
+
.then((text) => {
|
|
228
|
+
return { text, filename };
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
await Promise.all(defArr).then((mtlArr) => {
|
|
232
|
+
mtlArr.forEach(mtl => this._innerParser(mtl.text, mtl.filename));
|
|
233
|
+
});
|
|
234
|
+
return this.data;
|
|
235
|
+
}
|
|
236
|
+
async _readAndParse(file) {
|
|
237
|
+
const stream = file.stream();
|
|
238
|
+
const reader = stream.getReader();
|
|
239
|
+
const decoder = new TextDecoder();
|
|
240
|
+
let { value, done } = await reader.read();
|
|
241
|
+
let partialLine = "";
|
|
242
|
+
while (!done) {
|
|
243
|
+
const text = decoder.decode(value, { stream: true });
|
|
244
|
+
const lines = (partialLine + text).split("\n");
|
|
245
|
+
partialLine = lines.pop();
|
|
246
|
+
for (const line of lines) {
|
|
247
|
+
this._innerParser(line, file.name);
|
|
170
248
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
249
|
+
({ value, done } = await reader.read());
|
|
250
|
+
}
|
|
251
|
+
if (partialLine) {
|
|
252
|
+
this._innerParser(partialLine, file.name);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async readFile(objFile, mtlFile) {
|
|
256
|
+
this._path = "";
|
|
257
|
+
await this._readAndParse(objFile);
|
|
258
|
+
this._cleanupGeometryArrays();
|
|
259
|
+
if (mtlFile) {
|
|
260
|
+
await this._readAndParse(mtlFile);
|
|
261
|
+
}
|
|
262
|
+
return this.data;
|
|
263
|
+
}
|
|
264
|
+
_cleanupGeometryArrays() {
|
|
265
|
+
for (const geometry of this.geometries) {
|
|
266
|
+
geometry.data = Object.fromEntries(Object.entries(geometry.data).filter(([key, array]) => array.length > 0));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
177
269
|
}
|
|
178
270
|
function rotateObject(obj, angle) {
|
|
179
271
|
const cosA = Math.cos(angle);
|
package/lib/js/utils/shared.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Vec2 } from "../math/Vec2";
|
|
|
7
7
|
import { NumberArray2 } from "../math/Vec2";
|
|
8
8
|
import { NumberArray3, Vec3 } from "../math/Vec3";
|
|
9
9
|
import { NumberArray4, Vec4 } from "../math/Vec4";
|
|
10
|
+
import { Ellipsoid } from "../ellipsoid/Ellipsoid";
|
|
10
11
|
export declare function getDefault(param?: any, def?: any): boolean;
|
|
11
12
|
export declare function isEmpty(v: any): boolean;
|
|
12
13
|
/**
|
|
@@ -261,3 +262,24 @@ export declare function isImageLoaded(image: HTMLImageElement): boolean;
|
|
|
261
262
|
export declare function distanceFormat(v: number): string;
|
|
262
263
|
export declare function distanceFormatExt(v: number): [string, string];
|
|
263
264
|
export declare function getUrlParam(paramName: string): number | undefined;
|
|
265
|
+
/**
|
|
266
|
+
*
|
|
267
|
+
* @param x
|
|
268
|
+
* @param y
|
|
269
|
+
* @param z
|
|
270
|
+
* @param imageSize
|
|
271
|
+
* @param ellipsoid
|
|
272
|
+
*
|
|
273
|
+
* console.log(1, getTileImageResolution(0, 0, 1));
|
|
274
|
+
* console.log(7, getTileImageResolution(66, 44, 7));
|
|
275
|
+
* console.log(10, getTileImageResolution(536, 358, 10));
|
|
276
|
+
* console.log(12, getTileImageResolution(2149, 1446, 12));
|
|
277
|
+
* console.log(13, getTileImageResolution(4301, 2892, 13));
|
|
278
|
+
* console.log(14, getTileImageResolution(8582, 5736, 14));
|
|
279
|
+
* console.log(15, getTileImageResolution(17205, 11569, 15));
|
|
280
|
+
* console.log(16, getTileImageResolution(34419, 23138, 16));
|
|
281
|
+
* console.log(17, getTileImageResolution(68661, 45892, 17));
|
|
282
|
+
* console.log(18, getTileImageResolution(137650, 92555, 18));
|
|
283
|
+
*/
|
|
284
|
+
export declare function getTileImageResolution(x: number, y: number, z: number, imageSize?: number, ellipsoid?: Ellipsoid): number[];
|
|
285
|
+
export declare function toFixedMax(value: number, maxFixed?: number): string;
|
package/lib/js/utils/shared.js
CHANGED
|
@@ -7,6 +7,8 @@ import { Vec2 } from "../math/Vec2";
|
|
|
7
7
|
import { Vec3 } from "../math/Vec3";
|
|
8
8
|
import { Vec4 } from "../math/Vec4";
|
|
9
9
|
import { colorTable } from "./colorTable";
|
|
10
|
+
import { wgs84 } from "../ellipsoid/wgs84";
|
|
11
|
+
import * as mercator from "../mercator";
|
|
10
12
|
export function getDefault(param, def) {
|
|
11
13
|
return param != undefined ? param : def;
|
|
12
14
|
}
|
|
@@ -925,3 +927,35 @@ export function getUrlParam(paramName) {
|
|
|
925
927
|
return Number(param);
|
|
926
928
|
}
|
|
927
929
|
}
|
|
930
|
+
/**
|
|
931
|
+
*
|
|
932
|
+
* @param x
|
|
933
|
+
* @param y
|
|
934
|
+
* @param z
|
|
935
|
+
* @param imageSize
|
|
936
|
+
* @param ellipsoid
|
|
937
|
+
*
|
|
938
|
+
* console.log(1, getTileImageResolution(0, 0, 1));
|
|
939
|
+
* console.log(7, getTileImageResolution(66, 44, 7));
|
|
940
|
+
* console.log(10, getTileImageResolution(536, 358, 10));
|
|
941
|
+
* console.log(12, getTileImageResolution(2149, 1446, 12));
|
|
942
|
+
* console.log(13, getTileImageResolution(4301, 2892, 13));
|
|
943
|
+
* console.log(14, getTileImageResolution(8582, 5736, 14));
|
|
944
|
+
* console.log(15, getTileImageResolution(17205, 11569, 15));
|
|
945
|
+
* console.log(16, getTileImageResolution(34419, 23138, 16));
|
|
946
|
+
* console.log(17, getTileImageResolution(68661, 45892, 17));
|
|
947
|
+
* console.log(18, getTileImageResolution(137650, 92555, 18));
|
|
948
|
+
*/
|
|
949
|
+
export function getTileImageResolution(x, y, z, imageSize = 256, ellipsoid = wgs84) {
|
|
950
|
+
let ext = mercator.getTileExtent(x, y, z);
|
|
951
|
+
let b0 = ext.getSouthWest().inverseMercator(), b1 = ext.getNorthEast().inverseMercator();
|
|
952
|
+
let width = ellipsoid.getGreatCircleDistance(b0, new LonLat(b1.lon, b0.lat)), height = ellipsoid.getGreatCircleDistance(b0, new LonLat(b0.lon, b1.lat));
|
|
953
|
+
return [width / imageSize, height / imageSize];
|
|
954
|
+
}
|
|
955
|
+
export function toFixedMax(value, maxFixed = -1) {
|
|
956
|
+
if (maxFixed < 0) {
|
|
957
|
+
return value.toString();
|
|
958
|
+
}
|
|
959
|
+
const factor = Math.pow(10, maxFixed);
|
|
960
|
+
return (Math.round(value * factor) / factor).toString();
|
|
961
|
+
}
|
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import { BaseFramebuffer, IBaseFramebufferParams } from "./BaseFramebuffer";
|
|
2
2
|
import { Handler } from "./Handler";
|
|
3
|
+
import { TypedArray } from "../utils/shared";
|
|
4
|
+
export interface ITargetParams {
|
|
5
|
+
internalFormat?: string;
|
|
6
|
+
format?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
attachment?: string;
|
|
9
|
+
filter?: string;
|
|
10
|
+
readAsync?: boolean;
|
|
11
|
+
}
|
|
3
12
|
export interface IFrameBufferParams extends IBaseFramebufferParams {
|
|
4
13
|
isBare?: boolean;
|
|
5
|
-
format?: string | string[];
|
|
6
|
-
type?: string | string[];
|
|
7
|
-
attachment?: string | string[];
|
|
8
14
|
renderbufferTarget?: string;
|
|
9
15
|
textures?: WebGLTexture[];
|
|
16
|
+
targets?: ITargetParams[];
|
|
17
|
+
}
|
|
18
|
+
type TypedArrayConstructor = Uint8ArrayConstructor | Float32ArrayConstructor;
|
|
19
|
+
interface ITarget {
|
|
20
|
+
internalFormat: string;
|
|
21
|
+
format: string;
|
|
22
|
+
type: string;
|
|
23
|
+
attachment: string;
|
|
24
|
+
filter: string;
|
|
25
|
+
pixelBufferIndex: number;
|
|
26
|
+
TypeArrayConstructor: TypedArrayConstructor;
|
|
27
|
+
}
|
|
28
|
+
interface IPixelBuffer {
|
|
29
|
+
buffer: WebGLBuffer | null;
|
|
30
|
+
data: TypedArray | null;
|
|
31
|
+
glType: number;
|
|
32
|
+
glAttachment: number;
|
|
10
33
|
}
|
|
34
|
+
export declare function clientWaitAsync(gl: WebGL2RenderingContext, sync: WebGLSync, flags: number): Promise<void>;
|
|
11
35
|
/**
|
|
12
36
|
* Class represents framebuffer.
|
|
13
37
|
* @class
|
|
@@ -15,19 +39,18 @@ export interface IFrameBufferParams extends IBaseFramebufferParams {
|
|
|
15
39
|
* @param {IFrameBufferParams} [options] - Framebuffer options:
|
|
16
40
|
*/
|
|
17
41
|
export declare class Framebuffer extends BaseFramebuffer {
|
|
18
|
-
protected _isBare: boolean;
|
|
19
|
-
protected _internalFormatArr: string[];
|
|
20
|
-
protected _formatArr: string[];
|
|
21
|
-
protected _typeArr: string[];
|
|
22
|
-
protected _attachmentArr: string[];
|
|
23
42
|
protected _renderbufferTarget: string;
|
|
43
|
+
protected _targets: ITarget[];
|
|
24
44
|
/**
|
|
25
45
|
* Framebuffer texture.
|
|
26
46
|
* @public
|
|
27
47
|
* @type {number}
|
|
28
48
|
*/
|
|
29
49
|
textures: WebGLTexture[];
|
|
50
|
+
pixelBuffers: IPixelBuffer[];
|
|
51
|
+
protected _skipFrame: boolean;
|
|
30
52
|
constructor(handler: Handler, options?: IFrameBufferParams);
|
|
53
|
+
static createTargets(targets?: ITargetParams[]): ITarget[];
|
|
31
54
|
destroy(): void;
|
|
32
55
|
/**
|
|
33
56
|
* Framebuffer initialization.
|
|
@@ -35,6 +58,9 @@ export declare class Framebuffer extends BaseFramebuffer {
|
|
|
35
58
|
* @override
|
|
36
59
|
*/
|
|
37
60
|
init(): void;
|
|
61
|
+
readPixelBuffersAsync: () => void;
|
|
62
|
+
getPixelBufferData(targetIndex: number): TypedArray | null;
|
|
63
|
+
protected _createPixelBuffer(target: ITarget): void;
|
|
38
64
|
/**
|
|
39
65
|
* Bind buffer texture.
|
|
40
66
|
* @public
|
|
@@ -67,3 +93,4 @@ export declare class Framebuffer extends BaseFramebuffer {
|
|
|
67
93
|
*/
|
|
68
94
|
getImage(): HTMLImageElement;
|
|
69
95
|
}
|
|
96
|
+
export {};
|