From 536e83a51c2b86cffd12020ee1fe672c76b0395c Mon Sep 17 00:00:00 2001 From: Michiel Lankamp Date: Mon, 13 Jan 2025 10:53:49 +0100 Subject: [PATCH] Add DotBIMLoaderPlugin and cacheBuster property to multiple plugins --- .../CityJSONLoaderPlugin.d.ts | 4 + .../DotBIMLoaderPlugin.d.ts | 121 ++++++++++++++++++ types/plugins/DotBIMLoaderPlugin/index.d.ts | 1 + .../GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts | 4 + .../LASLoaderPlugin/LASLoaderPlugin.d.ts | 4 + .../STLLoaderPlugin/STLLoaderPlugin.d.ts | 4 + .../WebIFCLoaderPlugin.d.ts | 4 + .../XKTLoaderPlugin/XKTLoaderPlugin.d.ts | 20 ++- types/plugins/index.d.ts | 1 + 9 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts create mode 100644 types/plugins/DotBIMLoaderPlugin/index.d.ts diff --git a/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts b/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts index 4cf1a5e785..09af5f53cb 100644 --- a/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts +++ b/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts @@ -10,6 +10,10 @@ export declare interface ICityJSONDefaultDataSource { * @param {Function} error Callback fired on error. */ getCityJSON(src: string | number, ok: (json: any)=> void, error: (e: Error)=> void): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); } export declare type CityJSONLoaderPluginConfiguration = { diff --git a/types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts b/types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts new file mode 100644 index 0000000000..cf1e359cff --- /dev/null +++ b/types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts @@ -0,0 +1,121 @@ +import {IFCObjectDefaults, Plugin, VBOSceneModel, Viewer} from "../../viewer"; + +export declare interface IDotBIMDefaultDataSource { + /** + * Gets the contents of the given ````.xkt```` file in an arraybuffer. + * + * @param {String|Number} dotBIMSrc Path or ID of an ````.bim```` file. + * @param {Function} ok Callback fired on success, argument is the ````.xkt```` file in an arraybuffer. + * @param {Function} error Callback fired on error. + */ + getDotBIM(dotBIMSrc: string | number, ok: (buffer: ArrayBuffer) => void, error: (e: Error) => void): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); +} + +export declare type DotBIMLoaderPluginConfiguration = { + /** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */ + id?: string; + /** Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.*/ + objectDefaults?: IFCObjectDefaults; + /** A custom data source through which the XKTLoaderPlugin can load model and metadata files. Defaults to an instance of {@link DotBIMDefaultDataSource}, which loads uover HTTP. */ + dataSource?: IDotBIMDefaultDataSource; +}; + + +/** + * @param {Number[]} [params.rotation=[0,0,0]] The model's orientation, as Euler angles given in degrees, for each of the X, Y and Z axis. + * @param {Boolean} [params.backfaces=true] When true, always show backfaces, even on objects for which the .BIM material is single-sided. When false, only show backfaces on geometries whenever the .BIM material is double-sided. + * @param {Boolean} [params.dtxEnabled=true] When ````true```` (default) use data textures (DTX), where appropriate, to + * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable + * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point + * primitives. Only works while {@link DTX#enabled} is also ````true````. + */ +export declare type LoadDotBIMModel = { + /** ID to assign to the root {@link Entity#id}, unique among all components in the Viewer's {@link Scene}, generated automatically by default. */ + id?: string; + /** Path to a .BIM file, as an alternative to the ````bim```` parameter. */ + src?: string; + /** .BIM JSON, as an alternative to the ````src```` parameter. */ + bim?: any; + /** Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}. */ + objectDefaults?: object; + /** When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject.type} values in this list. */ + includeTypes?: string[] + /** When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject.type} values in this list. */ + excludeTypes?: string[]; + /** The double-precision World-space origin of the model's coordinates. */ + origin?: number[]; + /** The single-precision position, relative to ````origin````. */ + position?: number[]; + /** The model's scale. */ + scale?: number[]; + /** The model's orientation, given as Euler angles in degrees, for each of the X, Y and Z axis. */ + rotation?: number[]; + /** When true, always show backfaces, even on objects for which the .BIM material is single-sided. When false, only show backfaces on geometries whenever the .BIM material is double-sided. */ + backfaces?: boolean; + /** When ````true```` (default) use data textures (DTX), where appropriate, to + * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable + * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point + * primitives. Only works while {@link DTX#enabled} is also ````true````. */ + dtxEnabled?: boolean; +}; + +export declare class DotBIMLoaderPlugin extends Plugin { + /** + * @constructor + * + * @param {Viewer} viewer The Viewer. + * @param {DotBIMLoaderPluginConfiguration} cfg Plugin configuration. + */ + constructor(viewer: Viewer, cfg?: DotBIMLoaderPluginConfiguration); + + /** + * Sets a custom data source through which the DotBIMLoaderPlugin can .BIM files. + * + * Default value is {@link DotBIMDefaultDataSource}, which loads via an XMLHttpRequest. + * + * @type {IXKTDefaultDataSource} + */ + set dataSource(arg: IDotBIMDefaultDataSource); + + /** + * Gets the custom data source through which the DotBIMLoaderPlugin can load .BIM files. + * + * Default value is {@link DotBIMDefaultDataSource}, which loads via an XMLHttpRequest. + * + * @type {IXKTDefaultDataSource} + */ + get dataSource(): IDotBIMDefaultDataSource; + + /** + * Sets map of initial default states for each loaded {@link Entity} that represents an object. + * + * @type {IFCObjectDefaults} + */ + set objectDefaults(arg: IFCObjectDefaults); + + /** + * Gets map of initial default states for each loaded {@link Entity} that represents an object. + * + * @type {IFCObjectDefaults} + */ + get objectDefaults(): IFCObjectDefaults; + + /** + * Loads a .BIM model from a file into this DotBIMLoaderPlugin's {@link Viewer}. + * + * @param {LoadBIMModel} params Loading parameters. + * @returns {VBOSceneModel} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models} + */ + + /** + * Loads a .BIM model from a file into this DotBIMLoaderPlugin's {@link Viewer}. + * + * @param {LoadDotBIMModel} params Loading parameters. + * @returns {VBOSceneModel} Entity representing the model, which will have {@link Entity.isModel} set ````true```` and will be registered by {@link Entity.id} in {@link Scene.models}. + */ + load(params: LoadDotBIMModel): VBOSceneModel; +} diff --git a/types/plugins/DotBIMLoaderPlugin/index.d.ts b/types/plugins/DotBIMLoaderPlugin/index.d.ts new file mode 100644 index 0000000000..637aadefb9 --- /dev/null +++ b/types/plugins/DotBIMLoaderPlugin/index.d.ts @@ -0,0 +1 @@ +export * from "./DotBIMLoaderPlugin"; diff --git a/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts b/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts index 9b48d64701..3c2c9ec778 100644 --- a/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +++ b/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts @@ -31,6 +31,10 @@ export declare interface IGLTFDefaultDataSource { * @param {Function} error Fired on error while loading the glTF binary asset. */ getArrayBuffer(glTFSrc: string | number, binarySrc: string | number, ok: Function, error: Function): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); } export declare type GLTFLoaderPluginConfiguration = { diff --git a/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts b/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts index 8da1c8ca9f..876e17146f 100644 --- a/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +++ b/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts @@ -10,6 +10,10 @@ export declare interface ILASDefaultDataSource { * @param {Function} error Callback fired on error. */ getLAS(src: string | number, ok: (LAS: ArrayBuffer) => void, error: (e: Error) => void): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); } export declare type LASLoaderPluginConfiguration = { diff --git a/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts b/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts index 4d44ccdc60..7b0e84de72 100644 --- a/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts +++ b/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts @@ -9,6 +9,10 @@ export declare interface ISTLDefaultDataSource { * @param {Function} error Fired on error while loading the STL file. */ getSTL(src: string | number, ok: Function, error: Function): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); } export declare type STLLoaderPluginCOnfiguration = { diff --git a/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts b/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts index bb43b40410..9927bb505c 100644 --- a/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts +++ b/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts @@ -13,6 +13,10 @@ import { ModelStats } from "../index"; * @param {Function} error Callback fired on error. */ getIFC(src: string | number, ok: (buffer: ArrayBuffer)=> void, error: (e: Error)=> void): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); } export declare type WebIFCLoaderPluginConfiguration = { diff --git a/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts b/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts index b2767b4eaf..ffda0f8912 100644 --- a/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +++ b/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts @@ -56,14 +56,28 @@ export declare type LoadXKTModel = { saoEnabled?: boolean; /** Indicates if physically-based rendering (PBR) will apply to the model. Only works when {@link Scene.pbrEnabled} is also ````true````. */ pbrEnabled?: boolean; + /** Indicates if base color texture rendering is enabled for the model. Overridden by ````pbrEnabled````. Only works when {@link Scene#colorTextureEnabled} is also ````true````. */ + colorTextureEnabled?: boolean; /** When we set this ````true````, then we force rendering of backfaces for the model. */ backfaces?: boolean; /** When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). */ excludeUnclassifiedObjects?: boolean; /** Indicates whether to globalize each {@link Entity.id} and {@link MetaObject.id}, in case you need to prevent ID clashes with other models. */ globalizeObjectIds?: boolean; - /** Indicates whether to enable geometry reuse */ + /** Indicates whether to enable geometry reuse (````true```` by default) or whether to expand + * all geometry instances into batches (````false````), and not use instancing to render them. Setting this ````false```` can significantly + * improve Viewer performance for models that have excessive geometry reuse, but may also increases the amount of + * browser and GPU memory used by the model. See [#769](https://github.com/xeokit/xeokit-sdk/issues/769) for more info. */ reuseGeometries?: boolean; + /** When ````true```` (default) use data textures (DTX), where appropriate, to + * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable + * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point + * primitives. Only works while {@link DTX#enabled} is also ````true````. */ + dtxEnabled?: boolean; + /** Specifies the rendering order for the model. This is used to control the order in which + * SceneModels are drawn when they have transparent objects, to give control over the order in which those objects are blended within the transparent + * render pass. */ + renderOrder?: number; } export declare interface IXKTDefaultDataSource { @@ -84,6 +98,10 @@ export declare interface IXKTDefaultDataSource { * @param {Function} error Callback fired on error. */ getXKT(src: string | number, ok: (buffer: ArrayBuffer) => void, error: (e: Error) => void): void; + + get cacheBuster(): boolean; + + set cacheBuster(value: boolean); } /** diff --git a/types/plugins/index.d.ts b/types/plugins/index.d.ts index 1e64eab761..f402993d3f 100644 --- a/types/plugins/index.d.ts +++ b/types/plugins/index.d.ts @@ -4,6 +4,7 @@ export * from "./AxisGizmoPlugin"; export * from "./BCFViewpointsPlugin"; export * from "./CityJSONLoaderPlugin"; export * from "./DistanceMeasurementsPlugin"; +export * from "./DotBIMLoaderPlugin"; export * from "./FastNavPlugin"; export * from "./GLTFLoaderPlugin"; export * from "./LASLoaderPlugin";