/** Copyright (c) 2021 The v3d Authors. All rights reserved. * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Scene } from "@babylonjs/core/scene"; import { Engine } from "@babylonjs/core/Engines/engine"; import { Color3 } from "@babylonjs/core/Maths/math"; import { GLTFLoaderExtensionObserver } from "./importer/loader-observer"; import { VRMManager } from "./importer/babylon-vrm-loader/src"; import { Animation, Animatable, Camera, DefaultRenderingPipeline, EventState, IShadowLight, ShadowGenerator, IAnimationKey, EasingFunction, Nullable, SceneOptimizerOptions } from "@babylonjs/core"; import { v3DSkyBox } from "./scene/skybox"; export declare class V3DCore implements GLTFLoaderExtensionObserver { readonly engine: Engine; scene?: Scene; static FRAMERATE: number; /** * GLTFFileLoader plugin factory * @private */ private _vrmFileLoader; private _springBonesAutoUpdate; get springBonesAutoUpdate(): boolean; set springBonesAutoUpdate(value: boolean); /** * Shadow generators */ private _shadowGenerators; /** * Scene optimizer */ private _sceneOptimizer; /** * Rendering pipeline */ private readonly _renderingPipeline; get renderingPipeline(): DefaultRenderingPipeline; /** * Callbacks when loading is done */ private _onLoadCompleteCallbacks; addOnLoadCompleteCallbacks(callback: Function): void; removeOnLoadCompleteCallback(callback: Function): void; resetOnLoadCompleteCallbacks(): void; private _beforeRenderFunc; private _afterRenderFunc; updateBeforeRenderFunction(func: (eventData: Scene, eventState: EventState) => void): void; updateAfterRenderFunction(func: (eventData: Scene, eventState: EventState) => void): void; private _cameraOnBeforeRenderFunc; private _mainCamera; get mainCamera(): Camera; set mainCamera(value: Camera); skyBox: v3DSkyBox; /** * Loaded VRM Managers * @private */ loadedVRMManagers: VRMManager[]; addVRMManager(manager: VRMManager): void; /** * Get VRM Manager by index * @param idx */ getVRMManagerByIndex(idx: number): VRMManager; /** * Get VRM Manager by URI * VRM doesn't have any UID in metadata. Title can be unfilled too. * Filename is the only reasonable ID. * @param uri */ getVRMManagerByURI(uri: String): VRMManager; constructor(engine: Engine, scene?: Scene, camera?: Camera); /** * Make background transparent. */ transparentBackground(): void; /** * Make background solid. */ solidBackground(): void; /** * Change background color. * @param color */ setBackgroundColor(color: Color3): void; /** * Set background color from hex string. * @param hex Hex color string */ setBackgroundColorHex(hex: string): void; /** * Add an ambient light. * @param color color of the light */ addAmbientLight(color?: Color3): void; /** * Add a basic arc rotate camera to scene. * TODO: there seems to be a bug when meshes are near the edge of camera cone * Probably has something to do with culling * @param radius rotation radius */ private addCamera; /** * Attach a arc rotate following camera to VRM model. * Probably has something to do with culling * @param manager VRM Manager to attach the camera to * @param radius rotation radius */ attachCameraTo(manager: VRMManager, radius?: number): void; /** * * Create a skybox for the scene. * @param size size of the skybox * @param textureName path to skybox texture */ createSkyBox(size: number, textureName?: string): void; /** * Enable shadow caster for light. * @param light Light to enable shadows. */ enableShabows(light?: IShadowLight): void; /** * Get corresponding shadow generator for light. * @param light Light to get shadow generator */ getShadownGenerator(light: IShadowLight): Nullable; /** * Convenience function for starting animation * @param target * @param name * @param property * @param duration * @param from * @param to * @param loopMode * @param easingFunction * @param easingMode */ startQuickAnimation(target: any, name: string, property: string, duration: number, from: any, to: any, loopMode?: number | undefined, easingFunction?: EasingFunction, easingMode?: number): Animatable; /** * Convenience function for creating animation * @param target * @param name * @param property * @param keyFrames * @param loopMode * @param easingFunction * @param easingMode */ createAnimation(target: any, name: string, property: string, keyFrames: Array, loopMode?: number | undefined, easingFunction?: EasingFunction, easingMode?: number): [any, Animation]; enableOptimizer(options?: SceneOptimizerOptions): void; /** * Wrapper for SceneLoader.AppendAsync. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string) */ AppendAsync(rootUrl: string, sceneFilename?: string | File): Promise; /** * Wrapper for SceneLoader.LoadAsync * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string) */ LoadAsync(rootUrl: string, sceneFilename?: string | File): Promise; onLoadReady(): void; /** * Set up for time update. * @private */ private setupObservable; private enableResize; private setupShadowGenerator; private registerVrmExtension; private registerVrmPlugin; private setupRenderingPipeline; } export default V3DCore;