mirror of
https://gitee.com/ice-gl/icegl-three-vue-tres.git
synced 2025-04-05 06:22:43 +08:00
3DTiles 场景升级
This commit is contained in:
parent
b2c59e56a5
commit
c060e6fa6a
@ -4,11 +4,11 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-02-28 14:45:57
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-09-12 12:04:38
|
||||
* @LastEditTime: 2025-02-06 10:35:38
|
||||
-->
|
||||
<template>
|
||||
<TresGroup>
|
||||
<primitive :object="tiles.group" />
|
||||
<primitive :object="tiles.group" :rotation="[-Math.PI / 2, 0, 0]" />
|
||||
</TresGroup>
|
||||
</template>
|
||||
|
||||
@ -87,8 +87,10 @@ const setEffectMaterial = (mesh: any) => {
|
||||
|
||||
const tiles = new TilesRenderer('https://jdvop.oss-cn-qingdao.aliyuncs.com/mapv-data/titleset/sz_ns/no.json') //tileset 如果使用cesium 的tilies带tranfrom的 请把root的tranfrom去除 gltfUpAxis
|
||||
tiles.errorTarget = 2
|
||||
tiles.onLoadModel = (scene: any) => {
|
||||
scene.scene.traverse((c) => {
|
||||
|
||||
tiles.addEventListener('load-model', ({ scene }) => {
|
||||
// tiles.onLoadModel = (scene: any) => {
|
||||
scene.traverse((c) => {
|
||||
if (c.isMesh) {
|
||||
setEffectMaterial(c)
|
||||
c.receiveShadow = false
|
||||
@ -114,16 +116,16 @@ tiles.onLoadModel = (scene: any) => {
|
||||
})
|
||||
|
||||
// 对齐 tiles center
|
||||
// const box = new THREE.Box3()
|
||||
// const sphere = new THREE.Sphere()
|
||||
// if (tiles.getBoundingBox(box)) {
|
||||
// box.getCenter(tiles.group.position)
|
||||
// tiles.group.position.multiplyScalar(- 1)
|
||||
// } else if (tiles.getBoundingSphere(sphere)) {
|
||||
// tiles.group.position.copy(sphere.center)
|
||||
// tiles.group.position.multiplyScalar(- 1)
|
||||
// }
|
||||
}
|
||||
const box = new THREE.Box3()
|
||||
const sphere = new THREE.Sphere()
|
||||
if (tiles.getBoundingBox(box)) {
|
||||
box.getCenter(tiles.group.position)
|
||||
tiles.group.position.multiplyScalar(- 1)
|
||||
} else if (tiles.getBoundingSphere(sphere)) {
|
||||
tiles.group.position.copy(sphere.center)
|
||||
tiles.group.position.multiplyScalar(- 1)
|
||||
}
|
||||
})
|
||||
onLoadTileSetForCesium3Dtitles(tiles)
|
||||
|
||||
const { renderer, sizes } = useTresContext()
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-02-27 10:02:33
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-09-12 12:08:53
|
||||
* @LastEditTime: 2025-02-06 10:28:28
|
||||
-->
|
||||
<template>
|
||||
<TresGroup>
|
||||
@ -20,15 +20,14 @@ import * as THREE from 'three'
|
||||
|
||||
const tiles = new TilesRenderer('https://opensource-1314935952.cos.ap-nanjing.myqcloud.com/3Dtiles/simpleGIS/data/tileset.json')
|
||||
tiles.errorTarget = 0
|
||||
const onLoadModel = (scene: any ) => {
|
||||
scene.scene.traverse((c) => {
|
||||
const onLoadModel = ({ scene }) => {
|
||||
scene.traverse((c) => {
|
||||
if (c.isMesh) {
|
||||
c.material.side = 2
|
||||
c.receiveShadow = false
|
||||
c.castShadow = false
|
||||
}
|
||||
})
|
||||
|
||||
// 对齐 tiles center
|
||||
const box = new THREE.Box3()
|
||||
const sphere = new THREE.Sphere()
|
||||
@ -40,7 +39,9 @@ const onLoadModel = (scene: any ) => {
|
||||
tiles.group.position.multiplyScalar(-1)
|
||||
}
|
||||
}
|
||||
tiles.onLoadModel = onLoadModel
|
||||
|
||||
tiles.addEventListener('load-model', onLoadModel)
|
||||
// tiles.onLoadModel = onLoadModel
|
||||
|
||||
const { camera, renderer, sizes } = useTresContext()
|
||||
watchEffect(() => {
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-02-23 16:40:14
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-09-20 09:48:23
|
||||
* @LastEditTime: 2025-02-06 10:16:43
|
||||
*/
|
||||
|
||||
export default {
|
||||
@ -45,7 +45,7 @@ export default {
|
||||
type: 'img',
|
||||
name: 'renderer3DTiles',
|
||||
title: '3DTiles展示',
|
||||
referenceSource: { title: 'nasa-ammos', url: 'https://nasa-ammos.github.io/3DTilesRendererJS/' },
|
||||
referenceSource: { title: 'nasa-ammos', url: 'https://github.com/NASA-AMMOS/3DTilesRendererJS' },
|
||||
},
|
||||
{ src: 'plugins/simpleGIS/preview/mapBuildings.gif', type: 'img', name: 'mapBuildings', title: '地图和3DTiles结合' },
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user