UNPKG

@enable3d/three-graphics

Version:

3D library wrapping three.js and ammo.js

43 lines 1.78 kB
/** * @author Yannick Deubel (https://github.com/yandeu) * @copyright Copyright (c) 2020 Yannick Deubel; Project Url: https://github.com/enable3d/enable3d * @license {@link https://github.com/enable3d/enable3d/blob/master/LICENSE|LGPL-3.0} */ import { Cache, Scene, WebGLRenderer, PCFSoftShadowMap } from 'three'; import Cameras from './plugins/cameras.js'; import { AmmoPhysics } from '@enable3d/ammo-physics/dist/index.js'; import { logger } from '@enable3d/common/dist/logger.js'; export class ThreeGraphics { threeGraphicsConfig; cache; scene; renderer; camera; textureAnisotropy; cameras; physics; constructor(threeGraphicsConfig = {}) { this.threeGraphicsConfig = threeGraphicsConfig; const { alpha = false, anisotropy = 1, camera = Cameras.Perspective({ z: 25, y: 5 }), antialias = false, usePhysics = true, renderer } = threeGraphicsConfig; this.textureAnisotropy = anisotropy; this.camera = camera; this.scene = new Scene(); // this.renderer.physicallyCorrectLights = true this.renderer = renderer || new WebGLRenderer({ antialias, alpha }); // see https://threejs.org/docs/#examples/en/loaders/GLTFLoader // this.renderer.outputEncoding = sRGBEncoding // shadow this.renderer.shadowMap.enabled = true; this.renderer.shadowMap.type = PCFSoftShadowMap; // enable cache this.cache = Cache; this.cache.enabled = true; if (usePhysics) { if (typeof Ammo !== 'undefined') this.physics = new AmmoPhysics(this.scene, threeGraphicsConfig); else logger('Are you sure you included ammo.js?'); } } } //# sourceMappingURL=core.js.map