forma-embedded-view-sdk
Version:
The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma (previously Spacemaker).
54 lines (52 loc) • 2.15 kB
TypeScript
import type { IframeMessenger } from "../iframe-messenger.js";
/**
* Interact with the sun object in the 3D scene.
*
* @remarks
* Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.sun | sun}.
*/
export declare class SunApi {
#private;
/** @hidden */
constructor(iframeMessenger: IframeMessenger);
/**
* Fetch the `Date` corresponding to the current position of the sun in the scene.
*
* @remarks
* Since `Date` objects in JavaScript are based on the instance where the script is run,
* it is important to capture the discrepancy between the machine local time and the time
* at the project location. We recommend using a library such as
* [Luxon](https://moment.github.io/luxon/) to handle this
* -- their website has a lot of good documentation on the intricacies of time zones.
*
* @returns Date for the current sun position.
*
* @example
* import { DateTime } from "luxon";
* const projectTimezone = await Forma.project.getTimezone();
* const projectDate = await Forma.sun.getDate()
* const currentDate = DateTime.fromJSDate(currentDate, { zone: projectTimezone });
*/
getDate(): Promise<Date>;
/**
* Set the position of the sun in the scene.
*
* @remarks
* Since `Date` objects in JavaScript are based on the instance where the script is run,
* it is important to capture the discrepancy between the machine local time and the time
* at the project location. We recommend using a library such as
* [Luxon](https://moment.github.io/luxon/) to handle this
* -- their website has a lot of good documentation on the intricacies of time zones.
*
* @example
* import { DateTime } from "luxon";
*
* const projectTimezone = await Forma.project.getTimezone();
* const wantedDate = DateTime.fromISO("2023-07-01T13:37:00", { zone: projectTimezone });
* await Forma.sun.setDate({ date: wantedDate.toJSDate() });
*/
setDate(request: {
/** Date corresponding to the wanted sun position. */
date: Date;
}): Promise<void>;
}