Skip to content

Gltf图层(GltfLayer)

示例

示例源码
vue
<template>
  <div style="height: 400px">
    <mb-map :zoom="18" :pitch="60" :bearing="60" :center="mapCenter">
      <mb-tianditu-layer :types="['img']" />
      <mb-gltf-layer
        :gltf-url="gltfUrl"
        :data="gltfData"
        :get-orientation="[0, 0, 90]"
        get-color="rgba(255,0,0,0)"
        :size-scale="10"
      />
    </mb-map>
  </div>
</template>

<script setup lang="ts">
const mapCenter = [116, 39]
const gltfData = [{ position: [116, 39] }]
const gltfUrl = `${__RESOURCE_URL__}gltf/GroundVehicle/GroundVehicle.glb`
</script>

API

PROPS

名称描述类型默认值
id图层Idstring-
gltf-url模型URLstring-
auto-highlight本属性为true且pickable为true时,则会将鼠标悬浮选中的对象设为高亮booleanfalse
data图层源数据string / IndexAny / AnyArr / Promise<any>''
get-orientation朝向信息number[] / AnyNumbersFunc[0, 0, 90]
get-position位置信息AnyFunc-
get-scale放大倍数信息number[] / AnyNumbersFunc[1, 1, 1]
get-translation位移信息number[] / AnyNumbersFunc[0, 0, 0]
highlight-color要与高亮对象原始颜色进行混合(blend)的颜色值string / number[][255, 255, 128, 1]
highlighted-object-index高亮元素序号number-1
opacity透明度number1
pickable图层是否会响应鼠标事件,若为false,则组件不会emit鼠标相关事件booleanfalse
size-scale放大倍数number1
show是否显示booleantrue
animations动画配置IndexAny{ speed: 5 }

EVENTS

名称描述参数
created初始化完成事件-
mousemove-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }
mouseleave--
click-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }

SLOTS

名称描述

METHODS

名称描述定义