使用 TypeScript 开发时,导入 PointCloudRenderer 类的便捷模块。例如,不是像这样一次导入一个渲染器:
import PointCloudClassBreaksRenderer from "geoscene/renderers/PointCloudClassBreaksRenderer";
import PointCloudRGBRenderer from "geoscene/renderers/PointCloudRGBRenderer";
import PointCloudStretchRenderer from "geoscene/renderers/PointCloudStretchRenderer";
import PointCloudUniqueValueRenderer from "geoscene/renderers/PointCloudUniqueValueRenderer";
您可以使用此模块在一行中导入它们:
import {
PointCloudClassBreaksRenderer,
PointCloudRGBRenderer,
PointCloudStretchRenderer,
PointCloudUniqueValueRenderer
} from "geoscene/pointCloudRenderers";
此模块还允许您在渲染器上实现类型保护,从而使代码更加智能。
import { PointCloudRenderer } from "geoscene/pointCloudRenderers";
function logInfos(renderer: PointCloudRenderer): void {
if (renderer.type === "point-cloud-class-breaks") {
console.log("renderer colorClassBreakInfos: ", renderer.colorClassBreakInfos);
}
}