import { Editor, EditorTheme } from "./editor.js"; import * as THREE from 'three'; import { MaterialType, PandaMode } from "./enums.js"; import { Euler, Material, MaterialParameters, Object3D, Vector3 } from "three"; import { LineBasicMaterialParameters } from "three/src/materials/LineBasicMaterial"; export interface PandaOptions { /** * 模式 默认: edit */ mode?: PandaMode; /** * 编辑器主题 */ theme?: EditorTheme; /** * 选中物体辅助颜色 */ selectColor?: THREE.ColorRepresentation; /** * class */ className?: string; pixelRatio?: number; /** * 控制器属性 * */ control?: Control; /** * 是否显示辅助对象 */ showHelper?: boolean; /** * 是否显示网格 */ showGrid?: boolean; /** * 渲染精度 shader precision. Can be "highp", "mediump" or "lowp". */ precision?: string | undefined; /** * default is false. */ alpha?: boolean | undefined; /** * default is true. */ premultipliedAlpha?: boolean | undefined; /** * 抗锯齿 default is false. */ antialias?: boolean | undefined; /** * default is true. */ stencil?: boolean | undefined; /** * default is false. */ preserveDrawingBuffer?: boolean | undefined; /** * Can be "high-performance", "low-power" or "default" */ powerPreference?: string | undefined; /** * default is true. */ depth?: boolean | undefined; /** * default is false. */ logarithmicDepthBuffer?: boolean | undefined; /** * default is false. */ failIfMajorPerformanceCaveat?: boolean | undefined; /** * 孪生源配置 */ twinConfig?: TwinConfig | undefined; } export declare class PandaEngine { el: HTMLElement; container: HTMLElement; options: PandaOptions; private components?; editor: Editor; private viewport; private renderer; private keyboard?; /** * 添加物体之前钩子函数 */ onAddObjectBefore?: (compoennt: PandaCommponent, object: THREE.Object3D) => boolean; /** * 添加物体之后钩子函数 */ onAddObjectAfter?: (compoennt: PandaCommponent, object: THREE.Object3D) => void; constructor(el: HTMLElement, options?: PandaOptions); private onWindowResize; private onDragover; private onDrop; loadHDR(url: string): void; /** * 设置视图 2D或3D * @param showSceneHelpers */ setViewDirection(type: string): void; /** * 设置是否显示辅助对象 * @param showSceneHelpers */ setShowHelper(showHelper: boolean): void; /** * 设置是否显示网格 * @param showSceneHelpers */ setShowGrid(showGrid: boolean): void; /** * 坐标点拾取 * @param showSceneHelpers */ getPoint(fn: (point: number[]) => void): void; /** * 获取场景的截图 * @param showSceneHelpers */ getImage(): string; /** * 销毁编辑器 */ destroy(): void; /** * 注册组件 * @param compoennts 物体组件数据 */ register(compoennts: PandaCommponents): void; /** * 物体组件数据生成三维物体并添加到场景中 * @param compoennt 网格组件数据 * @param parent * @returns 三维物体 */ add(compoennt: PandaCommponent, parent?: THREE.Object3D): THREE.Object3D | undefined; private _add; get scene(): THREE.Scene; /** * uuid获取对象 * @param uuid Object3D对象的uuid * @returns */ getObject(uuid: string): THREE.Object3D; /** * 选中物体,传null取消选中 * @param object uuid或Object3D对象 */ select(object?: string | Object3D | null): void; /** * 聚焦到物体,传null取消选中 * @param object uuid或Object3D对象 */ focus(object?: string | Object3D | null): void; isMultiSelect(object?: Object3D): boolean; /** * 设置动画 */ setAnimation(uuid: string, animations: PandaAnimation[]): void; /** * 设置事件 */ setEvent(uuid: string, events: PandaEvent[]): void; /** * 设置连接配置 */ setTwinConfig(twinConfig: TwinConfig): void; /** * 运行场景 */ startPlayer(): void; /** * 停止运行场景 */ stopPlayer(): void; moveObject(object: Object3D, newParent?: Object3D, nextObject?: Object3D): void; /** * 修改2D文字物体信息 * @param uuid * @param data * @returns */ setText(uuid: string, data: PandaCommponent): void; /** * 设置管道的基本参数 * @param uuid * @param data * @returns */ setPipeGeometry(uuid: string, data: PandaCommponent): void; /** * 设置值 * @param target uuid或Object3D对象 * @param key 字段名 * @param value 值 */ setValue(target: string | T, key: K, value: any): void; setMaterialValue(target: string | T, key: K, value: any, index: number): void; setMaterial(target: string | T, value: any, index: number): void; setPositionValue(target: string | T, newPos: Vector3): void; setRotationValue(target: string | T, newRot: Euler): void; setScaleValue(target: string | T, newScale: Vector3): void; setRaycast(target: string | T, selectable: boolean): void; setLookCamera(target: string | T, type: string): void; setEdgesObj(target: string | T, bool: boolean, param?: LineBasicMaterialParameters): void; setOutlineObj(target: string | T, bool: boolean): void; /** * 选中物体对象事件 * @param fn */ onSelected(fn: (object: Object3D) => void): void; get control(): Control; set control(control: Control); get data(): Uint8Array; open(data?: Uint8Array): void; openJson(json: any): void; load(): void; download(filename?: string): void; get_mouse_plane_pos(evt: any): THREE.Vector3; /** * 拖动事件dataTransfer */ static readonly DargData = "Panda"; static draggable(dom: HTMLElement, data: any): void; /** * 创建材质 * @param materialType 材质类型 * @param material 材质参数 * @returns */ static createMaterial(materialType?: MaterialType, material?: MaterialParameters): Material | undefined; static MaterialType: typeof MaterialType; static THREE: typeof THREE; } interface PandaCommponents { [key: string]: (componentData: PandaCommponent) => THREE.Object3D | Promise; } export interface PandaCommponent { type: string; material?: THREE.MaterialParameters; materialType?: MaterialType; [key: string]: any; } export interface PandaAnimation { key: string; to: any; repeat?: number; start?: boolean; delay?: number; yoyo?: boolean; easing?: string; } export interface PandaEvent { action: string; name: string; type: string; [key: string]: any; } export interface Control { enabled: boolean; /** * How far you can dolly in ( PerspectiveCamera only ). * @default 0 */ minDistance?: number; /** * How far you can dolly out ( PerspectiveCamera only ). * @default Infinity */ maxDistance?: number; /** * How far you can zoom in ( OrthographicCamera only ). * @default 0 */ minZoom?: number; /** * How far you can zoom out ( OrthographicCamera only ). * @default Infinity */ maxZoom?: number; /** * How far you can orbit vertically, lower limit. * Range is 0 to Math.PI radians. * @default 0 */ minPolarAngle?: number; /** * How far you can orbit vertically, upper limit. * Range is 0 to Math.PI radians. * @default Math.PI. */ maxPolarAngle?: number; /** * How far you can orbit horizontally, lower limit. * If set, the interval [ min, max ] * must be a sub-interval of [ - 2 PI, 2 PI ], * with ( max - min < 2 PI ). * @default Infinity */ minAzimuthAngle?: number; /** * How far you can orbit horizontally, upper limit. * If set, the interval [ min, max ] must be a sub-interval * of [ - 2 PI, 2 PI ], with ( max - min < 2 PI ). * @default Infinity */ maxAzimuthAngle?: number; /** * Set to true to enable damping (inertia), which can * be used to give a sense of weight to the controls. * Note that if this is enabled, you must call * .update () in your animation loop. * @default false */ enableDamping?: boolean; /** * The damping inertia used if .enableDamping is set to true. * Note that for this to work, * you must call .update () in your animation loop. * @default 0.05 */ dampingFactor?: number; /** * Enable or disable zooming (dollying) of the camera. * @default true */ enableZoom?: boolean; /** * Speed of zooming / dollying. * @default 1 */ zoomSpeed?: number; /** * Setting this property to `true` allows to zoom to the cursor's position. * @default false */ zoomToCursor?: boolean; /** * Enable or disable horizontal and * vertical rotation of the camera. * Note that it is possible to disable a single axis * by setting the min and max of the polar angle or * azimuth angle to the same value, which will cause * the vertical or horizontal rotation to be fixed at that value. * @default true */ enableRotate?: boolean; /** * Speed of rotation. * @default 1 */ rotateSpeed?: number; /** * Enable or disable camera panning. * @default true */ enablePan?: boolean; /** * Speed of panning. * @default 1 */ panSpeed?: number; /** * Defines how the camera's position is translated when panning. * If true, the camera pans in screen space. Otherwise, * the camera pans in the plane orthogonal to the camera's * up direction. Default is true for OrbitControls; false for MapControls. * @default true */ screenSpacePanning?: boolean; /** * How fast to pan the camera when the keyboard is used. * Default is 7.0 pixels per keypress. * @default 7 */ keyPanSpeed?: number; /** * Set to true to automatically rotate around the target. * Note that if this is enabled, you must call * .update () in your animation loop. */ autoRotate?: boolean; /** * How fast to rotate around the target if .autoRotate is true. * Default is 2.0, which equates to 30 seconds per orbit at 60fps. * Note that if .autoRotate is enabled, you must call * .update () in your animation loop. * @default 2 */ autoRotateSpeed?: number; } export interface TwinConfig { twinType: string; url: string; screenId?: string; username?: string; password?: string; topic?: string; pubTopic?: string; } export {};