How to use the @here/harp-utils.chainCallbacks function in @here/harp-utils

To help you get started, we’ve selected a few @here/harp-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heremaps / harp.gl / @here / harp-materials / lib / MapMeshMaterials.ts View on Github external
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);
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryCreator.ts View on Github external
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 +
github heremaps / harp.gl / @here / harp-materials / lib / MapMeshMaterials.ts View on Github external
export function addRenderHelper(object: THREE.Object3D) {
        object.onBeforeRender = chainCallbacks(
            object.onBeforeRender,
            ExtrusionFeature.onBeforeRender
        );
    }
github heremaps / harp.gl / @here / harp-mapview / lib / composing / Outline.ts View on Github external
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)
        );
    }