camelCase, parameter renaming & interfaces

This commit is contained in:
program-sam 2025-06-27 16:19:29 +02:00
parent c9e56af4f6
commit fdb19b3ce4
5 changed files with 64 additions and 58 deletions

View File

@ -47,16 +47,16 @@
globus.planet.viewExtent(new Extent(new LonLat(158.31010, 54.45445), new LonLat(158.55687, 54.56659)));
globus.planet.addControl(new control.DrawingSwitcher({
corner_options: {
cornerStyle: {
color: "#0000FF",
},
center_options: {
centerStyle: {
color: "#00FF00",
},
outline_options: {
outlineStyle: {
color: "#FF0000",
},
fill_options: {
fillStyle: {
fillColor: "#00FFFF",
fillOpacity: 0.3,
},

View File

@ -3,10 +3,10 @@ import { LineStringDrawingScene } from "./LineStringDrawingScene";
import { PolygonDrawingScene } from "./PolygonDrawingScene";
export interface IDrawingControlParams extends IControlParams {
corner_options?: any;
center_options?: any;
outline_options?: any;
fill_options?: any;
cornerStyle?: any;
centerStyle?: any;
outlineStyle?: any;
fillStyle?: any;
}
class DrawingControl extends Control {
@ -17,10 +17,10 @@ class DrawingControl extends Control {
this._drawingScene = new LineStringDrawingScene({
name: `drawingScene:${this.__id}`,
corner_options: options.corner_options || {},
center_options: options.center_options || {},
outline_options: options.outline_options || {},
fill_options: options.fill_options || {},
cornerStyle: options.cornerStyle || {},
centerStyle: options.centerStyle || {},
outlineStyle: options.outlineStyle || {},
fillStyle: options.fillStyle || {},
});
}
@ -28,10 +28,10 @@ class DrawingControl extends Control {
this.deactivate();
this._drawingScene = new PolygonDrawingScene({
name: `polygonDrawingScene:${this.__id}`,
corner_options: this._drawingScene._corner_options,
center_options: this._drawingScene._center_options,
outline_options: this._drawingScene._outline_options,
fill_options: this._drawingScene._fill_options,
cornerStyle: this._drawingScene._cornerStyle,
centerStyle: this._drawingScene._centerStyle,
outlineStyle: this._drawingScene._outlineStyle,
fillStyle: this._drawingScene._fillStyle,
});
this.activate();
}
@ -40,10 +40,10 @@ class DrawingControl extends Control {
this.deactivate();
this._drawingScene = new LineStringDrawingScene({
name: `linestringDrawingScene:${this.__id}`,
corner_options: this._drawingScene._corner_options,
center_options: this._drawingScene._center_options,
outline_options: this._drawingScene._outline_options,
fill_options: this._drawingScene._fill_options,
cornerStyle: this._drawingScene._cornerStyle,
centerStyle: this._drawingScene._centerStyle,
outlineStyle: this._drawingScene._outlineStyle,
fillStyle: this._drawingScene._fillStyle,
});
this.activate();
}

View File

@ -28,7 +28,7 @@ class LineStringDrawingScene extends PolygonDrawingScene {
let prevCorn = corners[segNum];
let corner = new Entity({
geoObject: this._corner_options,
geoObject: this._cornerStyle,
});
corner.setCartesian3v(cart);
@ -56,7 +56,7 @@ class LineStringDrawingScene extends PolygonDrawingScene {
polyline: {
path3v: [prevPath],
isClosed: false,
...this._outline_options
...this._outlineStyle
}
});
entity.polyline!.altitude = OUTLINE_ALT;
@ -65,7 +65,7 @@ class LineStringDrawingScene extends PolygonDrawingScene {
let prevCenterCart = vecPrev.scaleTo(distPrev * 0.5).addA(prevCart);
let center = new Entity({
geoObject: this._center_options,
geoObject: this._centerStyle,
});
center.setCartesian3v(prevCenterCart);
center.addTo(this._centerLayer);
@ -180,7 +180,7 @@ class LineStringDrawingScene extends PolygonDrawingScene {
polyline: {
path3v: [],
isClosed: false,
...this._outline_options
...this._outlineStyle
}
}),
this._ghostCorner

View File

@ -1,6 +1,8 @@
import * as math from "../../math";
import { createEvents, type EventsHandler } from '../../Events';
import type { CoordinatesType } from "../../entity/Geometry";
import type { CoordinatesType, IGeometryStyle } from "../../entity/Geometry";
import type { IGeoObjectParams } from "../../entity/GeoObject";
import type { IPolylineParams } from "../../entity/Polyline";
import { Entity } from '../../entity/Entity';
import type { IMouseState } from "../../renderer/RendererEvents";
import { OldMouseNavigation } from "../OldMouseNavigation";
@ -19,13 +21,14 @@ const POLYGONDRAWINGSCENE_EVENTS: PolygonDrawingSceneEventsList = ["change", "st
export interface IPolygonDrawingSceneParams {
coordinates?: CoordinatesType[];
corner_options?: Object;
center_options?: Object;
outline_options?: Object;
fill_options?: Object;
cornerStyle?: IGeoObjectParams;
centerStyle?: IGeoObjectParams;
outlineStyle?: IPolylineParams;
fillStyle?: IGeometryStyle;
name: string;
}
const POINTER_OBJ3D = Object3d.createCylinder(1, 1, 2.0, 20, 1, true, false, 0, -0.5, 0);
export const NUM_SEGMENTS = 200;
@ -34,10 +37,10 @@ export const OUTLINE_ALT = 0.3;
class PolygonDrawingScene extends RenderNode {
public events: EventsHandler<PolygonDrawingSceneEventsList>;
public _planet: Planet | null;
public _corner_options: Object;
public _center_options: Object;
public _outline_options: Object;
public _fill_options: Object;
public _cornerStyle: IGeoObjectParams;
public _centerStyle: IGeoObjectParams;
public _outlineStyle: IPolylineParams;
public _fillStyle: IGeometryStyle;
protected _initCoordinates: CoordinatesType[];
protected _pickedCorner: Entity | null;
protected _pickedCenter: Entity | null;
@ -74,33 +77,33 @@ class PolygonDrawingScene extends RenderNode {
//
// options for vectors
//
this._corner_options = {
this._cornerStyle = {
scale: 0.5,
instanced: true,
tag: "corners",
color: "rgb(350, 350, 0)",
object3d: POINTER_OBJ3D,
...(options.corner_options || {})
...(options.cornerStyle || {})
};
this._center_options = {
this._centerStyle = {
scale: 0.4,
instanced: true,
tag: "centers",
color: "rgb(0, 350, 50)",
object3d: POINTER_OBJ3D,
...(options.center_options || {})
...(options.centerStyle || {})
};
this._outline_options = {
this._outlineStyle = {
thickness: 3.5,
color: "rgb(0, 350, 50)",
...(options.outline_options || {})
...(options.outlineStyle || {})
};
this._fill_options = {
this._fillStyle = {
fillColor: "rgba(0,146,247,0.2)",
...(options.fill_options || {})
...(options.fillStyle || {})
};
//
@ -127,7 +130,7 @@ class PolygonDrawingScene extends RenderNode {
polyline: {
path3v: [],
isClosed: false,
...this._outline_options
...this._outlineStyle
}
})],
pickingEnabled: false,
@ -141,7 +144,7 @@ class PolygonDrawingScene extends RenderNode {
// Ghost cursor pointer
//
this._ghostCorner = new Entity({
geoObject: this._corner_options
geoObject: this._cornerStyle
});
this._ghostOutlineLayer = new Vector("ghost-pointer", {
@ -208,7 +211,7 @@ class PolygonDrawingScene extends RenderNode {
'geometry': {
'type': e.geometryType,
'coordinates': [coords],
'style': this._fill_options
'style': this._fillStyle
}
});
this._geometryLayer.clear();
@ -486,7 +489,7 @@ class PolygonDrawingScene extends RenderNode {
let prevCorn = corners[segNum];
let corner = new Entity({
geoObject: this._corner_options,
geoObject: this._cornerStyle,
});
corner.setCartesian3v(cart);
@ -524,7 +527,7 @@ class PolygonDrawingScene extends RenderNode {
polyline: {
path3v: [prevPath],
isClosed: false,
...this._outline_options
...this._outlineStyle
}
});
entity.polyline!.altitude = OUTLINE_ALT;
@ -537,7 +540,7 @@ class PolygonDrawingScene extends RenderNode {
firstCenterCart = vecFirst.scaleTo(distFirst * 0.5).addA(firstCart);
let center = new Entity({
geoObject: this._center_options,
geoObject: this._centerStyle,
});
center.setCartesian3v(prevCenterCart);
center.addTo(this._centerLayer);
@ -551,7 +554,7 @@ class PolygonDrawingScene extends RenderNode {
} else {
let center = new Entity({
geoObject: this._center_options,
geoObject: this._centerStyle,
});
center.addTo(this._centerLayer);
}
@ -723,13 +726,13 @@ class PolygonDrawingScene extends RenderNode {
polyline: {
path3v: [],
isClosed: false,
...this._outline_options
...this._outlineStyle
}
}), new Entity({
polyline: {
path3v: [],
isClosed: false,
...this._outline_options
...this._outlineStyle
}
}),
this._ghostCorner

View File

@ -1,11 +1,11 @@
import * as utils from "../utils/shared";
import {Entity} from "./Entity";
import {Quat, Vec3, Vec4} from "../math/index";
import {GeoObjectHandler} from "./GeoObjectHandler";
import {InstanceData} from "./InstanceData";
import type {NumberArray3} from "../math/Vec3";
import type {NumberArray4} from "../math/Vec4";
import {Object3d} from "../Object3d";
import { Entity } from "./Entity";
import { Quat, Vec3, Vec4 } from "../math/index";
import { GeoObjectHandler } from "./GeoObjectHandler";
import { InstanceData } from "./InstanceData";
import type { NumberArray3 } from "../math/Vec3";
import type { NumberArray4 } from "../math/Vec4";
import { Object3d } from "../Object3d";
export const LOCAL_FORWARD = new Vec3(0.0, 0.0, -1.0);
@ -30,6 +30,7 @@ export interface IGeoObjectParams {
translate?: Vec3 | NumberArray3;
color?: Vec4 | NumberArray4 | string;
visibility?: boolean;
instanced?: boolean;
}
/**
@ -44,6 +45,7 @@ export interface IGeoObjectParams {
* @param {Vec3 | NumberArray3} [options.translate] - Translation offset.
* @param {Vec4 | NumberArray4 | string} [options.color] - RGBA color or HTML color string.
* @param {boolean} [options.visibility=true] - Visibility flag.
* @param {boolean} [options.instanced=true] - Whether the object is instanced or not. (unused for now)
*
* @todo: GeoObject and GeoObjectHandler provides instanced objects only.
* It would be nice if it could provide not instanced rendering loop too.
@ -94,6 +96,7 @@ class GeoObject {
public _objectSrc?: string;
protected _visibility: boolean;
protected _instanced: boolean = true;
protected _children: GeoObject[];
@ -440,4 +443,4 @@ class GeoObject {
}
}
export {GeoObject};
export { GeoObject };