Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function addRenderHelper(
object: THREE.Object3D,
viewRanges: ViewRanges,
fadeNear: number | undefined,
fadeFar: number | undefined,
updateUniforms: boolean,
additionalCallback?: (
renderer: THREE.WebGLRenderer,
material: THREE.Material & FadingFeature
) => void
) {
// tslint:disable-next-line:no-unused-variable
object.onBeforeRender = chainCallbacks(
object.onBeforeRender,
(
renderer: THREE.WebGLRenderer,
scene: THREE.Scene,
camera: THREE.Camera,
geometry: THREE.Geometry | THREE.BufferGeometry,
material: THREE.Material & FadingFeature,
group: THREE.Group
) => {
const fadingMaterial = material as FadingFeature;
fadingMaterial.fadeNear =
fadeNear === undefined
? FadingFeature.DEFAULT_FADE_NEAR
: cameraToWorldDistance(fadeNear, viewRanges);
const object = new ObjectCtor(bufferGeometry, material);
object.renderOrder = technique.renderOrder!;
if (group.renderOrderOffset !== undefined) {
object.renderOrder += group.renderOrderOffset;
}
if (srcGeometry.uuid !== undefined) {
object.userData.geometryId = srcGeometry.uuid;
}
if (
isFillTechnique(technique) &&
mapView.projection.type === ProjectionType.Planar
) {
object.onBeforeRender = chainCallbacks(
object.onBeforeRender,
(_renderer, _scene, _camera, _geometry, _material) => {
if (_material.clippingPlanes === null) {
_material.clippingPlanes = this.clippingPlanes;
// TODO: Add clipping for Spherical projection.
}
const worldOffsetX =
mapView.projection.worldExtent(0, 0).max.x * tile.offset;
// This prevents aliasing issues in the pixel shader, there are artifacts
// at low zoom levels, so we increase the factor by 10 to 1%.
const expandFactor = mapView.zoomLevel <= 2 ? 1.01 : 1.001;
const planes = _material.clippingPlanes;
const rightConstant =
tile.center.x -
mapView.worldCenter.x +
tile.boundingBox.extents.x * expandFactor +
export function addRenderHelper(object: THREE.Object3D) {
object.onBeforeRender = chainCallbacks(
object.onBeforeRender,
ExtrusionFeature.onBeforeRender
);
}
let i = 0, il = ((object as THREE.Mesh).material as THREE.Material[]).length;
i < il;
i++
) {
((object as THREE.Mesh).material as THREE.Material[])[i] = this.getOutlineMaterial(
((object as THREE.Mesh).material as THREE.Material[])[i]
);
}
} else {
(object as THREE.Mesh).material = this.getOutlineMaterial(
(object as THREE.Mesh).material as THREE.Material
);
}
this.m_originalOnBeforeRenders[object.uuid] = object.onBeforeRender;
object.onBeforeRender = chainCallbacks(
object.onBeforeRender,
this.onBeforeRender.bind(this)
);
}