Skip to content

Models rendering behind some things #8

Description

@cfpwastaken
Image Image

model eating the building (without changing position from the first image, only rotation)

Image Image

looks like the buildings are levitating??

Image

model being eaten by seemingly nothing?

my code:

let loc = { lat: 0, lng: 0 }
export function init(map: maplibregl.Map) {
	// @ts-expect-error ignore
	const mapScene = new MTP.MapScene(map);
	mapScene.addLight(new THREE.AmbientLight(0xffffff, 2));

	// Light up all 4 sides
	const light = new THREE.DirectionalLight(0xffffff, 3);
	light.position.set(0, 0, 10);
	mapScene.addLight(light);
	const light2 = new THREE.DirectionalLight(0xffffff, 3);
	light2.position.set(0, 0, -10);
	mapScene.addLight(light2);
	const light3 = new THREE.DirectionalLight(0xffffff, 3);
	light3.position.set(10, 0, 0);
	mapScene.addLight(light3);
	const light4 = new THREE.DirectionalLight(0xffffff, 3);
	light4.position.set(-10, 0, 0);
	mapScene.addLight(light4);

	let rtcGroup: THREE.Group;

	const loader = new GLTFLoader();
	loader.load('/test.glb', (gltf) => {
		const scale = 0.15;
		rtcGroup = MTP.Creator.createRTCGroup([loc.lng, loc.lat], [Math.PI / 2, Math.PI, 0], [scale, scale, scale]);
		rtcGroup.position.z += 0.2;
		rtcGroup.add(gltf.scene);
		mapScene.addObject(rtcGroup);
		console.log("3D model added to map");
	});

	let lastLocation = { lat: loc.lat, lng: loc.lng };

	setInterval(() => {
		if (!rtcGroup) return;
		if (lastLocation.lat === loc.lat && lastLocation.lng === loc.lng) return;
		rtcGroup.position.copy(MTP.SceneTransform.lngLatToVector3([location.lng, location.lat]));
		rtcGroup.position.z += 0.2;
		map.triggerRepaint();
		lastLocation = { lat: loc.lat, lng: loc.lng };
	}, 500);
}

Did I configure MTP incorrectly? Or is this a bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions