Skip to content

案例展示

创建 Group

<template>
  <div id="TO"></div>
</template>

<script setup>
import { onMounted } from 'vue';

onMounted(() => {
  // 初始化场景
  let TO = new ThingOrigin('groupTest', document.getElementById('TO'));

  //创建Group
  const group = TO.model.initGroup();
  //创建圆柱体
  const cylinder = TO.model.initCylinder({
    position: {
      x: 10,
      y: 0,
      z: 0
    },
    material: {
      color: 0xff0000
    }
  });
  //创建立方体
  const cube = TO.model.initCube({
    position: {
      x: -20,
      y: 0,
      z: 0
    },
    material: {
      color: 0x0000ff
    }
  });
  //填加到组内
  group.add(cylinder, cube);
  group.position.set(0, 10, 0);
  //添加到场景内
  TO.scene.add(group);
  //创建变换控制器
  TO.controls.initTransform();
  //设置变换器模式-移动
  TO.controls.setTransformMode(group.name, 'translate');
});
</script>

<style scoped>
#TO {
  width: 100%;
  height: 400px;
  position: relative;
}
</style>

API 介绍

model.initGroup

方法签名返回值描述
initGroup(modelInfo?: modelInfoParams)Object3D创建 Group

参数说明:

参数名说明类型必填默认值
modelInfo模型参数modelInfoParams--