Autodesk forge 向Forge Viewer添加场景灯光
我想为我的Forge Viewer场景添加几个额外的灯光,但我找不到任何关于如何实现这一点的示例,我的尝试到目前为止都没有成功 我知道这篇文章:。这不是我要寻找的,我不想创建新的灯光预设,我想保留选定的灯光预设,并在模型周围添加额外的灯光,使其更加明亮 通过挖掘代码,我发现了以下功能:Autodesk forge 向Forge Viewer添加场景灯光,autodesk-forge,autodesk-viewer,Autodesk Forge,Autodesk Viewer,我想为我的Forge Viewer场景添加几个额外的灯光,但我找不到任何关于如何实现这一点的示例,我的尝试到目前为止都没有成功 我知道这篇文章:。这不是我要寻找的,我不想创建新的灯光预设,我想保留选定的灯光预设,并在模型周围添加额外的灯光,使其更加明亮 通过挖掘代码,我发现了以下功能: this.initLights = function () { this.dir_light1 = new three__WEBPACK_IMPORTED_MODULE_30__["Directi
this.initLights = function ()
{
this.dir_light1 = new three__WEBPACK_IMPORTED_MODULE_30__["DirectionalLight"](_defaultDirLightColor, _defaultLightIntensity);
this.dir_light1.position.copy(_lightDirDefault);
this.highlight_dir_light1 = new three__WEBPACK_IMPORTED_MODULE_30__["DirectionalLight"](_defaultDirLightColor, _defaultLightIntensity);
this.highlight_dir_light1.intensity = 1;
this.highlight_dir_light1.position.copy(_lightDirDefault);
//Note this color will be overridden by various light presets
this.amb_light = new three__WEBPACK_IMPORTED_MODULE_30__["AmbientLight"](_defaultAmbientColor);
this.highlight_amb_light = new three__WEBPACK_IMPORTED_MODULE_30__["AmbientLight"](_defaultAmbientColor);
// Set this list only once, so that we're not constantly creating and deleting arrays each frame.
// See https://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript for why.
// use this.no_lights empty array if no lights are needed.
this.lights = [this.dir_light1, this.amb_light];
this.highlight_lights = [this.highlight_dir_light1, this.highlight_amb_light];
//We do not add the lights to any scene, because we need to use them
//in multiple scenes during progressive render.
//this.scene.add(this.amb_light);
// Attach the light to the camera, so that the light direction is applied in view-space.
// Note:
//
// 1. For directional lights, the direction where the light comes from is determined by
// lightPosition - targetPosition, both in in world-space.
// 2. The default target of dir lights is the world origin.
// 3. Transforming the light object only affects the light position, but has no effect on the target.
//
// The goal is to rotate the lightDir with the camera, but keep it independent
// of the camera position. Due to 3. above, we must also attach the light's target object to the camera.
// Otherwise, the camera position would incorrectly be added to the light direction.
this.camera.add(this.dir_light1);
this.camera.add(this.dir_light1.target);
this.camera.add(this.highlight_dir_light1);
this.camera.add(this.highlight_dir_light1.target);
_lightsInitialized = true;
};
因此,我尝试按如下方式创建灯光,但没有成功:(
LMV使用自定义光源,因此需要将任何额外光源添加到
viewer.impl.lights
中才能生效:
const myExtraLight = new THREE.DirectionalLight(0xFF0000, 1.0);
viewer.impl.lights.push(myExtraLight)
注意:在您发布的查看器源代码中,光源也添加到渲染的灯光阵列中:
this.lights = [this.dir_light1, this.amb_light];
这似乎没有效果,我添加了一束红光(10),所以我希望看到我的模型以某种方式被照亮一点…这实际上是可行的,我的坏,但在我的模型中差异不明显。我只能注意到金属表面上微小的彩色光反射。。。
this.lights = [this.dir_light1, this.amb_light];