private _createPointMatr()

in packages/layers/xyz-poi-tile/src/POILayer.ts [579:653]


	private _createPointMatr(polaris: AbstractPolaris) {
		const pointOffset = this.getProps('pointOffset')
		const pointColorBlend = this.getProps('pointColorBlend')
		let P_COLOR_MODE = 0
		switch (pointColorBlend) {
			case 'replace':
				P_COLOR_MODE = 0
				break
			case 'multiply':
				P_COLOR_MODE = 1
				break
			case 'add':
				P_COLOR_MODE = 2
				break
		}

		const matr = new PointMaterial({
			alphaMode: 'BLEND',
			depthTest: this.getProps('depthTest'),
			baseColorFactor: { r: 1, g: 1, b: 1 },
			baseColorTexture: specifyTexture({
				image: { uri: this.getProps('pointImage'), extensions: { EXT_image: { flipY: true } } },
				sampler: {
					minFilter: 'LINEAR_MIPMAP_LINEAR',
					magFilter: 'LINEAR',
					wrapS: 'CLAMP_TO_EDGE',
					wrapT: 'CLAMP_TO_EDGE',
				},
			}),
			defines: {
				P_COLOR_MODE,
			},
			uniforms: {
				uOffset: {
					value: { x: pointOffset[0], y: pointOffset[1] },
				},
				uResolution: {
					value: { x: polaris.canvasWidth, y: polaris.canvasHeight },
				},
			},
			global: `
				uniform vec2 uOffset;
				uniform vec2 uResolution;

				varying vec3 vColor;
			`,
			vertGlobal: `
				attribute float aSize;
				attribute vec3 aColor;
			`,
			vertPointGeometry: `
				pointSize = aSize;
			`,
			vertOutput: `
				vColor = aColor / 255.0;
				// calc point offsets
				vec2 sizes = vec2(aSize);
				glPosition = projectionMatrix * modelViewPosition;
				glPosition /= glPosition.w;
				vec2 pxRange = sizes / uResolution;
				vec2 offset = uOffset;
				glPosition.xy += offset * pxRange;
			`,
			fragOutput: `
			#if P_COLOR_MODE == 0          // replace
				fragColor.rgb = vColor;
			#elif P_COLOR_MODE == 1        // multiply
				fragColor.rgb *= vColor;
			#elif P_COLOR_MODE == 2        // add
				fragColor.rgb += vColor;
			#endif
			`,
		})
		return matr
	}