案例展示
场景剖切效果
<template>
<div id="TO"></div>
</template>
<script setup>
import { onMounted } from 'vue';
onMounted(() => {
//初始化场景
let TO = new ThingOrigin("fileModel", document.getElementById("TO"))
//导入模型
TO.model.initFileModel(
{
modelName: "fileModel-" + new Date().getTime(),//模型名称
base: {
modelUrl: `${import.meta.env.BASE_URL}models/agv.gltf`, //模型地址
},
modelType: "gltf", //模型类型
scale: {//缩放大小
x: 5,
y: 5,
z: 5,
}
}
).then((model) => {
//添加到场景中
TO.scene.add(model.scene);
//创建场景的剖切
TO.effect.initSceneClip("x", 0.1);
});
});
</script>
<style scoped>
#TO {
width: 100%;
height: 400px;
position: relative;
}
</style>API 介绍
effect.initSceneClip
| 方法签名 | 返回值 | 描述 |
|---|---|---|
initSceneClip(axis: string, constant: number) | void | 场景剖切 |
参数说明:
| 参数名 | 说明 | 类型 | 必填 | 默认值 |
|---|---|---|---|---|
axis | 剖切轴 | string('x' | 'y' | 'z') | 是 | - |
constant | 初始剖切位置 | number | 是 | - |