|
@@ -3,7 +3,7 @@
|
|
|
import { ViewerConfiguration } from './../configuration/configuration';
|
|
|
import { Template, EventCallback } from './../templateManager';
|
|
|
import { AbstractViewer } from './viewer';
|
|
|
-import { MirrorTexture, Plane, ShadowGenerator, Texture, BackgroundMaterial, Observable, ShadowLight, CubeTexture, BouncingBehavior, FramingBehavior, Behavior, Light, Engine, Scene, AutoRotationBehavior, AbstractMesh, Quaternion, StandardMaterial, ArcRotateCamera, ImageProcessingConfiguration, Color3, Vector3, SceneLoader, Mesh, HemisphericLight } from 'babylonjs';
|
|
|
+import { SpotLight, MirrorTexture, Plane, ShadowGenerator, Texture, BackgroundMaterial, Observable, ShadowLight, CubeTexture, BouncingBehavior, FramingBehavior, Behavior, Light, Engine, Scene, AutoRotationBehavior, AbstractMesh, Quaternion, StandardMaterial, ArcRotateCamera, ImageProcessingConfiguration, Color3, Vector3, SceneLoader, Mesh, HemisphericLight } from 'babylonjs';
|
|
|
import { CameraBehavior } from '../interfaces';
|
|
|
|
|
|
export class DefaultViewer extends AbstractViewer {
|
|
@@ -366,7 +366,48 @@ export class DefaultViewer extends AbstractViewer {
|
|
|
|
|
|
// labs feature - flashlight
|
|
|
if (this.configuration.lab && this.configuration.lab.flashlight) {
|
|
|
+ let pointerPosition = BABYLON.Vector3.Zero();
|
|
|
+ let lightTarget;
|
|
|
+ let angle = 0.5;
|
|
|
+ let exponent = Math.PI / 2;
|
|
|
+ if (typeof this.configuration.lab.flashlight === "object") {
|
|
|
+ exponent = this.configuration.lab.flashlight.exponent || exponent;
|
|
|
+ angle = this.configuration.lab.flashlight.angle || angle;
|
|
|
+ }
|
|
|
+ var flashlight = new SpotLight("flashlight", Vector3.Zero(),
|
|
|
+ Vector3.Zero(), exponent, angle, this.scene);
|
|
|
+ if (typeof this.configuration.lab.flashlight === "object") {
|
|
|
+ flashlight.intensity = this.configuration.lab.flashlight.intensity || flashlight.intensity;
|
|
|
+ if (this.configuration.lab.flashlight.diffuse) {
|
|
|
+ flashlight.diffuse.r = this.configuration.lab.flashlight.diffuse.r;
|
|
|
+ flashlight.diffuse.g = this.configuration.lab.flashlight.diffuse.g;
|
|
|
+ flashlight.diffuse.b = this.configuration.lab.flashlight.diffuse.b;
|
|
|
+ }
|
|
|
+ if (this.configuration.lab.flashlight.specular) {
|
|
|
+ flashlight.specular.r = this.configuration.lab.flashlight.specular.r;
|
|
|
+ flashlight.specular.g = this.configuration.lab.flashlight.specular.g;
|
|
|
+ flashlight.specular.b = this.configuration.lab.flashlight.specular.b;
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ this.scene.constantlyUpdateMeshUnderPointer = true;
|
|
|
+ this.scene.onPointerObservable.add((eventData, eventState) => {
|
|
|
+ if (eventData.type === 4 && eventData.pickInfo) {
|
|
|
+ lightTarget = (eventData.pickInfo.pickedPoint);
|
|
|
+ } else {
|
|
|
+ lightTarget = undefined;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let updateFlashlightFunction = () => {
|
|
|
+ if (this.camera && flashlight) {
|
|
|
+ flashlight.position.copyFrom(this.camera.position);
|
|
|
+ if (lightTarget) {
|
|
|
+ lightTarget.subtractToRef(flashlight.position, flashlight.direction);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.scene.registerBeforeRender(updateFlashlightFunction);
|
|
|
+ this.registeredOnBeforerenderFunctions.push(updateFlashlightFunction);
|
|
|
}
|
|
|
|
|
|
if (!sceneConfig.defaultLight && (this.configuration.lights && Object.keys(this.configuration.lights).length)) {
|