UNPKG

@google/model-viewer

Version:

Easily display interactive 3D models on the web and in AR!

74 lines (73 loc) 3.06 kB
export declare type Constructor<T = object> = { new (...args: any[]): T; prototype: T; }; export declare const deserializeUrl: (url: string | null) => string | null; export declare const assertIsArCandidate: () => void; /** * Converts a partial URL string to a fully qualified URL string. * * @param {String} url * @return {String} */ export declare const toFullUrl: (partialUrl: string) => string; /** * Returns a throttled version of a given function that is only invoked at most * once within a given threshold of time in milliseconds. * * The throttled version of the function has a "flush" property that resets the * threshold for cases when immediate invokation is desired. */ export declare const throttle: (fn: (...args: any[]) => any, ms: number) => { (...args: any[]): void; flush(): void; }; export declare const debounce: (fn: (...args: any[]) => any, ms: number) => (...args: any[]) => void; /** * @param {Number} edge * @param {Number} value * @return {Number} 0 if value is less than edge, otherwise 1 */ export declare const step: (edge: number, value: number) => number; /** * @param {Number} value * @param {Number} lowerLimit * @param {Number} upperLimit * @return {Number} value clamped within lowerLimit..upperLimit */ export declare const clamp: (value: number, lowerLimit: number, upperLimit: number) => number; export declare const CAPPED_DEVICE_PIXEL_RATIO = 1; /** * This helper analyzes the layout of the current page to decide if we should * use the natural device pixel ratio, or a capped value. * * We cap DPR if there is no meta viewport (suggesting that user is not * consciously specifying how to scale the viewport relative to the device * screen size). * * The rationale is that this condition typically leads to a pathological * outcome on mobile devices. When the window dimensions are scaled up on a * device with a high DPR, we create a canvas that is much larger than * appropriate to accomodate for the pixel density if we naively use the * reported DPR. * * This value needs to be measured in real time, as device pixel ratio can * change over time (e.g., when a user zooms the page). Also, in some cases * (such as Firefox on Android), the window's innerWidth is initially reported * as the same as the screen's availWidth but changes later. * * A user who specifies a meta viewport, thereby consciously creating scaling * conditions where <model-viewer> is slow, will be encouraged to live their * best life. */ export declare const resolveDpr: () => number; /** * Returns the first key in a Map in iteration order. * * NOTE(cdata): This is necessary because IE11 does not implement iterator * methods of Map, and polymer-build does not polyfill these methods for * compatibility and performance reasons. This helper proposes that it is * a reasonable compromise to sacrifice a very small amount of runtime * performance in IE11 for the sake of code clarity. */ export declare const getFirstMapKey: <T = any, U = any>(map: Map<T, U>) => T | null;