我想在Forge Viewer场景中添加一些额外的灯光,但是我找不到有关如何实现此目的的任何示例,到目前为止,我的尝试均未成功。
我知道这篇文章:Add Custom Light for the View and Data API Viewer。这不是我想要的,我不想创建一个新的灯光预设,我想保留所选的灯光预设,并在模型周围添加额外的灯光以使其更明亮。
挖掘viewer3D.js代码,我发现以下功能:
static void Main(string[] args)
{
Process.Start("first.cmd").WaitForExit(); // popup a new window
Process.Start("second.cmd").WaitForExit(); // popup a new window
Process.Start("third.bat").WaitForExit(); // popup a new window
Console.WriteLine("Press any key to exit ... ");
Console.ReadKey();
}
因此,我尝试按照以下步骤创建灯光:(
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;
};
答案 0 :(得分:-1)
LMV使用自定义光源,因此任何多余的光源都需要添加到const myExtraLight = new THREE.DirectionalLight(0xFF0000, 1.0);
viewer.impl.lights.push(myExtraLight)
中才能生效:
this.lights = [this.dir_light1, this.amb_light];
在您发布的查看器的源代码中请注意,光源也将添加到渲染器的光源阵列中:
class User(UserMixin, Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
date_added = Column(DateTime(timezone=True), nullable=False)